From 94fa51c425898821d246b423a761aee88a3199b1 Mon Sep 17 00:00:00 2001 From: prajith Date: Tue, 17 Aug 2021 17:05:34 +0530 Subject: [PATCH] multiple fixes with regard to documentation and json response --- builder-lib/Paws/API/Builder.pm | 11 +++++++++-- templates/default/callclass_documentation.tt | 2 +- templates/json/map_enum.tt | 3 --- templates/restjson/map_enum.tt | 3 --- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/builder-lib/Paws/API/Builder.pm b/builder-lib/Paws/API/Builder.pm index 152a54f514..b85e768910 100644 --- a/builder-lib/Paws/API/Builder.pm +++ b/builder-lib/Paws/API/Builder.pm @@ -31,6 +31,13 @@ package Paws::API::Builder { has service_full_name => (is => 'ro', lazy => 1, default => sub { $_[0]->api_struct->{metadata}->{ serviceFullName } }); has service => (is => 'ro', lazy => 1, default => sub { $_[0]->api_struct->{metadata}->{ endpointPrefix } }); has signing_name => (is => 'ro', lazy => 1, default => sub { $_[0]->api_struct->{metadata}->{ signingName } // $_[0]->api_struct->{metadata}->{ endpointPrefix } }); + has service_short => (is => 'ro', lazy => 1, default => sub { + my $service = $_[0]->service; + if ( index($service, '.') != -1 ) { + return (split(/\./, $service))[1]; + } + return $service; + }); has version => (is => 'ro', lazy => 1, default => sub { $_[0]->api_struct->{metadata}->{ apiVersion } }); has endpoint_role => (is => 'ro', lazy => 1, default => 'Paws::API::EndpointResolver' ); @@ -637,10 +644,10 @@ package Paws::API::Builder { my $inputs = $self->input_for_operation($op_name); my $example_str = ''; - if ($out_shape) { + if ($out_shape) { $example_str .= "my \$${out_shape} = "; } - $example_str .= "\$" . $self->service . "->" . $op_name . "("; + $example_str .= "\$" . $self->service_short . "->" . $op_name . "("; my @args = (); my $shape_cache = {}; diff --git a/templates/default/callclass_documentation.tt b/templates/default/callclass_documentation.tt index d35381f3b1..5d2727319a 100644 --- a/templates/default/callclass_documentation.tt +++ b/templates/default/callclass_documentation.tt @@ -14,7 +14,7 @@ You shouldn't make instances of this class. Each attribute should be used as a n =head1 SYNOPSIS - my $[% c.service %] = Paws->service('[% c.api_ns %]'); + my $[% c.service_short %] = Paws->service('[% c.api_ns %]'); [% synopsis %] Values for attributes that are native types (Int, String, Float, etc) can passed as-is (scalar values). Values for complex Types (objects) can be passed as a HashRef. The keys and values of the hashref will be used to instance the underlying object. diff --git a/templates/json/map_enum.tt b/templates/json/map_enum.tt index 16922cea73..3ea81aee7a 100644 --- a/templates/json/map_enum.tt +++ b/templates/json/map_enum.tt @@ -1,11 +1,8 @@ [%- -%] package [% inner_class %]; use Moose; - with 'Paws::API::MapParser'; use MooseX::ClassAttribute; - class_has xml_keys =>(is => 'ro', default => '[% iclass.key.locationName || 'key' %]'); - class_has xml_values =>(is => 'ro', default => '[% iclass.value.locationName || 'value' %]'); [% FOREACH param_name=keys_shape.enum.sort -%] has [% param_name %] => (is => 'ro', isa => '[% c.get_caller_class_type(iclass.value.shape) %]'); diff --git a/templates/restjson/map_enum.tt b/templates/restjson/map_enum.tt index 16922cea73..3ea81aee7a 100644 --- a/templates/restjson/map_enum.tt +++ b/templates/restjson/map_enum.tt @@ -1,11 +1,8 @@ [%- -%] package [% inner_class %]; use Moose; - with 'Paws::API::MapParser'; use MooseX::ClassAttribute; - class_has xml_keys =>(is => 'ro', default => '[% iclass.key.locationName || 'key' %]'); - class_has xml_values =>(is => 'ro', default => '[% iclass.value.locationName || 'value' %]'); [% FOREACH param_name=keys_shape.enum.sort -%] has [% param_name %] => (is => 'ro', isa => '[% c.get_caller_class_type(iclass.value.shape) %]');