I have generated a perl client for a rest api with openapi generator. The slimmed down AuthorizeRequestDTO class is :
package WWW::OpenAPIClient::Object::AuthorizeRequestDTO; require 5.6.0; use strict; use warnings; use utf8; use JSON qw(decode_json); use Data::Dumper; use Module::Runtime qw(use_module); use Log::Any qw($log); use Date::Parse; use DateTime; use base ("Class::Accessor", "Class::Data::Inheritable"); __PACKAGE__->mk_classdata('attribute_map' => {}); __PACKAGE__->mk_classdata('openapi_types' => {}); __PACKAGE__->mk_classdata('method_documentation' => {}); __PACKAGE__->mk_classdata('class_documentation' => {}); # new plain object sub new { my ($class, %args) = @_; my $self = bless {}, $class; $self->init(%args); return $self; } # initialize the object sub init { my ($self, %args) = @_; foreach my $attribute (keys %{$self->attribute_map}) { my $args_key = $self->attribute_map->{$attribute}; $self->$attribute( $args{ $args_key } ); } } __PACKAGE__->method_documentation({ 'username' => { datatype => 'string', base_name => 'Username', description => '', format => '', read_only => '', }, 'password' => { datatype => 'string', base_name => 'Password', description => '', format => '', read_only => '', }, }); __PACKAGE__->openapi_types( { 'username' => 'string', 'password' => 'string' } ); __PACKAGE__->attribute_map( { 'username' => 'USERNAME', 'password' => 'PASSWORD' } ); __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map}); 1;
I'm trying to create a new object by setting the username and password fields but they always come up undefined !!
my %h= ('username' => 'TEST_USER','password' => 'dsds'); my $authobj=WWW::OpenAPIClient::Object::AuthorizeRequestDTO->new(%h); print Dumper $authobj; $VAR1 = bless( { 'username' => undef, 'password' => undef }, 'WWW::OpenAPIClient::Object::AuthorizeRequestDTO' );
The init method does
$self->$attribute
what does that mean ? that it calls a $self->update() and a $self->password() methods? But these do not exist in the code!They are only described in __PACKAGE__->method_documentation
Am I missing something or hasn't the openapi generator generated those two methods?

In reply to OpenAPI generator issue by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.