forked from loafle/openapi-generator-original
better logic for accept and content-type, added test cases
This commit is contained in:
@@ -253,4 +253,39 @@ sub deserialize
|
||||
|
||||
}
|
||||
|
||||
# return 'Accept' based on an array of accept provided
|
||||
# @param [Array] header_accept_array Array fo 'Accept'
|
||||
# @return String Accept (e.g. application/json)
|
||||
sub select_header_accept
|
||||
{
|
||||
my ($self, @header) = @_;
|
||||
|
||||
if (@header == 0 || (@header == 1 && $header[0] eq '')) {
|
||||
return undef;
|
||||
} elsif (grep(/^application\/json$/i, @header)) {
|
||||
return 'application/json';
|
||||
} else {
|
||||
return join(',', @header);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# return the content type based on an array of content-type provided
|
||||
# @param [Array] content_type_array Array fo content-type
|
||||
# @return String Content-Type (e.g. application/json)
|
||||
sub select_header_content_type
|
||||
{
|
||||
my ($self, @header) = @_;
|
||||
|
||||
if (@header == 0 || (@header == 1 && $header[0] eq '')) {
|
||||
return 'application/json'; # default to application/json
|
||||
} elsif (grep(/^application\/json$/i, @header)) {
|
||||
return 'application/json';
|
||||
} else {
|
||||
return join(',', @header);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
@@ -86,12 +86,14 @@ sub new {
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
my $_header_accept = 'application/json, application/xml';
|
||||
if ($_header_accept ne '') {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
my @_header_content_type = ('application/json','application/xml',);
|
||||
$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
#my @_header_content_type = ('application/json','application/xml',);
|
||||
#$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json', 'application/xml', );
|
||||
|
||||
|
||||
|
||||
@@ -137,12 +139,14 @@ sub new {
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
my $_header_accept = 'application/json, application/xml';
|
||||
if ($_header_accept ne '') {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
my @_header_content_type = ('application/json','application/xml',);
|
||||
$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
#my @_header_content_type = ('application/json','application/xml',);
|
||||
#$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json', 'application/xml', );
|
||||
|
||||
|
||||
|
||||
@@ -188,12 +192,14 @@ sub new {
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
my $_header_accept = 'application/json, application/xml';
|
||||
if ($_header_accept ne '') {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
my @_header_content_type = ();
|
||||
$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
#my @_header_content_type = ();
|
||||
#$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
# query params
|
||||
if ( exists $args{'status'}) {
|
||||
@@ -242,12 +248,14 @@ sub new {
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
my $_header_accept = 'application/json, application/xml';
|
||||
if ($_header_accept ne '') {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
my @_header_content_type = ();
|
||||
$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
#my @_header_content_type = ();
|
||||
#$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
# query params
|
||||
if ( exists $args{'tags'}) {
|
||||
@@ -301,12 +309,14 @@ sub new {
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
my $_header_accept = 'application/json, application/xml';
|
||||
if ($_header_accept ne '') {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
my @_header_content_type = ();
|
||||
$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
#my @_header_content_type = ();
|
||||
#$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
|
||||
|
||||
@@ -364,12 +374,14 @@ sub new {
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
my $_header_accept = 'application/json, application/xml';
|
||||
if ($_header_accept ne '') {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
my @_header_content_type = ('application/x-www-form-urlencoded',);
|
||||
$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
#my @_header_content_type = ('application/x-www-form-urlencoded',);
|
||||
#$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/x-www-form-urlencoded', );
|
||||
|
||||
|
||||
|
||||
@@ -433,12 +445,14 @@ sub new {
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
my $_header_accept = 'application/json, application/xml';
|
||||
if ($_header_accept ne '') {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
my @_header_content_type = ();
|
||||
$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
#my @_header_content_type = ();
|
||||
#$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
|
||||
# header params
|
||||
@@ -496,12 +510,14 @@ sub new {
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
my $_header_accept = 'application/json, application/xml';
|
||||
if ($_header_accept ne '') {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
my @_header_content_type = ('multipart/form-data',);
|
||||
$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
#my @_header_content_type = ('multipart/form-data',);
|
||||
#$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('multipart/form-data', );
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -81,12 +81,14 @@ sub new {
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
my $_header_accept = 'application/json, application/xml';
|
||||
if ($_header_accept ne '') {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
my @_header_content_type = ();
|
||||
$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
#my @_header_content_type = ();
|
||||
#$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
|
||||
|
||||
@@ -132,12 +134,14 @@ sub new {
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
my $_header_accept = 'application/json, application/xml';
|
||||
if ($_header_accept ne '') {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
my @_header_content_type = ();
|
||||
$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
#my @_header_content_type = ();
|
||||
#$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
|
||||
|
||||
@@ -191,12 +195,14 @@ sub new {
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
my $_header_accept = 'application/json, application/xml';
|
||||
if ($_header_accept ne '') {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
my @_header_content_type = ();
|
||||
$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
#my @_header_content_type = ();
|
||||
#$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
|
||||
|
||||
@@ -252,12 +258,14 @@ sub new {
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
my $_header_accept = 'application/json, application/xml';
|
||||
if ($_header_accept ne '') {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
my @_header_content_type = ();
|
||||
$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
#my @_header_content_type = ();
|
||||
#$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -86,12 +86,14 @@ sub new {
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
my $_header_accept = 'application/json, application/xml';
|
||||
if ($_header_accept ne '') {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
my @_header_content_type = ();
|
||||
$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
#my @_header_content_type = ();
|
||||
#$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
|
||||
|
||||
@@ -137,12 +139,14 @@ sub new {
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
my $_header_accept = 'application/json, application/xml';
|
||||
if ($_header_accept ne '') {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
my @_header_content_type = ();
|
||||
$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
#my @_header_content_type = ();
|
||||
#$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
|
||||
|
||||
@@ -188,12 +192,14 @@ sub new {
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
my $_header_accept = 'application/json, application/xml';
|
||||
if ($_header_accept ne '') {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
my @_header_content_type = ();
|
||||
$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
#my @_header_content_type = ();
|
||||
#$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
|
||||
|
||||
@@ -240,12 +246,14 @@ sub new {
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
my $_header_accept = 'application/json, application/xml';
|
||||
if ($_header_accept ne '') {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
my @_header_content_type = ();
|
||||
$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
#my @_header_content_type = ();
|
||||
#$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
# query params
|
||||
if ( exists $args{'username'}) {
|
||||
@@ -296,12 +304,14 @@ sub new {
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
my $_header_accept = 'application/json, application/xml';
|
||||
if ($_header_accept ne '') {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
my @_header_content_type = ();
|
||||
$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
#my @_header_content_type = ();
|
||||
#$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
|
||||
|
||||
@@ -349,12 +359,14 @@ sub new {
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
my $_header_accept = 'application/json, application/xml';
|
||||
if ($_header_accept ne '') {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
my @_header_content_type = ();
|
||||
$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
#my @_header_content_type = ();
|
||||
#$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
|
||||
|
||||
@@ -411,12 +423,14 @@ sub new {
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
my $_header_accept = 'application/json, application/xml';
|
||||
if ($_header_accept ne '') {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
my @_header_content_type = ();
|
||||
$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
#my @_header_content_type = ();
|
||||
#$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
|
||||
|
||||
@@ -472,12 +486,14 @@ sub new {
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
my $_header_accept = 'application/json, application/xml';
|
||||
if ($_header_accept ne '') {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
my @_header_content_type = ();
|
||||
$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
#my @_header_content_type = ();
|
||||
#$header_params->{'Content-Type'} = scalar(@_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user