TT#47024 Use config to document allowed Accept header values

Change-Id: If4c064d36ac0fadc97f5dd193bdafe619494e4e4
changes/18/24618/11
Irina Peshinskaya 7 years ago
parent e36c5da012
commit 7c13308271

@ -226,6 +226,7 @@ sub GET : Allow {
fields => $form_fields, fields => $form_fields,
uploads => $form_fields_upload, uploads => $form_fields_upload,
config => $full_mod->config , config => $full_mod->config ,
( $full_item_mod && $full_item_mod->can('config') ) ? (item_config => $full_item_mod->config) : () ,
query_params => $query_params, query_params => $query_params,
actions => $actions, actions => $actions,
item_actions => $item_actions, item_actions => $item_actions,

@ -281,19 +281,36 @@ sub generate_swagger_datastructure {
} }
if (grep {m/^GET$/} @{ $col->{item_actions} }) { if (grep {m/^GET$/} @{ $col->{item_actions} }) {
my $action_config = $col->{item_config}->{action}->{GET};
my $produces = $action_config->{ReturnContentType}
? ref $action_config->{ReturnContentType} eq 'ARRAY'
? $action_config->{ReturnContentType}
: $action_config->{ReturnContentType} eq 'binary' ? ['application/octet-stream'] : undef
: undef;
$item_p->{get} = { $item_p->{get} = {
summary => "Get a specific $entity", summary => "Get a specific $entity",
tags => ["$entity"], tags => ["$entity"],
$produces ? ( produces => $produces ) : (),
responses => { responses => {
"200" => { "200" => {
description => "$title", description => "$title",
$produces ? ( content => { map {
$_ => {
schema => {
$_ ne 'application/json'
? (type => 'string')
: ('$ref' => "#/components/schemas/$entity"),
}
} } @$produces } )
: (
content => { content => {
"application/json" => { "application/json" => {
schema => { schema => {
'$ref' => "#/components/schemas/$entity", '$ref' => "#/components/schemas/$entity",
} }
}, },
}, }
),
} }
} }
}; };

Loading…
Cancel
Save