From d4dbbd677bb10bbe04b396edbbe1b45eb40d4b30 Mon Sep 17 00:00:00 2001 From: wing328 Date: Wed, 30 Nov 2016 15:53:58 +0800 Subject: [PATCH 1/8] new files for dart client --- bin/dart-petstore.sh | 2 +- .../codegen/languages/DartClientCodegen.java | 17 + .../src/main/resources/dart/README.mustache | 316 ++++++++++++++ .../src/main/resources/dart/api_doc.mustache | 85 ++++ .../main/resources/dart/object_doc.mustache | 16 + .../client/petstore/dart/swagger/README.md | 338 +++++++++++++++ .../petstore/dart/swagger/docs/ApiResponse.md | 17 + .../petstore/dart/swagger/docs/Category.md | 16 + .../petstore/dart/swagger/docs/Order.md | 20 + .../client/petstore/dart/swagger/docs/Pet.md | 20 + .../petstore/dart/swagger/docs/PetApi.md | 403 ++++++++++++++++++ .../petstore/dart/swagger/docs/StoreApi.md | 191 +++++++++ .../client/petstore/dart/swagger/docs/Tag.md | 16 + .../client/petstore/dart/swagger/docs/User.md | 22 + .../petstore/dart/swagger/docs/UserApi.md | 367 ++++++++++++++++ 15 files changed, 1845 insertions(+), 1 deletion(-) create mode 100644 modules/swagger-codegen/src/main/resources/dart/README.mustache create mode 100644 modules/swagger-codegen/src/main/resources/dart/api_doc.mustache create mode 100644 modules/swagger-codegen/src/main/resources/dart/object_doc.mustache create mode 100644 samples/client/petstore/dart/swagger/README.md create mode 100644 samples/client/petstore/dart/swagger/docs/ApiResponse.md create mode 100644 samples/client/petstore/dart/swagger/docs/Category.md create mode 100644 samples/client/petstore/dart/swagger/docs/Order.md create mode 100644 samples/client/petstore/dart/swagger/docs/Pet.md create mode 100644 samples/client/petstore/dart/swagger/docs/PetApi.md create mode 100644 samples/client/petstore/dart/swagger/docs/StoreApi.md create mode 100644 samples/client/petstore/dart/swagger/docs/Tag.md create mode 100644 samples/client/petstore/dart/swagger/docs/User.md create mode 100644 samples/client/petstore/dart/swagger/docs/UserApi.md diff --git a/bin/dart-petstore.sh b/bin/dart-petstore.sh index 357cbac45ff..bfb9e8179f0 100755 --- a/bin/dart-petstore.sh +++ b/bin/dart-petstore.sh @@ -27,7 +27,7 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l dart -o samples/client/petstore/dart/swagger" +ags="$@ generate -t modules/swagger-codegen/src/main/resources/dart -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l dart -o samples/client/petstore/dart/swagger" # then options to generate the library for vm would be: #ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l dart -o samples/client/petstore/dart/swagger_vm -DbrowserClient=false -DpubName=swagger_vm" diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/DartClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/DartClientCodegen.java index 1d90984f8b0..1d7a2e62f2f 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/DartClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/DartClientCodegen.java @@ -25,6 +25,8 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig { protected String pubVersion = "1.0.0"; protected String pubDescription = "Swagger API client"; protected String sourceFolder = ""; + protected String apiDocPath = "docs/"; + protected String modelDocPath = "docs/"; public DartClientCodegen() { super(); @@ -39,6 +41,8 @@ public DartClientCodegen() { embeddedTemplateDir = templateDir = "dart"; apiPackage = "lib.api"; modelPackage = "lib.model"; + modelDocTemplateFiles.put("object_doc.mustache", ".md"); + apiDocTemplateFiles.put("api_doc.mustache", ".md"); setReservedWordsLowerCase( Arrays.asList( @@ -160,6 +164,9 @@ public void processOpts() { supportingFiles.add(new SupportingFile("auth/oauth.mustache", authFolder, "oauth.dart")); supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); + supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); + + } @@ -179,6 +186,16 @@ public String modelFileFolder() { return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar); } + @Override + public String apiDocFileFolder() { + return (outputFolder + "/" + apiDocPath).replace('/', File.separatorChar); + } + + @Override + public String modelDocFileFolder() { + return (outputFolder + "/" + modelDocPath).replace('/', File.separatorChar); + } + @Override public String toVarName(String name) { // replace - with _ e.g. created-at => created_at diff --git a/modules/swagger-codegen/src/main/resources/dart/README.mustache b/modules/swagger-codegen/src/main/resources/dart/README.mustache new file mode 100644 index 00000000000..c732448cecf --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/dart/README.mustache @@ -0,0 +1,316 @@ +# NAME + +{{moduleName}}::Role - a Moose role for the {{appName}} + +{{#appDescription}}{{{appDescription}}}{{/appDescription}} + +# VERSION + +Automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: + +- API version: {{appVersion}} +- Package version: {{moduleVersion}} +- Build date: {{generatedDate}} +- Build package: {{generatorClass}} +{{#infoUrl}} +For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) +{{/infoUrl}} + +## A note on Moose + +This role is the only component of the library that uses Moose. See +{{moduleName}}::ApiFactory for non-Moosey usage. + +# SYNOPSIS + +The Perl Swagger Codegen project builds a library of Perl modules to interact with +a web service defined by a OpenAPI Specification. See below for how to build the +library. + +This module provides an interface to the generated library. All the classes, +objects, and methods (well, not quite \*all\*, see below) are flattened into this +role. + + package MyApp; + use Moose; + with '{{moduleName}}::Role'; + + package main; + + my $api = MyApp->new({ tokens => $tokens }); + + my $pet = $api->get_pet_by_id(pet_id => $pet_id); + + +## Structure of the library + +The library consists of a set of API classes, one for each endpoint. These APIs +implement the method calls available on each endpoint. + +Additionally, there is a set of "object" classes, which represent the objects +returned by and sent to the methods on the endpoints. + +An API factory class is provided, which builds instances of each endpoint API. + +This Moose role flattens all the methods from the endpoint APIs onto the consuming +class. It also provides methods to retrieve the endpoint API objects, and the API +factory object, should you need it. + +For documentation of all these methods, see AUTOMATIC DOCUMENTATION below. + +## Configuring authentication + +In the normal case, the OpenAPI Spec will describe what parameters are +required and where to put them. You just need to supply the tokens. + + my $tokens = { + # basic + username => $username, + password => $password, + + # oauth + access_token => $oauth_token, + + # keys + $some_key => { token => $token, + prefix => $prefix, + in => $in, # 'head||query', + }, + + $another => { token => $token, + prefix => $prefix, + in => $in, # 'head||query', + }, + ..., + + }; + + my $api = MyApp->new({ tokens => $tokens }); + +Note these are all optional, as are `prefix` and `in`, and depend on the API +you are accessing. Usually `prefix` and `in` will be determined by the code generator from +the spec and you will not need to set them at run time. If not, `in` will +default to 'head' and `prefix` to the empty string. + +The tokens will be placed in the `{{moduleName}}::Configuration` namespace +as follows, but you don't need to know about this. + +- `${{moduleName}}::Configuration::username` + + String. The username for basic auth. + +- `${{moduleName}}::Configuration::password` + + String. The password for basic auth. + +- `${{moduleName}}::Configuration::api_key` + + Hashref. Keyed on the name of each key (there can be multiple tokens). + + ${{moduleName}}::Configuration::api_key = { + secretKey => 'aaaabbbbccccdddd', + anotherKey => '1111222233334444', + }; + +- `${{moduleName}}::Configuration::api_key_prefix` + + Hashref. Keyed on the name of each key (there can be multiple tokens). Note not + all api keys require a prefix. + + ${{moduleName}}::Configuration::api_key_prefix = { + secretKey => 'string', + anotherKey => 'same or some other string', + }; + +- `${{moduleName}}::Configuration::access_token` + + String. The OAuth access token. + +# METHODS + +## `base_url` + +The generated code has the `base_url` already set as a default value. This method +returns (and optionally sets, but only if the API client has not been +created yet) the current value of `base_url`. + +## `api_factory` + +Returns an API factory object. You probably won't need to call this directly. + + $self->api_factory('Pet'); # returns a {{moduleName}}::PetApi instance + + $self->pet_api; # the same + +# MISSING METHODS + +Most of the methods on the API are delegated to individual endpoint API objects +(e.g. Pet API, Store API, User API etc). Where different endpoint APIs use the +same method name (e.g. `new()`), these methods can't be delegated. So you need +to call `$api->pet_api->new()`. + +In principle, every API is susceptible to the presence of a few, random, undelegatable +method names. In practice, because of the way method names are constructed, it's +unlikely in general that any methods will be undelegatable, except for: + + new() + class_documentation() + method_documentation() + +To call these methods, you need to get a handle on the relevant object, either +by calling `$api->foo_api` or by retrieving an object, e.g. +`$api->get_pet_by_id(pet_id => $pet_id)`. They are class methods, so +you could also call them on class names. + +# BUILDING YOUR LIBRARY + +See the homepage `https://github.com/swagger-api/swagger-codegen` for full details. +But briefly, clone the git repository, build the codegen codebase, set up your build +config file, then run the API build script. You will need git, Java 7 or 8 and Apache +maven 3.0.3 or better already installed. + +The config file should specify the project name for the generated library: + + {"moduleName":"WWW::MyProjectName"} + +Your library files will be built under `WWW::MyProjectName`. + + $ git clone https://github.com/swagger-api/swagger-codegen.git + $ cd swagger-codegen + $ mvn package + $ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ + -i [URL or file path to JSON swagger API spec] \ + -l perl \ + -c /path/to/config/file.json \ + -o /path/to/output/folder + +Bang, all done. Run the `autodoc` script in the `bin` directory to see the API +you just built. + +# AUTOMATIC DOCUMENTATION + +You can print out a summary of the generated API by running the included +`autodoc` script in the `bin` directory of your generated library. A few +output formats are supported: + + Usage: autodoc [OPTION] + + -w wide format (default) + -n narrow format + -p POD format + -H HTML format + -m Markdown format + -h print this help message + -c your application class + + +The `-c` option allows you to load and inspect your own application. A dummy +namespace is used if you don't supply your own class. + +# DOCUMENTATION FROM THE OpenAPI Spec + +Additional documentation for each class and method may be provided by the Swagger +spec. If so, this is available via the `class_documentation()` and +`method_documentation()` methods on each generated object class, and the +`method_documentation()` method on the endpoint API classes: + + my $cmdoc = $api->pet_api->method_documentation->{$method_name}; + + my $odoc = $api->get_pet_by_id->(pet_id => $pet_id)->class_documentation; + my $omdoc = $api->get_pet_by_id->(pet_id => $pet_id)->method_documentation->{method_name}; + + +Each of these calls returns a hashref with various useful pieces of information. + +# LOAD THE MODULES + +To load the API packages: +```perl +{{#apiInfo}}{{#apis}}use {{moduleName}}::{{classname}}; +{{/apis}}{{/apiInfo}} +``` + +To load the models: +```perl +{{#models}}{{#model}}use {{moduleName}}::Object::{{classname}}; +{{/model}}{{/models}} +```` + +# GETTING STARTED +Put the Perl SDK under the 'lib' folder in your project directory, then run the following +```perl +#!/usr/bin/perl +use lib 'lib'; +use strict; +use warnings; +# load the API package +{{#apiInfo}}{{#apis}}use {{moduleName}}::{{classname}}; +{{/apis}}{{/apiInfo}} +# load the models +{{#models}}{{#model}}use {{moduleName}}::Object::{{classname}}; +{{/model}}{{/models}} +# for displaying the API response data +use Data::Dumper; +use {{{moduleName}}}::Configuration; +use {{moduleName}}::{{classname}}; +{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}} +# Configure HTTP basic authorization: {{{name}}} +${{{moduleName}}}::Configuration::username = 'YOUR_USERNAME'; +${{{moduleName}}}::Configuration::password = 'YOUR_PASSWORD';{{/isBasic}}{{#isApiKey}} +# Configure API key authorization: {{{name}}} +${{{moduleName}}}::Configuration::api_key->{'{{{keyParamName}}}'} = 'YOUR_API_KEY'; +# uncomment below to setup prefix (e.g. Bearer) for API key, if needed +#${{{moduleName}}}::Configuration::api_key_prefix->{'{{{keyParamName}}}'} = 'Bearer';{{/isApiKey}}{{#isOAuth}} +# Configure OAuth2 access token for authorization: {{{name}}} +${{{moduleName}}}::Configuration::access_token = 'YOUR_ACCESS_TOKEN';{{/isOAuth}}{{/authMethods}} +{{/hasAuthMethods}} + +my $api_instance = {{moduleName}}::{{classname}}->new(); +{{#allParams}}my ${{paramName}} = {{#isListContainer}}[{{/isListContainer}}{{#isBodyParam}}{{{moduleName}}}::Object::{{dataType}}->new(){{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isListContainer}}]{{/isListContainer}}; # {{{dataType}}} | {{{description}}} +{{/allParams}} + +eval { + {{#returnType}}my $result = {{/returnType}}$api_instance->{{{operationId}}}({{#allParams}}{{paramName}} => ${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}} + print Dumper($result);{{/returnType}} +}; +if ($@) { + warn "Exception when calling {{classname}}->{{operationId}}: $@\n"; +} +{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} +``` + +# DOCUMENTATION FOR API ENDPOINTS + +All URIs are relative to *{{basePath}}* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{nickname}}**]({{apiDocPath}}{{classname}}.md#{{nickname}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} + +# DOCUMENTATION FOR MODELS +{{#models}}{{#model}} - [{{moduleName}}::Object::{{classname}}]({{modelDocPath}}{{classname}}.md) +{{/model}}{{/models}} + +# DOCUMENTATION FOR AUTHORIZATION +{{^authMethods}} All endpoints do not require authorization. +{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}} +{{#authMethods}}## {{{name}}} + +{{#isApiKey}}- **Type**: API key +- **API key parameter name**: {{{keyParamName}}} +- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} +{{/isApiKey}} +{{#isBasic}}- **Type**: HTTP basic authentication +{{/isBasic}} +{{#isOAuth}}- **Type**: OAuth +- **Flow**: {{{flow}}} +- **Authorization URL**: {{{authorizationUrl}}} +- **Scopes**: {{^scopes}}N/A{{/scopes}} +{{#scopes}} - **{{{scope}}}**: {{{description}}} +{{/scopes}} +{{/isOAuth}} + +{{/authMethods}} + + diff --git a/modules/swagger-codegen/src/main/resources/dart/api_doc.mustache b/modules/swagger-codegen/src/main/resources/dart/api_doc.mustache new file mode 100644 index 00000000000..ed12126515f --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/dart/api_doc.mustache @@ -0,0 +1,85 @@ +# {{moduleName}}::{{classname}}{{#description}} +{{description}}{{/description}} + +## Load the API package +```perl +use {{moduleName}}::Object::{{classname}}; +``` + +All URIs are relative to *{{basePath}}* + +Method | HTTP request | Description +------------- | ------------- | ------------- +{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}} + +{{#operations}} +{{#operation}} +# **{{{operationId}}}** +> {{#returnType}}{{{returnType}}} {{/returnType}}{{{operationId}}}({{#allParams}}{{paramName}} => ${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) + +{{{summary}}}{{#notes}} + +{{{notes}}}{{/notes}} + +### Example +```dart +import '{{{moduleName}}}': +import '{{{moduleName}}}'; +{{#hasAuthMethods}} +{{#authMethods}} +{{#isBasic}} +// Configure HTTP basic authorization: {{{name}}} +//{{{moduleName}}}::Configuration::username = 'YOUR_USERNAME'; +//{{{moduleName}}}::Configuration::password = 'YOUR_PASSWORD'; +{{/isBasic}} +{{#isApiKey}} +// Configure API key authorization: {{{name}}} +//{{{moduleName}}}::Configuration::api_key->{'{{{keyParamName}}}'} = 'YOUR_API_KEY'; +// uncomment below to setup prefix (e.g. Bearer) for API key, if needed +//${{{moduleName}}}::Configuration::api_key_prefix->{'{{{keyParamName}}}'} = "Bearer";{{/isApiKey}}{{#isOAuth}} +// Configure OAuth2 access token for authorization: {{{name}}} +${{{moduleName}}}::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; +{{/isOAuth}} +{{/authMethods}} +{{/hasAuthMethods}} + +var api_instance = {{moduleName}}::{{classname}}->new(); +{{#allParams}} +var {{paramName}} = {{#isListContainer}}[{{/isListContainer}}{{#isBodyParam}}new {{{moduleName}}}:{{dataType}}(){{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isListContainer}}]{{/isListContainer}}; # {{{dataType}}} | {{{description}}} +{{/allParams}} + +try { + {{#returnType}}var result = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + {{#returnType}} + print(result); + {{/returnType}} +} catch (e) { + print("Exception when calling {{classname}}->{{operationId}}: $e\n"); +} +``` + +### Parameters +{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} +Name | Type | Description | Notes +------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} +{{#allParams}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}} +{{/allParams}} + +### Return type + +{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void (empty response body){{/returnType}} + +### Authorization + +{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}} + +### HTTP request headers + + - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} + - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}} + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +{{/operation}} +{{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/dart/object_doc.mustache b/modules/swagger-codegen/src/main/resources/dart/object_doc.mustache new file mode 100644 index 00000000000..b76874f9050 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/dart/object_doc.mustache @@ -0,0 +1,16 @@ +{{#models}}{{#model}}# {{moduleName}}::Object::{{classname}} + +## Load the model package +```perl +use {{moduleName}}::Object::{{classname}}; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{datatype}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{datatype}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}} +{{/vars}} + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + +{{/model}}{{/models}} diff --git a/samples/client/petstore/dart/swagger/README.md b/samples/client/petstore/dart/swagger/README.md new file mode 100644 index 00000000000..9c23bdd8dcb --- /dev/null +++ b/samples/client/petstore/dart/swagger/README.md @@ -0,0 +1,338 @@ +# NAME + +::Role - a Moose role for the Swagger Petstore + +This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + +# VERSION + +Automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: + +- API version: 1.0.0 +- Package version: +- Build date: 2016-11-30T15:51:43.881+08:00 +- Build package: class io.swagger.codegen.languages.DartClientCodegen + +## A note on Moose + +This role is the only component of the library that uses Moose. See +::ApiFactory for non-Moosey usage. + +# SYNOPSIS + +The Perl Swagger Codegen project builds a library of Perl modules to interact with +a web service defined by a OpenAPI Specification. See below for how to build the +library. + +This module provides an interface to the generated library. All the classes, +objects, and methods (well, not quite \*all\*, see below) are flattened into this +role. + + package MyApp; + use Moose; + with '::Role'; + + package main; + + my $api = MyApp->new({ tokens => $tokens }); + + my $pet = $api->get_pet_by_id(pet_id => $pet_id); + + +## Structure of the library + +The library consists of a set of API classes, one for each endpoint. These APIs +implement the method calls available on each endpoint. + +Additionally, there is a set of "object" classes, which represent the objects +returned by and sent to the methods on the endpoints. + +An API factory class is provided, which builds instances of each endpoint API. + +This Moose role flattens all the methods from the endpoint APIs onto the consuming +class. It also provides methods to retrieve the endpoint API objects, and the API +factory object, should you need it. + +For documentation of all these methods, see AUTOMATIC DOCUMENTATION below. + +## Configuring authentication + +In the normal case, the OpenAPI Spec will describe what parameters are +required and where to put them. You just need to supply the tokens. + + my $tokens = { + # basic + username => $username, + password => $password, + + # oauth + access_token => $oauth_token, + + # keys + $some_key => { token => $token, + prefix => $prefix, + in => $in, # 'head||query', + }, + + $another => { token => $token, + prefix => $prefix, + in => $in, # 'head||query', + }, + ..., + + }; + + my $api = MyApp->new({ tokens => $tokens }); + +Note these are all optional, as are `prefix` and `in`, and depend on the API +you are accessing. Usually `prefix` and `in` will be determined by the code generator from +the spec and you will not need to set them at run time. If not, `in` will +default to 'head' and `prefix` to the empty string. + +The tokens will be placed in the `::Configuration` namespace +as follows, but you don't need to know about this. + +- `$::Configuration::username` + + String. The username for basic auth. + +- `$::Configuration::password` + + String. The password for basic auth. + +- `$::Configuration::api_key` + + Hashref. Keyed on the name of each key (there can be multiple tokens). + + $::Configuration::api_key = { + secretKey => 'aaaabbbbccccdddd', + anotherKey => '1111222233334444', + }; + +- `$::Configuration::api_key_prefix` + + Hashref. Keyed on the name of each key (there can be multiple tokens). Note not + all api keys require a prefix. + + $::Configuration::api_key_prefix = { + secretKey => 'string', + anotherKey => 'same or some other string', + }; + +- `$::Configuration::access_token` + + String. The OAuth access token. + +# METHODS + +## `base_url` + +The generated code has the `base_url` already set as a default value. This method +returns (and optionally sets, but only if the API client has not been +created yet) the current value of `base_url`. + +## `api_factory` + +Returns an API factory object. You probably won't need to call this directly. + + $self->api_factory('Pet'); # returns a ::PetApi instance + + $self->pet_api; # the same + +# MISSING METHODS + +Most of the methods on the API are delegated to individual endpoint API objects +(e.g. Pet API, Store API, User API etc). Where different endpoint APIs use the +same method name (e.g. `new()`), these methods can't be delegated. So you need +to call `$api->pet_api->new()`. + +In principle, every API is susceptible to the presence of a few, random, undelegatable +method names. In practice, because of the way method names are constructed, it's +unlikely in general that any methods will be undelegatable, except for: + + new() + class_documentation() + method_documentation() + +To call these methods, you need to get a handle on the relevant object, either +by calling `$api->foo_api` or by retrieving an object, e.g. +`$api->get_pet_by_id(pet_id => $pet_id)`. They are class methods, so +you could also call them on class names. + +# BUILDING YOUR LIBRARY + +See the homepage `https://github.com/swagger-api/swagger-codegen` for full details. +But briefly, clone the git repository, build the codegen codebase, set up your build +config file, then run the API build script. You will need git, Java 7 or 8 and Apache +maven 3.0.3 or better already installed. + +The config file should specify the project name for the generated library: + + {"moduleName":"WWW::MyProjectName"} + +Your library files will be built under `WWW::MyProjectName`. + + $ git clone https://github.com/swagger-api/swagger-codegen.git + $ cd swagger-codegen + $ mvn package + $ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ + -i [URL or file path to JSON swagger API spec] \ + -l perl \ + -c /path/to/config/file.json \ + -o /path/to/output/folder + +Bang, all done. Run the `autodoc` script in the `bin` directory to see the API +you just built. + +# AUTOMATIC DOCUMENTATION + +You can print out a summary of the generated API by running the included +`autodoc` script in the `bin` directory of your generated library. A few +output formats are supported: + + Usage: autodoc [OPTION] + + -w wide format (default) + -n narrow format + -p POD format + -H HTML format + -m Markdown format + -h print this help message + -c your application class + + +The `-c` option allows you to load and inspect your own application. A dummy +namespace is used if you don't supply your own class. + +# DOCUMENTATION FROM THE OpenAPI Spec + +Additional documentation for each class and method may be provided by the Swagger +spec. If so, this is available via the `class_documentation()` and +`method_documentation()` methods on each generated object class, and the +`method_documentation()` method on the endpoint API classes: + + my $cmdoc = $api->pet_api->method_documentation->{$method_name}; + + my $odoc = $api->get_pet_by_id->(pet_id => $pet_id)->class_documentation; + my $omdoc = $api->get_pet_by_id->(pet_id => $pet_id)->method_documentation->{method_name}; + + +Each of these calls returns a hashref with various useful pieces of information. + +# LOAD THE MODULES + +To load the API packages: +```perl +use ::PetApi; +use ::StoreApi; +use ::UserApi; + +``` + +To load the models: +```perl +use ::Object::ApiResponse; +use ::Object::Category; +use ::Object::Order; +use ::Object::Pet; +use ::Object::Tag; +use ::Object::User; + +```` + +# GETTING STARTED +Put the Perl SDK under the 'lib' folder in your project directory, then run the following +```perl +#!/usr/bin/perl +use lib 'lib'; +use strict; +use warnings; +# load the API package +use ::PetApi; +use ::StoreApi; +use ::UserApi; + +# load the models +use ::Object::ApiResponse; +use ::Object::Category; +use ::Object::Order; +use ::Object::Pet; +use ::Object::Tag; +use ::Object::User; + +# for displaying the API response data +use Data::Dumper; +use ::Configuration; +use ::; + +# Configure OAuth2 access token for authorization: petstore_auth +$::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; + +my $api_instance = ::PetApi->new(); +my $body = ::Object::Pet->new(); # Pet | Pet object that needs to be added to the store + +eval { + $api_instance->addPet(body => $body); +}; +if ($@) { + warn "Exception when calling PetApi->addPet: $@\n"; +} + +``` + +# DOCUMENTATION FOR API ENDPOINTS + +All URIs are relative to *http://petstore.swagger.io/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*PetApi* | [**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store +*PetApi* | [**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet +*PetApi* | [**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data +*PetApi* | [**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image +*StoreApi* | [**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*StoreApi* | [**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID +*StoreApi* | [**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet +*UserApi* | [**createUser**](UserApi.md#createUser) | **POST** /user | Create user +*UserApi* | [**createUsersWithArrayInput**](UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**createUsersWithListInput**](UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**deleteUser**](UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user +*UserApi* | [**getUserByName**](UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name +*UserApi* | [**loginUser**](UserApi.md#loginUser) | **GET** /user/login | Logs user into the system +*UserApi* | [**logoutUser**](UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**updateUser**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user + + +# DOCUMENTATION FOR MODELS + - [::Object::ApiResponse](ApiResponse.md) + - [::Object::Category](Category.md) + - [::Object::Order](Order.md) + - [::Object::Pet](Pet.md) + - [::Object::Tag](Tag.md) + - [::Object::User](User.md) + + +# DOCUMENTATION FOR AUTHORIZATION + +## api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + +## petstore_auth + +- **Type**: OAuth +- **Flow**: implicit +- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - **write:pets**: modify pets in your account + - **read:pets**: read your pets + + + diff --git a/samples/client/petstore/dart/swagger/docs/ApiResponse.md b/samples/client/petstore/dart/swagger/docs/ApiResponse.md new file mode 100644 index 00000000000..03d4985e53e --- /dev/null +++ b/samples/client/petstore/dart/swagger/docs/ApiResponse.md @@ -0,0 +1,17 @@ +# ::Object::ApiResponse + +## Load the model package +```perl +use ::Object::ApiResponse; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **int** | | [optional] [default to null] +**type** | **String** | | [optional] [default to null] +**message** | **String** | | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/dart/swagger/docs/Category.md b/samples/client/petstore/dart/swagger/docs/Category.md new file mode 100644 index 00000000000..db3378bf8ec --- /dev/null +++ b/samples/client/petstore/dart/swagger/docs/Category.md @@ -0,0 +1,16 @@ +# ::Object::Category + +## Load the model package +```perl +use ::Object::Category; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] [default to null] +**name** | **String** | | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/dart/swagger/docs/Order.md b/samples/client/petstore/dart/swagger/docs/Order.md new file mode 100644 index 00000000000..c575d31ba5a --- /dev/null +++ b/samples/client/petstore/dart/swagger/docs/Order.md @@ -0,0 +1,20 @@ +# ::Object::Order + +## Load the model package +```perl +use ::Object::Order; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] [default to null] +**petId** | **int** | | [optional] [default to null] +**quantity** | **int** | | [optional] [default to null] +**shipDate** | [**DateTime**](DateTime.md) | | [optional] [default to null] +**status** | **String** | Order Status | [optional] [default to null] +**complete** | **bool** | | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/dart/swagger/docs/Pet.md b/samples/client/petstore/dart/swagger/docs/Pet.md new file mode 100644 index 00000000000..db26f08175a --- /dev/null +++ b/samples/client/petstore/dart/swagger/docs/Pet.md @@ -0,0 +1,20 @@ +# ::Object::Pet + +## Load the model package +```perl +use ::Object::Pet; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] [default to null] +**category** | [**Category**](Category.md) | | [optional] [default to null] +**name** | **String** | | [default to null] +**photoUrls** | **List<String>** | | [default to []] +**tags** | [**List<Tag>**](Tag.md) | | [optional] [default to []] +**status** | **String** | pet status in the store | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/dart/swagger/docs/PetApi.md b/samples/client/petstore/dart/swagger/docs/PetApi.md new file mode 100644 index 00000000000..75c48f8c05e --- /dev/null +++ b/samples/client/petstore/dart/swagger/docs/PetApi.md @@ -0,0 +1,403 @@ +# ::PetApi + +## Load the API package +```perl +use ::Object::PetApi; +``` + +All URIs are relative to ** + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store +[**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet +[**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status +[**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags +[**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID +[**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet +[**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data +[**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image + + +# **addPet** +> addPet(body => $body) + +Add a new pet to the store + + + +### Example +```dart +import '': +import ''; + +// Configure OAuth2 access token for authorization: petstore_auth +$::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; + +var api_instance = ::PetApi->new(); +var body = new :Pet(); # Pet | Pet object that needs to be added to the store + +try { + api_instance.addPet(body); +} catch (e) { + print("Exception when calling PetApi->addPet: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **deletePet** +> deletePet(petId => $petId, apiKey => $apiKey) + +Deletes a pet + + + +### Example +```dart +import '': +import ''; + +// Configure OAuth2 access token for authorization: petstore_auth +$::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; + +var api_instance = ::PetApi->new(); +var petId = 789; # int | Pet id to delete +var apiKey = apiKey_example; # String | + +try { + api_instance.deletePet(petId, apiKey); +} catch (e) { + print("Exception when calling PetApi->deletePet: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **int**| Pet id to delete | + **apiKey** | **String**| | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **findPetsByStatus** +> List findPetsByStatus(status => $status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example +```dart +import '': +import ''; + +// Configure OAuth2 access token for authorization: petstore_auth +$::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; + +var api_instance = ::PetApi->new(); +var status = []; # List | Status values that need to be considered for filter + +try { + var result = api_instance.findPetsByStatus(status); + print(result); +} catch (e) { + print("Exception when calling PetApi->findPetsByStatus: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | [**List<String>**](String.md)| Status values that need to be considered for filter | + +### Return type + +[**List**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **findPetsByTags** +> List findPetsByTags(tags => $tags) + +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Example +```dart +import '': +import ''; + +// Configure OAuth2 access token for authorization: petstore_auth +$::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; + +var api_instance = ::PetApi->new(); +var tags = []; # List | Tags to filter by + +try { + var result = api_instance.findPetsByTags(tags); + print(result); +} catch (e) { + print("Exception when calling PetApi->findPetsByTags: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **tags** | [**List<String>**](String.md)| Tags to filter by | + +### Return type + +[**List**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **getPetById** +> Pet getPetById(petId => $petId) + +Find pet by ID + +Returns a single pet + +### Example +```dart +import '': +import ''; +// Configure API key authorization: api_key +//::Configuration::api_key->{'api_key'} = 'YOUR_API_KEY'; +// uncomment below to setup prefix (e.g. Bearer) for API key, if needed +//$::Configuration::api_key_prefix->{'api_key'} = "Bearer"; +var api_instance = ::PetApi->new(); +var petId = 789; # int | ID of pet to return + +try { + var result = api_instance.getPetById(petId); + print(result); +} catch (e) { + print("Exception when calling PetApi->getPetById: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **int**| ID of pet to return | + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **updatePet** +> updatePet(body => $body) + +Update an existing pet + + + +### Example +```dart +import '': +import ''; + +// Configure OAuth2 access token for authorization: petstore_auth +$::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; + +var api_instance = ::PetApi->new(); +var body = new :Pet(); # Pet | Pet object that needs to be added to the store + +try { + api_instance.updatePet(body); +} catch (e) { + print("Exception when calling PetApi->updatePet: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **updatePetWithForm** +> updatePetWithForm(petId => $petId, name => $name, status => $status) + +Updates a pet in the store with form data + + + +### Example +```dart +import '': +import ''; + +// Configure OAuth2 access token for authorization: petstore_auth +$::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; + +var api_instance = ::PetApi->new(); +var petId = 789; # int | ID of pet that needs to be updated +var name = name_example; # String | Updated name of the pet +var status = status_example; # String | Updated status of the pet + +try { + api_instance.updatePetWithForm(petId, name, status); +} catch (e) { + print("Exception when calling PetApi->updatePetWithForm: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **int**| ID of pet that needs to be updated | + **name** | **String**| Updated name of the pet | [optional] + **status** | **String**| Updated status of the pet | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **uploadFile** +> ApiResponse uploadFile(petId => $petId, additionalMetadata => $additionalMetadata, file => $file) + +uploads an image + + + +### Example +```dart +import '': +import ''; + +// Configure OAuth2 access token for authorization: petstore_auth +$::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; + +var api_instance = ::PetApi->new(); +var petId = 789; # int | ID of pet to update +var additionalMetadata = additionalMetadata_example; # String | Additional data to pass to server +var file = /path/to/file.txt; # MultipartFile | file to upload + +try { + var result = api_instance.uploadFile(petId, additionalMetadata, file); + print(result); +} catch (e) { + print("Exception when calling PetApi->uploadFile: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **int**| ID of pet to update | + **additionalMetadata** | **String**| Additional data to pass to server | [optional] + **file** | **MultipartFile**| file to upload | [optional] + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/dart/swagger/docs/StoreApi.md b/samples/client/petstore/dart/swagger/docs/StoreApi.md new file mode 100644 index 00000000000..a85114e06fd --- /dev/null +++ b/samples/client/petstore/dart/swagger/docs/StoreApi.md @@ -0,0 +1,191 @@ +# ::StoreApi + +## Load the API package +```perl +use ::Object::StoreApi; +``` + +All URIs are relative to ** + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +[**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status +[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID +[**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet + + +# **deleteOrder** +> deleteOrder(orderId => $orderId) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Example +```dart +import '': +import ''; + +var api_instance = ::StoreApi->new(); +var orderId = orderId_example; # String | ID of the order that needs to be deleted + +try { + api_instance.deleteOrder(orderId); +} catch (e) { + print("Exception when calling StoreApi->deleteOrder: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orderId** | **String**| ID of the order that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **getInventory** +> Map getInventory() + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example +```dart +import '': +import ''; +// Configure API key authorization: api_key +//::Configuration::api_key->{'api_key'} = 'YOUR_API_KEY'; +// uncomment below to setup prefix (e.g. Bearer) for API key, if needed +//$::Configuration::api_key_prefix->{'api_key'} = "Bearer"; +var api_instance = ::StoreApi->new(); + +try { + var result = api_instance.getInventory(); + print(result); +} catch (e) { + print("Exception when calling StoreApi->getInventory: $e\n"); +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**Map**](Map.md) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **getOrderById** +> Order getOrderById(orderId => $orderId) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + +### Example +```dart +import '': +import ''; + +var api_instance = ::StoreApi->new(); +var orderId = 789; # int | ID of pet that needs to be fetched + +try { + var result = api_instance.getOrderById(orderId); + print(result); +} catch (e) { + print("Exception when calling StoreApi->getOrderById: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orderId** | **int**| ID of pet that needs to be fetched | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **placeOrder** +> Order placeOrder(body => $body) + +Place an order for a pet + + + +### Example +```dart +import '': +import ''; + +var api_instance = ::StoreApi->new(); +var body = new :Order(); # Order | order placed for purchasing the pet + +try { + var result = api_instance.placeOrder(body); + print(result); +} catch (e) { + print("Exception when calling StoreApi->placeOrder: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Order**](Order.md)| order placed for purchasing the pet | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/dart/swagger/docs/Tag.md b/samples/client/petstore/dart/swagger/docs/Tag.md new file mode 100644 index 00000000000..7d3455521bb --- /dev/null +++ b/samples/client/petstore/dart/swagger/docs/Tag.md @@ -0,0 +1,16 @@ +# ::Object::Tag + +## Load the model package +```perl +use ::Object::Tag; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] [default to null] +**name** | **String** | | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/dart/swagger/docs/User.md b/samples/client/petstore/dart/swagger/docs/User.md new file mode 100644 index 00000000000..9498e377f5f --- /dev/null +++ b/samples/client/petstore/dart/swagger/docs/User.md @@ -0,0 +1,22 @@ +# ::Object::User + +## Load the model package +```perl +use ::Object::User; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] [default to null] +**username** | **String** | | [optional] [default to null] +**firstName** | **String** | | [optional] [default to null] +**lastName** | **String** | | [optional] [default to null] +**email** | **String** | | [optional] [default to null] +**password** | **String** | | [optional] [default to null] +**phone** | **String** | | [optional] [default to null] +**userStatus** | **int** | User Status | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/dart/swagger/docs/UserApi.md b/samples/client/petstore/dart/swagger/docs/UserApi.md new file mode 100644 index 00000000000..02d3eb74088 --- /dev/null +++ b/samples/client/petstore/dart/swagger/docs/UserApi.md @@ -0,0 +1,367 @@ +# ::UserApi + +## Load the API package +```perl +use ::Object::UserApi; +``` + +All URIs are relative to ** + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**createUser**](UserApi.md#createUser) | **POST** /user | Create user +[**createUsersWithArrayInput**](UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array +[**createUsersWithListInput**](UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array +[**deleteUser**](UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user +[**getUserByName**](UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name +[**loginUser**](UserApi.md#loginUser) | **GET** /user/login | Logs user into the system +[**logoutUser**](UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session +[**updateUser**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user + + +# **createUser** +> createUser(body => $body) + +Create user + +This can only be done by the logged in user. + +### Example +```dart +import '': +import ''; + +var api_instance = ::UserApi->new(); +var body = new :User(); # User | Created user object + +try { + api_instance.createUser(body); +} catch (e) { + print("Exception when calling UserApi->createUser: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**User**](User.md)| Created user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **createUsersWithArrayInput** +> createUsersWithArrayInput(body => $body) + +Creates list of users with given input array + + + +### Example +```dart +import '': +import ''; + +var api_instance = ::UserApi->new(); +var body = [new :List<User>()]; # List | List of user object + +try { + api_instance.createUsersWithArrayInput(body); +} catch (e) { + print("Exception when calling UserApi->createUsersWithArrayInput: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**List<User>**](User.md)| List of user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **createUsersWithListInput** +> createUsersWithListInput(body => $body) + +Creates list of users with given input array + + + +### Example +```dart +import '': +import ''; + +var api_instance = ::UserApi->new(); +var body = [new :List<User>()]; # List | List of user object + +try { + api_instance.createUsersWithListInput(body); +} catch (e) { + print("Exception when calling UserApi->createUsersWithListInput: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**List<User>**](User.md)| List of user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **deleteUser** +> deleteUser(username => $username) + +Delete user + +This can only be done by the logged in user. + +### Example +```dart +import '': +import ''; + +var api_instance = ::UserApi->new(); +var username = username_example; # String | The name that needs to be deleted + +try { + api_instance.deleteUser(username); +} catch (e) { + print("Exception when calling UserApi->deleteUser: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The name that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **getUserByName** +> User getUserByName(username => $username) + +Get user by user name + + + +### Example +```dart +import '': +import ''; + +var api_instance = ::UserApi->new(); +var username = username_example; # String | The name that needs to be fetched. Use user1 for testing. + +try { + var result = api_instance.getUserByName(username); + print(result); +} catch (e) { + print("Exception when calling UserApi->getUserByName: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The name that needs to be fetched. Use user1 for testing. | + +### Return type + +[**User**](User.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **loginUser** +> String loginUser(username => $username, password => $password) + +Logs user into the system + + + +### Example +```dart +import '': +import ''; + +var api_instance = ::UserApi->new(); +var username = username_example; # String | The user name for login +var password = password_example; # String | The password for login in clear text + +try { + var result = api_instance.loginUser(username, password); + print(result); +} catch (e) { + print("Exception when calling UserApi->loginUser: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The user name for login | + **password** | **String**| The password for login in clear text | + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **logoutUser** +> logoutUser() + +Logs out current logged in user session + + + +### Example +```dart +import '': +import ''; + +var api_instance = ::UserApi->new(); + +try { + api_instance.logoutUser(); +} catch (e) { + print("Exception when calling UserApi->logoutUser: $e\n"); +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **updateUser** +> updateUser(username => $username, body => $body) + +Updated user + +This can only be done by the logged in user. + +### Example +```dart +import '': +import ''; + +var api_instance = ::UserApi->new(); +var username = username_example; # String | name that need to be deleted +var body = new :User(); # User | Updated user object + +try { + api_instance.updateUser(username, body); +} catch (e) { + print("Exception when calling UserApi->updateUser: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| name that need to be deleted | + **body** | [**User**](User.md)| Updated user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + From ad5d2ea4dbadf12155a714d29385745a7d35090e Mon Sep 17 00:00:00 2001 From: wing328 Date: Wed, 30 Nov 2016 16:09:42 +0800 Subject: [PATCH 2/8] update doc for dart --- .../src/main/resources/dart/api_doc.mustache | 24 +++--- .../client/petstore/dart/swagger/README.md | 2 +- .../petstore/dart/swagger/docs/PetApi.md | 78 +++++++++---------- .../petstore/dart/swagger/docs/StoreApi.md | 31 ++++---- .../petstore/dart/swagger/docs/UserApi.md | 50 ++++++------ 5 files changed, 91 insertions(+), 94 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/dart/api_doc.mustache b/modules/swagger-codegen/src/main/resources/dart/api_doc.mustache index ed12126515f..c874634e42e 100644 --- a/modules/swagger-codegen/src/main/resources/dart/api_doc.mustache +++ b/modules/swagger-codegen/src/main/resources/dart/api_doc.mustache @@ -1,9 +1,9 @@ -# {{moduleName}}::{{classname}}{{#description}} +# {{apiPackage}}::{{classname}}{{#description}} {{description}}{{/description}} ## Load the API package -```perl -use {{moduleName}}::Object::{{classname}}; +```dart +import 'swagger.api.{{classname}}'; ``` All URIs are relative to *{{basePath}}* @@ -16,7 +16,7 @@ Method | HTTP request | Description {{#operations}} {{#operation}} # **{{{operationId}}}** -> {{#returnType}}{{{returnType}}} {{/returnType}}{{{operationId}}}({{#allParams}}{{paramName}} => ${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) +> {{#returnType}}{{{returnType}}} {{/returnType}}{{{operationId}}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {{{summary}}}{{#notes}} @@ -24,22 +24,24 @@ Method | HTTP request | Description ### Example ```dart -import '{{{moduleName}}}': -import '{{{moduleName}}}'; +import 'swagger.api.{{classname}}': +import 'swagger.model.{{classname}}': {{#hasAuthMethods}} {{#authMethods}} {{#isBasic}} // Configure HTTP basic authorization: {{{name}}} -//{{{moduleName}}}::Configuration::username = 'YOUR_USERNAME'; -//{{{moduleName}}}::Configuration::password = 'YOUR_PASSWORD'; +//swagger.api.Configuration.username = 'YOUR_USERNAME'; +//swagger.api.Configuration.password = 'YOUR_PASSWORD'; {{/isBasic}} {{#isApiKey}} // Configure API key authorization: {{{name}}} -//{{{moduleName}}}::Configuration::api_key->{'{{{keyParamName}}}'} = 'YOUR_API_KEY'; +//swagger.api.Configuration.apiKey{'{{{keyParamName}}}'} = 'YOUR_API_KEY'; // uncomment below to setup prefix (e.g. Bearer) for API key, if needed -//${{{moduleName}}}::Configuration::api_key_prefix->{'{{{keyParamName}}}'} = "Bearer";{{/isApiKey}}{{#isOAuth}} +//swagger.api.Configuration.apiKeyPrefix{'{{{keyParamName}}}'} = "Bearer"; +{{/isApiKey}} +{{#isOAuth}} // Configure OAuth2 access token for authorization: {{{name}}} -${{{moduleName}}}::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; +swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; {{/isOAuth}} {{/authMethods}} {{/hasAuthMethods}} diff --git a/samples/client/petstore/dart/swagger/README.md b/samples/client/petstore/dart/swagger/README.md index 9c23bdd8dcb..74c090226c6 100644 --- a/samples/client/petstore/dart/swagger/README.md +++ b/samples/client/petstore/dart/swagger/README.md @@ -10,7 +10,7 @@ Automatically generated by the [Swagger Codegen](https://github.com/swagger-api/ - API version: 1.0.0 - Package version: -- Build date: 2016-11-30T15:51:43.881+08:00 +- Build date: 2016-11-30T16:09:18.784+08:00 - Build package: class io.swagger.codegen.languages.DartClientCodegen ## A note on Moose diff --git a/samples/client/petstore/dart/swagger/docs/PetApi.md b/samples/client/petstore/dart/swagger/docs/PetApi.md index 75c48f8c05e..5ac79ace61a 100644 --- a/samples/client/petstore/dart/swagger/docs/PetApi.md +++ b/samples/client/petstore/dart/swagger/docs/PetApi.md @@ -1,8 +1,8 @@ # ::PetApi ## Load the API package -```perl -use ::Object::PetApi; +```dart +import 'swagger.api.PetApi'; ``` All URIs are relative to ** @@ -20,7 +20,7 @@ Method | HTTP request | Description # **addPet** -> addPet(body => $body) +> addPet(body) Add a new pet to the store @@ -28,11 +28,10 @@ Add a new pet to the store ### Example ```dart -import '': -import ''; - +import 'swagger.api.PetApi': +import 'swagger.model.PetApi': // Configure OAuth2 access token for authorization: petstore_auth -$::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; +swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = ::PetApi->new(); var body = new :Pet(); # Pet | Pet object that needs to be added to the store @@ -66,7 +65,7 @@ void (empty response body) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **deletePet** -> deletePet(petId => $petId, apiKey => $apiKey) +> deletePet(petId, apiKey) Deletes a pet @@ -74,11 +73,10 @@ Deletes a pet ### Example ```dart -import '': -import ''; - +import 'swagger.api.PetApi': +import 'swagger.model.PetApi': // Configure OAuth2 access token for authorization: petstore_auth -$::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; +swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = ::PetApi->new(); var petId = 789; # int | Pet id to delete @@ -114,7 +112,7 @@ void (empty response body) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **findPetsByStatus** -> List findPetsByStatus(status => $status) +> List findPetsByStatus(status) Finds Pets by status @@ -122,11 +120,10 @@ Multiple status values can be provided with comma separated strings ### Example ```dart -import '': -import ''; - +import 'swagger.api.PetApi': +import 'swagger.model.PetApi': // Configure OAuth2 access token for authorization: petstore_auth -$::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; +swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = ::PetApi->new(); var status = []; # List | Status values that need to be considered for filter @@ -161,7 +158,7 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **findPetsByTags** -> List findPetsByTags(tags => $tags) +> List findPetsByTags(tags) Finds Pets by tags @@ -169,11 +166,10 @@ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 ### Example ```dart -import '': -import ''; - +import 'swagger.api.PetApi': +import 'swagger.model.PetApi': // Configure OAuth2 access token for authorization: petstore_auth -$::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; +swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = ::PetApi->new(); var tags = []; # List | Tags to filter by @@ -208,7 +204,7 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **getPetById** -> Pet getPetById(petId => $petId) +> Pet getPetById(petId) Find pet by ID @@ -216,12 +212,13 @@ Returns a single pet ### Example ```dart -import '': -import ''; +import 'swagger.api.PetApi': +import 'swagger.model.PetApi': // Configure API key authorization: api_key -//::Configuration::api_key->{'api_key'} = 'YOUR_API_KEY'; +//swagger.api.Configuration.apiKey{'api_key'} = 'YOUR_API_KEY'; // uncomment below to setup prefix (e.g. Bearer) for API key, if needed -//$::Configuration::api_key_prefix->{'api_key'} = "Bearer"; +//swagger.api.Configuration.apiKeyPrefix{'api_key'} = "Bearer"; + var api_instance = ::PetApi->new(); var petId = 789; # int | ID of pet to return @@ -255,7 +252,7 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **updatePet** -> updatePet(body => $body) +> updatePet(body) Update an existing pet @@ -263,11 +260,10 @@ Update an existing pet ### Example ```dart -import '': -import ''; - +import 'swagger.api.PetApi': +import 'swagger.model.PetApi': // Configure OAuth2 access token for authorization: petstore_auth -$::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; +swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = ::PetApi->new(); var body = new :Pet(); # Pet | Pet object that needs to be added to the store @@ -301,7 +297,7 @@ void (empty response body) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **updatePetWithForm** -> updatePetWithForm(petId => $petId, name => $name, status => $status) +> updatePetWithForm(petId, name, status) Updates a pet in the store with form data @@ -309,11 +305,10 @@ Updates a pet in the store with form data ### Example ```dart -import '': -import ''; - +import 'swagger.api.PetApi': +import 'swagger.model.PetApi': // Configure OAuth2 access token for authorization: petstore_auth -$::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; +swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = ::PetApi->new(); var petId = 789; # int | ID of pet that needs to be updated @@ -351,7 +346,7 @@ void (empty response body) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **uploadFile** -> ApiResponse uploadFile(petId => $petId, additionalMetadata => $additionalMetadata, file => $file) +> ApiResponse uploadFile(petId, additionalMetadata, file) uploads an image @@ -359,11 +354,10 @@ uploads an image ### Example ```dart -import '': -import ''; - +import 'swagger.api.PetApi': +import 'swagger.model.PetApi': // Configure OAuth2 access token for authorization: petstore_auth -$::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; +swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = ::PetApi->new(); var petId = 789; # int | ID of pet to update diff --git a/samples/client/petstore/dart/swagger/docs/StoreApi.md b/samples/client/petstore/dart/swagger/docs/StoreApi.md index a85114e06fd..82423191fe2 100644 --- a/samples/client/petstore/dart/swagger/docs/StoreApi.md +++ b/samples/client/petstore/dart/swagger/docs/StoreApi.md @@ -1,8 +1,8 @@ # ::StoreApi ## Load the API package -```perl -use ::Object::StoreApi; +```dart +import 'swagger.api.StoreApi'; ``` All URIs are relative to ** @@ -16,7 +16,7 @@ Method | HTTP request | Description # **deleteOrder** -> deleteOrder(orderId => $orderId) +> deleteOrder(orderId) Delete purchase order by ID @@ -24,8 +24,8 @@ For valid response try integer IDs with value < 1000. Anything above 1000 or non ### Example ```dart -import '': -import ''; +import 'swagger.api.StoreApi': +import 'swagger.model.StoreApi': var api_instance = ::StoreApi->new(); var orderId = orderId_example; # String | ID of the order that needs to be deleted @@ -67,12 +67,13 @@ Returns a map of status codes to quantities ### Example ```dart -import '': -import ''; +import 'swagger.api.StoreApi': +import 'swagger.model.StoreApi': // Configure API key authorization: api_key -//::Configuration::api_key->{'api_key'} = 'YOUR_API_KEY'; +//swagger.api.Configuration.apiKey{'api_key'} = 'YOUR_API_KEY'; // uncomment below to setup prefix (e.g. Bearer) for API key, if needed -//$::Configuration::api_key_prefix->{'api_key'} = "Bearer"; +//swagger.api.Configuration.apiKeyPrefix{'api_key'} = "Bearer"; + var api_instance = ::StoreApi->new(); try { @@ -102,7 +103,7 @@ This endpoint does not need any parameter. [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **getOrderById** -> Order getOrderById(orderId => $orderId) +> Order getOrderById(orderId) Find purchase order by ID @@ -110,8 +111,8 @@ For valid response try integer IDs with value <= 5 or > 10. Other values will ge ### Example ```dart -import '': -import ''; +import 'swagger.api.StoreApi': +import 'swagger.model.StoreApi': var api_instance = ::StoreApi->new(); var orderId = 789; # int | ID of pet that needs to be fetched @@ -146,7 +147,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **placeOrder** -> Order placeOrder(body => $body) +> Order placeOrder(body) Place an order for a pet @@ -154,8 +155,8 @@ Place an order for a pet ### Example ```dart -import '': -import ''; +import 'swagger.api.StoreApi': +import 'swagger.model.StoreApi': var api_instance = ::StoreApi->new(); var body = new :Order(); # Order | order placed for purchasing the pet diff --git a/samples/client/petstore/dart/swagger/docs/UserApi.md b/samples/client/petstore/dart/swagger/docs/UserApi.md index 02d3eb74088..d67a34eb71c 100644 --- a/samples/client/petstore/dart/swagger/docs/UserApi.md +++ b/samples/client/petstore/dart/swagger/docs/UserApi.md @@ -1,8 +1,8 @@ # ::UserApi ## Load the API package -```perl -use ::Object::UserApi; +```dart +import 'swagger.api.UserApi'; ``` All URIs are relative to ** @@ -20,7 +20,7 @@ Method | HTTP request | Description # **createUser** -> createUser(body => $body) +> createUser(body) Create user @@ -28,8 +28,8 @@ This can only be done by the logged in user. ### Example ```dart -import '': -import ''; +import 'swagger.api.UserApi': +import 'swagger.model.UserApi': var api_instance = ::UserApi->new(); var body = new :User(); # User | Created user object @@ -63,7 +63,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **createUsersWithArrayInput** -> createUsersWithArrayInput(body => $body) +> createUsersWithArrayInput(body) Creates list of users with given input array @@ -71,8 +71,8 @@ Creates list of users with given input array ### Example ```dart -import '': -import ''; +import 'swagger.api.UserApi': +import 'swagger.model.UserApi': var api_instance = ::UserApi->new(); var body = [new :List<User>()]; # List | List of user object @@ -106,7 +106,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **createUsersWithListInput** -> createUsersWithListInput(body => $body) +> createUsersWithListInput(body) Creates list of users with given input array @@ -114,8 +114,8 @@ Creates list of users with given input array ### Example ```dart -import '': -import ''; +import 'swagger.api.UserApi': +import 'swagger.model.UserApi': var api_instance = ::UserApi->new(); var body = [new :List<User>()]; # List | List of user object @@ -149,7 +149,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **deleteUser** -> deleteUser(username => $username) +> deleteUser(username) Delete user @@ -157,8 +157,8 @@ This can only be done by the logged in user. ### Example ```dart -import '': -import ''; +import 'swagger.api.UserApi': +import 'swagger.model.UserApi': var api_instance = ::UserApi->new(); var username = username_example; # String | The name that needs to be deleted @@ -192,7 +192,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **getUserByName** -> User getUserByName(username => $username) +> User getUserByName(username) Get user by user name @@ -200,8 +200,8 @@ Get user by user name ### Example ```dart -import '': -import ''; +import 'swagger.api.UserApi': +import 'swagger.model.UserApi': var api_instance = ::UserApi->new(); var username = username_example; # String | The name that needs to be fetched. Use user1 for testing. @@ -236,7 +236,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **loginUser** -> String loginUser(username => $username, password => $password) +> String loginUser(username, password) Logs user into the system @@ -244,8 +244,8 @@ Logs user into the system ### Example ```dart -import '': -import ''; +import 'swagger.api.UserApi': +import 'swagger.model.UserApi': var api_instance = ::UserApi->new(); var username = username_example; # String | The user name for login @@ -290,8 +290,8 @@ Logs out current logged in user session ### Example ```dart -import '': -import ''; +import 'swagger.api.UserApi': +import 'swagger.model.UserApi': var api_instance = ::UserApi->new(); @@ -321,7 +321,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **updateUser** -> updateUser(username => $username, body => $body) +> updateUser(username, body) Updated user @@ -329,8 +329,8 @@ This can only be done by the logged in user. ### Example ```dart -import '': -import ''; +import 'swagger.api.UserApi': +import 'swagger.model.UserApi': var api_instance = ::UserApi->new(); var username = username_example; # String | name that need to be deleted From dd711ec4c904aababcfd52011dccddb0f7c5f198 Mon Sep 17 00:00:00 2001 From: wing328 Date: Wed, 30 Nov 2016 16:16:12 +0800 Subject: [PATCH 3/8] update api and model doc for dart --- .../src/main/resources/dart/api_doc.mustache | 22 +++++++++---------- .../main/resources/dart/object_doc.mustache | 6 ++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/dart/api_doc.mustache b/modules/swagger-codegen/src/main/resources/dart/api_doc.mustache index c874634e42e..4272f3a8099 100644 --- a/modules/swagger-codegen/src/main/resources/dart/api_doc.mustache +++ b/modules/swagger-codegen/src/main/resources/dart/api_doc.mustache @@ -1,9 +1,9 @@ -# {{apiPackage}}::{{classname}}{{#description}} +# {{pubName}}.api.{{classname}}{{#description}} {{description}}{{/description}} ## Load the API package ```dart -import 'swagger.api.{{classname}}'; +import '{{pubName}}.api.{{classname}}'; ``` All URIs are relative to *{{basePath}}* @@ -24,31 +24,31 @@ Method | HTTP request | Description ### Example ```dart -import 'swagger.api.{{classname}}': -import 'swagger.model.{{classname}}': +import '{{pubName}}.api'; +import '{{pubName}}.model'; {{#hasAuthMethods}} {{#authMethods}} {{#isBasic}} // Configure HTTP basic authorization: {{{name}}} -//swagger.api.Configuration.username = 'YOUR_USERNAME'; -//swagger.api.Configuration.password = 'YOUR_PASSWORD'; +//{{pubName}}.api.Configuration.username = 'YOUR_USERNAME'; +//{{pubName}}.api.Configuration.password = 'YOUR_PASSWORD'; {{/isBasic}} {{#isApiKey}} // Configure API key authorization: {{{name}}} -//swagger.api.Configuration.apiKey{'{{{keyParamName}}}'} = 'YOUR_API_KEY'; +//{{pubName}}.api.Configuration.apiKey{'{{{keyParamName}}}'} = 'YOUR_API_KEY'; // uncomment below to setup prefix (e.g. Bearer) for API key, if needed -//swagger.api.Configuration.apiKeyPrefix{'{{{keyParamName}}}'} = "Bearer"; +//{{pubName}}.api.Configuration.apiKeyPrefix{'{{{keyParamName}}}'} = "Bearer"; {{/isApiKey}} {{#isOAuth}} // Configure OAuth2 access token for authorization: {{{name}}} -swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; +//{{pubName}}.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; {{/isOAuth}} {{/authMethods}} {{/hasAuthMethods}} -var api_instance = {{moduleName}}::{{classname}}->new(); +var api_instance = {{pubName}}.api.{{classname}}->new(); {{#allParams}} -var {{paramName}} = {{#isListContainer}}[{{/isListContainer}}{{#isBodyParam}}new {{{moduleName}}}:{{dataType}}(){{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isListContainer}}]{{/isListContainer}}; # {{{dataType}}} | {{{description}}} +var {{paramName}} = {{#isListContainer}}[{{/isListContainer}}{{#isBodyParam}}new {{{pubName}}}:{{dataType}}(){{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isListContainer}}]{{/isListContainer}}; # {{{dataType}}} | {{{description}}} {{/allParams}} try { diff --git a/modules/swagger-codegen/src/main/resources/dart/object_doc.mustache b/modules/swagger-codegen/src/main/resources/dart/object_doc.mustache index b76874f9050..f640a87c360 100644 --- a/modules/swagger-codegen/src/main/resources/dart/object_doc.mustache +++ b/modules/swagger-codegen/src/main/resources/dart/object_doc.mustache @@ -1,8 +1,8 @@ -{{#models}}{{#model}}# {{moduleName}}::Object::{{classname}} +{{#models}}{{#model}}# {{pubName}}.model.{{classname}} ## Load the model package -```perl -use {{moduleName}}::Object::{{classname}}; +```dart +import {{pubName}}.model.{{classname}}; ``` ## Properties From 741091a8bf77e5ff627da5bcbd1b7d7352cd1812 Mon Sep 17 00:00:00 2001 From: wing328 Date: Wed, 30 Nov 2016 16:17:13 +0800 Subject: [PATCH 4/8] update dart petstore sample --- .../client/petstore/dart/swagger/README.md | 2 +- .../petstore/dart/swagger/docs/ApiResponse.md | 6 +- .../petstore/dart/swagger/docs/Category.md | 6 +- .../petstore/dart/swagger/docs/Order.md | 6 +- .../client/petstore/dart/swagger/docs/Pet.md | 6 +- .../petstore/dart/swagger/docs/PetApi.md | 68 +++++++++---------- .../petstore/dart/swagger/docs/StoreApi.md | 28 ++++---- .../client/petstore/dart/swagger/docs/Tag.md | 6 +- .../client/petstore/dart/swagger/docs/User.md | 6 +- .../petstore/dart/swagger/docs/UserApi.md | 58 ++++++++-------- 10 files changed, 96 insertions(+), 96 deletions(-) diff --git a/samples/client/petstore/dart/swagger/README.md b/samples/client/petstore/dart/swagger/README.md index 74c090226c6..ee02068cc08 100644 --- a/samples/client/petstore/dart/swagger/README.md +++ b/samples/client/petstore/dart/swagger/README.md @@ -10,7 +10,7 @@ Automatically generated by the [Swagger Codegen](https://github.com/swagger-api/ - API version: 1.0.0 - Package version: -- Build date: 2016-11-30T16:09:18.784+08:00 +- Build date: 2016-11-30T16:17:11.786+08:00 - Build package: class io.swagger.codegen.languages.DartClientCodegen ## A note on Moose diff --git a/samples/client/petstore/dart/swagger/docs/ApiResponse.md b/samples/client/petstore/dart/swagger/docs/ApiResponse.md index 03d4985e53e..f5b16281f01 100644 --- a/samples/client/petstore/dart/swagger/docs/ApiResponse.md +++ b/samples/client/petstore/dart/swagger/docs/ApiResponse.md @@ -1,8 +1,8 @@ -# ::Object::ApiResponse +# swagger.model.ApiResponse ## Load the model package -```perl -use ::Object::ApiResponse; +```dart +import swagger.model.ApiResponse; ``` ## Properties diff --git a/samples/client/petstore/dart/swagger/docs/Category.md b/samples/client/petstore/dart/swagger/docs/Category.md index db3378bf8ec..ca4dfef1274 100644 --- a/samples/client/petstore/dart/swagger/docs/Category.md +++ b/samples/client/petstore/dart/swagger/docs/Category.md @@ -1,8 +1,8 @@ -# ::Object::Category +# swagger.model.Category ## Load the model package -```perl -use ::Object::Category; +```dart +import swagger.model.Category; ``` ## Properties diff --git a/samples/client/petstore/dart/swagger/docs/Order.md b/samples/client/petstore/dart/swagger/docs/Order.md index c575d31ba5a..5425a272629 100644 --- a/samples/client/petstore/dart/swagger/docs/Order.md +++ b/samples/client/petstore/dart/swagger/docs/Order.md @@ -1,8 +1,8 @@ -# ::Object::Order +# swagger.model.Order ## Load the model package -```perl -use ::Object::Order; +```dart +import swagger.model.Order; ``` ## Properties diff --git a/samples/client/petstore/dart/swagger/docs/Pet.md b/samples/client/petstore/dart/swagger/docs/Pet.md index db26f08175a..6e3e6c156ff 100644 --- a/samples/client/petstore/dart/swagger/docs/Pet.md +++ b/samples/client/petstore/dart/swagger/docs/Pet.md @@ -1,8 +1,8 @@ -# ::Object::Pet +# swagger.model.Pet ## Load the model package -```perl -use ::Object::Pet; +```dart +import swagger.model.Pet; ``` ## Properties diff --git a/samples/client/petstore/dart/swagger/docs/PetApi.md b/samples/client/petstore/dart/swagger/docs/PetApi.md index 5ac79ace61a..e7e2cf7ec8e 100644 --- a/samples/client/petstore/dart/swagger/docs/PetApi.md +++ b/samples/client/petstore/dart/swagger/docs/PetApi.md @@ -1,4 +1,4 @@ -# ::PetApi +# swagger.api.PetApi ## Load the API package ```dart @@ -28,13 +28,13 @@ Add a new pet to the store ### Example ```dart -import 'swagger.api.PetApi': -import 'swagger.model.PetApi': +import 'swagger.api'; +import 'swagger.model'; // Configure OAuth2 access token for authorization: petstore_auth -swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; +//swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; -var api_instance = ::PetApi->new(); -var body = new :Pet(); # Pet | Pet object that needs to be added to the store +var api_instance = swagger.api.PetApi->new(); +var body = new swagger:Pet(); # Pet | Pet object that needs to be added to the store try { api_instance.addPet(body); @@ -73,12 +73,12 @@ Deletes a pet ### Example ```dart -import 'swagger.api.PetApi': -import 'swagger.model.PetApi': +import 'swagger.api'; +import 'swagger.model'; // Configure OAuth2 access token for authorization: petstore_auth -swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; +//swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; -var api_instance = ::PetApi->new(); +var api_instance = swagger.api.PetApi->new(); var petId = 789; # int | Pet id to delete var apiKey = apiKey_example; # String | @@ -120,12 +120,12 @@ Multiple status values can be provided with comma separated strings ### Example ```dart -import 'swagger.api.PetApi': -import 'swagger.model.PetApi': +import 'swagger.api'; +import 'swagger.model'; // Configure OAuth2 access token for authorization: petstore_auth -swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; +//swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; -var api_instance = ::PetApi->new(); +var api_instance = swagger.api.PetApi->new(); var status = []; # List | Status values that need to be considered for filter try { @@ -166,12 +166,12 @@ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 ### Example ```dart -import 'swagger.api.PetApi': -import 'swagger.model.PetApi': +import 'swagger.api'; +import 'swagger.model'; // Configure OAuth2 access token for authorization: petstore_auth -swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; +//swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; -var api_instance = ::PetApi->new(); +var api_instance = swagger.api.PetApi->new(); var tags = []; # List | Tags to filter by try { @@ -212,14 +212,14 @@ Returns a single pet ### Example ```dart -import 'swagger.api.PetApi': -import 'swagger.model.PetApi': +import 'swagger.api'; +import 'swagger.model'; // Configure API key authorization: api_key //swagger.api.Configuration.apiKey{'api_key'} = 'YOUR_API_KEY'; // uncomment below to setup prefix (e.g. Bearer) for API key, if needed //swagger.api.Configuration.apiKeyPrefix{'api_key'} = "Bearer"; -var api_instance = ::PetApi->new(); +var api_instance = swagger.api.PetApi->new(); var petId = 789; # int | ID of pet to return try { @@ -260,13 +260,13 @@ Update an existing pet ### Example ```dart -import 'swagger.api.PetApi': -import 'swagger.model.PetApi': +import 'swagger.api'; +import 'swagger.model'; // Configure OAuth2 access token for authorization: petstore_auth -swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; +//swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; -var api_instance = ::PetApi->new(); -var body = new :Pet(); # Pet | Pet object that needs to be added to the store +var api_instance = swagger.api.PetApi->new(); +var body = new swagger:Pet(); # Pet | Pet object that needs to be added to the store try { api_instance.updatePet(body); @@ -305,12 +305,12 @@ Updates a pet in the store with form data ### Example ```dart -import 'swagger.api.PetApi': -import 'swagger.model.PetApi': +import 'swagger.api'; +import 'swagger.model'; // Configure OAuth2 access token for authorization: petstore_auth -swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; +//swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; -var api_instance = ::PetApi->new(); +var api_instance = swagger.api.PetApi->new(); var petId = 789; # int | ID of pet that needs to be updated var name = name_example; # String | Updated name of the pet var status = status_example; # String | Updated status of the pet @@ -354,12 +354,12 @@ uploads an image ### Example ```dart -import 'swagger.api.PetApi': -import 'swagger.model.PetApi': +import 'swagger.api'; +import 'swagger.model'; // Configure OAuth2 access token for authorization: petstore_auth -swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; +//swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; -var api_instance = ::PetApi->new(); +var api_instance = swagger.api.PetApi->new(); var petId = 789; # int | ID of pet to update var additionalMetadata = additionalMetadata_example; # String | Additional data to pass to server var file = /path/to/file.txt; # MultipartFile | file to upload diff --git a/samples/client/petstore/dart/swagger/docs/StoreApi.md b/samples/client/petstore/dart/swagger/docs/StoreApi.md index 82423191fe2..afb498db524 100644 --- a/samples/client/petstore/dart/swagger/docs/StoreApi.md +++ b/samples/client/petstore/dart/swagger/docs/StoreApi.md @@ -1,4 +1,4 @@ -# ::StoreApi +# swagger.api.StoreApi ## Load the API package ```dart @@ -24,10 +24,10 @@ For valid response try integer IDs with value < 1000. Anything above 1000 or non ### Example ```dart -import 'swagger.api.StoreApi': -import 'swagger.model.StoreApi': +import 'swagger.api'; +import 'swagger.model'; -var api_instance = ::StoreApi->new(); +var api_instance = swagger.api.StoreApi->new(); var orderId = orderId_example; # String | ID of the order that needs to be deleted try { @@ -67,14 +67,14 @@ Returns a map of status codes to quantities ### Example ```dart -import 'swagger.api.StoreApi': -import 'swagger.model.StoreApi': +import 'swagger.api'; +import 'swagger.model'; // Configure API key authorization: api_key //swagger.api.Configuration.apiKey{'api_key'} = 'YOUR_API_KEY'; // uncomment below to setup prefix (e.g. Bearer) for API key, if needed //swagger.api.Configuration.apiKeyPrefix{'api_key'} = "Bearer"; -var api_instance = ::StoreApi->new(); +var api_instance = swagger.api.StoreApi->new(); try { var result = api_instance.getInventory(); @@ -111,10 +111,10 @@ For valid response try integer IDs with value <= 5 or > 10. Other values will ge ### Example ```dart -import 'swagger.api.StoreApi': -import 'swagger.model.StoreApi': +import 'swagger.api'; +import 'swagger.model'; -var api_instance = ::StoreApi->new(); +var api_instance = swagger.api.StoreApi->new(); var orderId = 789; # int | ID of pet that needs to be fetched try { @@ -155,11 +155,11 @@ Place an order for a pet ### Example ```dart -import 'swagger.api.StoreApi': -import 'swagger.model.StoreApi': +import 'swagger.api'; +import 'swagger.model'; -var api_instance = ::StoreApi->new(); -var body = new :Order(); # Order | order placed for purchasing the pet +var api_instance = swagger.api.StoreApi->new(); +var body = new swagger:Order(); # Order | order placed for purchasing the pet try { var result = api_instance.placeOrder(body); diff --git a/samples/client/petstore/dart/swagger/docs/Tag.md b/samples/client/petstore/dart/swagger/docs/Tag.md index 7d3455521bb..f0884cc1918 100644 --- a/samples/client/petstore/dart/swagger/docs/Tag.md +++ b/samples/client/petstore/dart/swagger/docs/Tag.md @@ -1,8 +1,8 @@ -# ::Object::Tag +# swagger.model.Tag ## Load the model package -```perl -use ::Object::Tag; +```dart +import swagger.model.Tag; ``` ## Properties diff --git a/samples/client/petstore/dart/swagger/docs/User.md b/samples/client/petstore/dart/swagger/docs/User.md index 9498e377f5f..dfe783b2cf7 100644 --- a/samples/client/petstore/dart/swagger/docs/User.md +++ b/samples/client/petstore/dart/swagger/docs/User.md @@ -1,8 +1,8 @@ -# ::Object::User +# swagger.model.User ## Load the model package -```perl -use ::Object::User; +```dart +import swagger.model.User; ``` ## Properties diff --git a/samples/client/petstore/dart/swagger/docs/UserApi.md b/samples/client/petstore/dart/swagger/docs/UserApi.md index d67a34eb71c..c68837b5e42 100644 --- a/samples/client/petstore/dart/swagger/docs/UserApi.md +++ b/samples/client/petstore/dart/swagger/docs/UserApi.md @@ -1,4 +1,4 @@ -# ::UserApi +# swagger.api.UserApi ## Load the API package ```dart @@ -28,11 +28,11 @@ This can only be done by the logged in user. ### Example ```dart -import 'swagger.api.UserApi': -import 'swagger.model.UserApi': +import 'swagger.api'; +import 'swagger.model'; -var api_instance = ::UserApi->new(); -var body = new :User(); # User | Created user object +var api_instance = swagger.api.UserApi->new(); +var body = new swagger:User(); # User | Created user object try { api_instance.createUser(body); @@ -71,11 +71,11 @@ Creates list of users with given input array ### Example ```dart -import 'swagger.api.UserApi': -import 'swagger.model.UserApi': +import 'swagger.api'; +import 'swagger.model'; -var api_instance = ::UserApi->new(); -var body = [new :List<User>()]; # List | List of user object +var api_instance = swagger.api.UserApi->new(); +var body = [new swagger:List<User>()]; # List | List of user object try { api_instance.createUsersWithArrayInput(body); @@ -114,11 +114,11 @@ Creates list of users with given input array ### Example ```dart -import 'swagger.api.UserApi': -import 'swagger.model.UserApi': +import 'swagger.api'; +import 'swagger.model'; -var api_instance = ::UserApi->new(); -var body = [new :List<User>()]; # List | List of user object +var api_instance = swagger.api.UserApi->new(); +var body = [new swagger:List<User>()]; # List | List of user object try { api_instance.createUsersWithListInput(body); @@ -157,10 +157,10 @@ This can only be done by the logged in user. ### Example ```dart -import 'swagger.api.UserApi': -import 'swagger.model.UserApi': +import 'swagger.api'; +import 'swagger.model'; -var api_instance = ::UserApi->new(); +var api_instance = swagger.api.UserApi->new(); var username = username_example; # String | The name that needs to be deleted try { @@ -200,10 +200,10 @@ Get user by user name ### Example ```dart -import 'swagger.api.UserApi': -import 'swagger.model.UserApi': +import 'swagger.api'; +import 'swagger.model'; -var api_instance = ::UserApi->new(); +var api_instance = swagger.api.UserApi->new(); var username = username_example; # String | The name that needs to be fetched. Use user1 for testing. try { @@ -244,10 +244,10 @@ Logs user into the system ### Example ```dart -import 'swagger.api.UserApi': -import 'swagger.model.UserApi': +import 'swagger.api'; +import 'swagger.model'; -var api_instance = ::UserApi->new(); +var api_instance = swagger.api.UserApi->new(); var username = username_example; # String | The user name for login var password = password_example; # String | The password for login in clear text @@ -290,10 +290,10 @@ Logs out current logged in user session ### Example ```dart -import 'swagger.api.UserApi': -import 'swagger.model.UserApi': +import 'swagger.api'; +import 'swagger.model'; -var api_instance = ::UserApi->new(); +var api_instance = swagger.api.UserApi->new(); try { api_instance.logoutUser(); @@ -329,12 +329,12 @@ This can only be done by the logged in user. ### Example ```dart -import 'swagger.api.UserApi': -import 'swagger.model.UserApi': +import 'swagger.api'; +import 'swagger.model'; -var api_instance = ::UserApi->new(); +var api_instance = swagger.api.UserApi->new(); var username = username_example; # String | name that need to be deleted -var body = new :User(); # User | Updated user object +var body = new swagger:User(); # User | Updated user object try { api_instance.updateUser(username, body); From 96c211c881c0017d4106d16b597eaa3e82012af9 Mon Sep 17 00:00:00 2001 From: wing328 Date: Wed, 30 Nov 2016 16:30:28 +0800 Subject: [PATCH 5/8] update dart doc --- .../src/main/resources/dart/README.mustache | 326 +++------------- .../src/main/resources/dart/api_doc.mustache | 10 +- .../client/petstore/dart/swagger/README.md | 361 ++++-------------- .../petstore/dart/swagger/docs/PetApi.md | 58 +-- .../petstore/dart/swagger/docs/StoreApi.md | 16 +- .../petstore/dart/swagger/docs/UserApi.md | 34 +- 6 files changed, 186 insertions(+), 619 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/dart/README.mustache b/modules/swagger-codegen/src/main/resources/dart/README.mustache index c732448cecf..e694760fcf0 100644 --- a/modules/swagger-codegen/src/main/resources/dart/README.mustache +++ b/modules/swagger-codegen/src/main/resources/dart/README.mustache @@ -1,303 +1,99 @@ -# NAME +# {{packagePath}} +{{#appDescription}} +{{{appDescription}}} +{{/appDescription}} -{{moduleName}}::Role - a Moose role for the {{appName}} - -{{#appDescription}}{{{appDescription}}}{{/appDescription}} - -# VERSION - -Automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: +This Dart package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: - API version: {{appVersion}} -- Package version: {{moduleVersion}} +{{#artifactVersion}} +- Package version: {{artifactVersion}} +{{/artifactVersion}} +{{^hideGenerationTimestamp}} - Build date: {{generatedDate}} +{{/hideGenerationTimestamp}} - Build package: {{generatorClass}} {{#infoUrl}} For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) {{/infoUrl}} -## A note on Moose - -This role is the only component of the library that uses Moose. See -{{moduleName}}::ApiFactory for non-Moosey usage. - -# SYNOPSIS - -The Perl Swagger Codegen project builds a library of Perl modules to interact with -a web service defined by a OpenAPI Specification. See below for how to build the -library. - -This module provides an interface to the generated library. All the classes, -objects, and methods (well, not quite \*all\*, see below) are flattened into this -role. - - package MyApp; - use Moose; - with '{{moduleName}}::Role'; - - package main; - - my $api = MyApp->new({ tokens => $tokens }); - - my $pet = $api->get_pet_by_id(pet_id => $pet_id); - - -## Structure of the library - -The library consists of a set of API classes, one for each endpoint. These APIs -implement the method calls available on each endpoint. - -Additionally, there is a set of "object" classes, which represent the objects -returned by and sent to the methods on the endpoints. - -An API factory class is provided, which builds instances of each endpoint API. - -This Moose role flattens all the methods from the endpoint APIs onto the consuming -class. It also provides methods to retrieve the endpoint API objects, and the API -factory object, should you need it. - -For documentation of all these methods, see AUTOMATIC DOCUMENTATION below. - -## Configuring authentication - -In the normal case, the OpenAPI Spec will describe what parameters are -required and where to put them. You just need to supply the tokens. - - my $tokens = { - # basic - username => $username, - password => $password, - - # oauth - access_token => $oauth_token, - - # keys - $some_key => { token => $token, - prefix => $prefix, - in => $in, # 'head||query', - }, - - $another => { token => $token, - prefix => $prefix, - in => $in, # 'head||query', - }, - ..., - - }; - - my $api = MyApp->new({ tokens => $tokens }); - -Note these are all optional, as are `prefix` and `in`, and depend on the API -you are accessing. Usually `prefix` and `in` will be determined by the code generator from -the spec and you will not need to set them at run time. If not, `in` will -default to 'head' and `prefix` to the empty string. - -The tokens will be placed in the `{{moduleName}}::Configuration` namespace -as follows, but you don't need to know about this. - -- `${{moduleName}}::Configuration::username` - - String. The username for basic auth. - -- `${{moduleName}}::Configuration::password` - - String. The password for basic auth. - -- `${{moduleName}}::Configuration::api_key` - - Hashref. Keyed on the name of each key (there can be multiple tokens). - - ${{moduleName}}::Configuration::api_key = { - secretKey => 'aaaabbbbccccdddd', - anotherKey => '1111222233334444', - }; - -- `${{moduleName}}::Configuration::api_key_prefix` - - Hashref. Keyed on the name of each key (there can be multiple tokens). Note not - all api keys require a prefix. - - ${{moduleName}}::Configuration::api_key_prefix = { - secretKey => 'string', - anotherKey => 'same or some other string', - }; - -- `${{moduleName}}::Configuration::access_token` - - String. The OAuth access token. - -# METHODS +## Requirements -## `base_url` +Dart 1.20.0 and later -The generated code has the `base_url` already set as a default value. This method -returns (and optionally sets, but only if the API client has not been -created yet) the current value of `base_url`. +## Installation & Usage -## `api_factory` +TODO -Returns an API factory object. You probably won't need to call this directly. +## Tests - $self->api_factory('Pet'); # returns a {{moduleName}}::PetApi instance - - $self->pet_api; # the same +TODO -# MISSING METHODS +## Getting Started -Most of the methods on the API are delegated to individual endpoint API objects -(e.g. Pet API, Store API, User API etc). Where different endpoint APIs use the -same method name (e.g. `new()`), these methods can't be delegated. So you need -to call `$api->pet_api->new()`. +Please follow the [installation procedure](#installation--usage) and then run the following: -In principle, every API is susceptible to the presence of a few, random, undelegatable -method names. In practice, because of the way method names are constructed, it's -unlikely in general that any methods will be undelegatable, except for: - - new() - class_documentation() - method_documentation() - -To call these methods, you need to get a handle on the relevant object, either -by calling `$api->foo_api` or by retrieving an object, e.g. -`$api->get_pet_by_id(pet_id => $pet_id)`. They are class methods, so -you could also call them on class names. - -# BUILDING YOUR LIBRARY - -See the homepage `https://github.com/swagger-api/swagger-codegen` for full details. -But briefly, clone the git repository, build the codegen codebase, set up your build -config file, then run the API build script. You will need git, Java 7 or 8 and Apache -maven 3.0.3 or better already installed. - -The config file should specify the project name for the generated library: - - {"moduleName":"WWW::MyProjectName"} - -Your library files will be built under `WWW::MyProjectName`. - - $ git clone https://github.com/swagger-api/swagger-codegen.git - $ cd swagger-codegen - $ mvn package - $ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ - -i [URL or file path to JSON swagger API spec] \ - -l perl \ - -c /path/to/config/file.json \ - -o /path/to/output/folder - -Bang, all done. Run the `autodoc` script in the `bin` directory to see the API -you just built. - -# AUTOMATIC DOCUMENTATION - -You can print out a summary of the generated API by running the included -`autodoc` script in the `bin` directory of your generated library. A few -output formats are supported: - - Usage: autodoc [OPTION] - - -w wide format (default) - -n narrow format - -p POD format - -H HTML format - -m Markdown format - -h print this help message - -c your application class - - -The `-c` option allows you to load and inspect your own application. A dummy -namespace is used if you don't supply your own class. - -# DOCUMENTATION FROM THE OpenAPI Spec - -Additional documentation for each class and method may be provided by the Swagger -spec. If so, this is available via the `class_documentation()` and -`method_documentation()` methods on each generated object class, and the -`method_documentation()` method on the endpoint API classes: - - my $cmdoc = $api->pet_api->method_documentation->{$method_name}; - - my $odoc = $api->get_pet_by_id->(pet_id => $pet_id)->class_documentation; - my $omdoc = $api->get_pet_by_id->(pet_id => $pet_id)->method_documentation->{method_name}; - - -Each of these calls returns a hashref with various useful pieces of information. - -# LOAD THE MODULES - -To load the API packages: -```perl -{{#apiInfo}}{{#apis}}use {{moduleName}}::{{classname}}; -{{/apis}}{{/apiInfo}} -``` - -To load the models: -```perl -{{#models}}{{#model}}use {{moduleName}}::Object::{{classname}}; -{{/model}}{{/models}} -```` - -# GETTING STARTED -Put the Perl SDK under the 'lib' folder in your project directory, then run the following -```perl -#!/usr/bin/perl -use lib 'lib'; -use strict; -use warnings; -# load the API package -{{#apiInfo}}{{#apis}}use {{moduleName}}::{{classname}}; -{{/apis}}{{/apiInfo}} -# load the models -{{#models}}{{#model}}use {{moduleName}}::Object::{{classname}}; -{{/model}}{{/models}} -# for displaying the API response data -use Data::Dumper; -use {{{moduleName}}}::Configuration; -use {{moduleName}}::{{classname}}; -{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}} -# Configure HTTP basic authorization: {{{name}}} -${{{moduleName}}}::Configuration::username = 'YOUR_USERNAME'; -${{{moduleName}}}::Configuration::password = 'YOUR_PASSWORD';{{/isBasic}}{{#isApiKey}} -# Configure API key authorization: {{{name}}} -${{{moduleName}}}::Configuration::api_key->{'{{{keyParamName}}}'} = 'YOUR_API_KEY'; -# uncomment below to setup prefix (e.g. Bearer) for API key, if needed -#${{{moduleName}}}::Configuration::api_key_prefix->{'{{{keyParamName}}}'} = 'Bearer';{{/isApiKey}}{{#isOAuth}} -# Configure OAuth2 access token for authorization: {{{name}}} -${{{moduleName}}}::Configuration::access_token = 'YOUR_ACCESS_TOKEN';{{/isOAuth}}{{/authMethods}} +```dart +import '{{pubName}}.api'; +import '{{pubName}}.model'; +{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}} +{{#hasAuthMethods}} +{{#authMethods}} +{{#isBasic}} +// TODO Configure HTTP basic authorization: {{{name}}} +//{{pubName}}.api.Configuration.username = 'YOUR_USERNAME'; +//{{pubName}}.api.Configuration.password = 'YOUR_PASSWORD'; +{{/isBasic}} +{{#isApiKey}} +// TODO Configure API key authorization: {{{name}}} +//{{pubName}}.api.Configuration.apiKey{'{{{keyParamName}}}'} = 'YOUR_API_KEY'; +// uncomment below to setup prefix (e.g. Bearer) for API key, if needed +//{{pubName}}.api.Configuration.apiKeyPrefix{'{{{keyParamName}}}'} = "Bearer"; +{{/isApiKey}} +{{#isOAuth}} +// TODO Configure OAuth2 access token for authorization: {{{name}}} +//{{pubName}}.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; +{{/isOAuth}} +{{/authMethods}} {{/hasAuthMethods}} -my $api_instance = {{moduleName}}::{{classname}}->new(); -{{#allParams}}my ${{paramName}} = {{#isListContainer}}[{{/isListContainer}}{{#isBodyParam}}{{{moduleName}}}::Object::{{dataType}}->new(){{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isListContainer}}]{{/isListContainer}}; # {{{dataType}}} | {{{description}}} +var api_instance = new {{classname}}(); +{{#allParams}} +var {{paramName}} = {{#isListContainer}}[{{/isListContainer}}{{#isBodyParam}}new {{dataType}}(){{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isListContainer}}]{{/isListContainer}}; // {{{dataType}}} | {{{description}}} {{/allParams}} -eval { - {{#returnType}}my $result = {{/returnType}}$api_instance->{{{operationId}}}({{#allParams}}{{paramName}} => ${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}} - print Dumper($result);{{/returnType}} -}; -if ($@) { - warn "Exception when calling {{classname}}->{{operationId}}: $@\n"; +try { + {{#returnType}}var result = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + {{#returnType}} + print(result); + {{/returnType}} +} catch (e) { + print("Exception when calling {{classname}}->{{operationId}}: $e\n"); } {{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} ``` -# DOCUMENTATION FOR API ENDPOINTS +## Documentation for API Endpoints All URIs are relative to *{{basePath}}* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- -{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{nickname}}**]({{apiDocPath}}{{classname}}.md#{{nickname}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}/{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} {{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} -# DOCUMENTATION FOR MODELS -{{#models}}{{#model}} - [{{moduleName}}::Object::{{classname}}]({{modelDocPath}}{{classname}}.md) +## Documentation For Models + +{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}/{{{classname}}}.md) {{/model}}{{/models}} -# DOCUMENTATION FOR AUTHORIZATION +## Documentation For Authorization + {{^authMethods}} All endpoints do not require authorization. {{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}} {{#authMethods}}## {{{name}}} -{{#isApiKey}}- **Type**: API key +{{#isApiKey}}- **Type**: API key - **API key parameter name**: {{{keyParamName}}} - **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} {{/isApiKey}} @@ -307,10 +103,14 @@ Class | Method | HTTP request | Description - **Flow**: {{{flow}}} - **Authorization URL**: {{{authorizationUrl}}} - **Scopes**: {{^scopes}}N/A{{/scopes}} -{{#scopes}} - **{{{scope}}}**: {{{description}}} +{{#scopes}} - **{{{scope}}}**: {{{description}}} {{/scopes}} {{/isOAuth}} {{/authMethods}} +## Author + +{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}} +{{/hasMore}}{{/apis}}{{/apiInfo}} diff --git a/modules/swagger-codegen/src/main/resources/dart/api_doc.mustache b/modules/swagger-codegen/src/main/resources/dart/api_doc.mustache index 4272f3a8099..8ab43869f4e 100644 --- a/modules/swagger-codegen/src/main/resources/dart/api_doc.mustache +++ b/modules/swagger-codegen/src/main/resources/dart/api_doc.mustache @@ -29,26 +29,26 @@ import '{{pubName}}.model'; {{#hasAuthMethods}} {{#authMethods}} {{#isBasic}} -// Configure HTTP basic authorization: {{{name}}} +// TODO Configure HTTP basic authorization: {{{name}}} //{{pubName}}.api.Configuration.username = 'YOUR_USERNAME'; //{{pubName}}.api.Configuration.password = 'YOUR_PASSWORD'; {{/isBasic}} {{#isApiKey}} -// Configure API key authorization: {{{name}}} +// TODO Configure API key authorization: {{{name}}} //{{pubName}}.api.Configuration.apiKey{'{{{keyParamName}}}'} = 'YOUR_API_KEY'; // uncomment below to setup prefix (e.g. Bearer) for API key, if needed //{{pubName}}.api.Configuration.apiKeyPrefix{'{{{keyParamName}}}'} = "Bearer"; {{/isApiKey}} {{#isOAuth}} -// Configure OAuth2 access token for authorization: {{{name}}} +// TODO Configure OAuth2 access token for authorization: {{{name}}} //{{pubName}}.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; {{/isOAuth}} {{/authMethods}} {{/hasAuthMethods}} -var api_instance = {{pubName}}.api.{{classname}}->new(); +var api_instance = new {{classname}}(); {{#allParams}} -var {{paramName}} = {{#isListContainer}}[{{/isListContainer}}{{#isBodyParam}}new {{{pubName}}}:{{dataType}}(){{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isListContainer}}]{{/isListContainer}}; # {{{dataType}}} | {{{description}}} +var {{paramName}} = {{#isListContainer}}[{{/isListContainer}}{{#isBodyParam}}new {{dataType}}(){{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isListContainer}}]{{/isListContainer}}; // {{{dataType}}} | {{{description}}} {{/allParams}} try { diff --git a/samples/client/petstore/dart/swagger/README.md b/samples/client/petstore/dart/swagger/README.md index ee02068cc08..8a2537ec8f2 100644 --- a/samples/client/petstore/dart/swagger/README.md +++ b/samples/client/petstore/dart/swagger/README.md @@ -1,327 +1,90 @@ -# NAME - -::Role - a Moose role for the Swagger Petstore - +# This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. -# VERSION - -Automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: +This Dart package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: - API version: 1.0.0 -- Package version: -- Build date: 2016-11-30T16:17:11.786+08:00 +- Build date: 2016-11-30T16:30:21.205+08:00 - Build package: class io.swagger.codegen.languages.DartClientCodegen -## A note on Moose - -This role is the only component of the library that uses Moose. See -::ApiFactory for non-Moosey usage. - -# SYNOPSIS - -The Perl Swagger Codegen project builds a library of Perl modules to interact with -a web service defined by a OpenAPI Specification. See below for how to build the -library. - -This module provides an interface to the generated library. All the classes, -objects, and methods (well, not quite \*all\*, see below) are flattened into this -role. - - package MyApp; - use Moose; - with '::Role'; - - package main; - - my $api = MyApp->new({ tokens => $tokens }); - - my $pet = $api->get_pet_by_id(pet_id => $pet_id); - - -## Structure of the library - -The library consists of a set of API classes, one for each endpoint. These APIs -implement the method calls available on each endpoint. - -Additionally, there is a set of "object" classes, which represent the objects -returned by and sent to the methods on the endpoints. - -An API factory class is provided, which builds instances of each endpoint API. - -This Moose role flattens all the methods from the endpoint APIs onto the consuming -class. It also provides methods to retrieve the endpoint API objects, and the API -factory object, should you need it. - -For documentation of all these methods, see AUTOMATIC DOCUMENTATION below. - -## Configuring authentication - -In the normal case, the OpenAPI Spec will describe what parameters are -required and where to put them. You just need to supply the tokens. - - my $tokens = { - # basic - username => $username, - password => $password, - - # oauth - access_token => $oauth_token, - - # keys - $some_key => { token => $token, - prefix => $prefix, - in => $in, # 'head||query', - }, - - $another => { token => $token, - prefix => $prefix, - in => $in, # 'head||query', - }, - ..., - - }; - - my $api = MyApp->new({ tokens => $tokens }); - -Note these are all optional, as are `prefix` and `in`, and depend on the API -you are accessing. Usually `prefix` and `in` will be determined by the code generator from -the spec and you will not need to set them at run time. If not, `in` will -default to 'head' and `prefix` to the empty string. - -The tokens will be placed in the `::Configuration` namespace -as follows, but you don't need to know about this. - -- `$::Configuration::username` - - String. The username for basic auth. - -- `$::Configuration::password` - - String. The password for basic auth. - -- `$::Configuration::api_key` - - Hashref. Keyed on the name of each key (there can be multiple tokens). - - $::Configuration::api_key = { - secretKey => 'aaaabbbbccccdddd', - anotherKey => '1111222233334444', - }; - -- `$::Configuration::api_key_prefix` - - Hashref. Keyed on the name of each key (there can be multiple tokens). Note not - all api keys require a prefix. +## Requirements - $::Configuration::api_key_prefix = { - secretKey => 'string', - anotherKey => 'same or some other string', - }; +Dart 1.20.0 and later -- `$::Configuration::access_token` +## Installation & Usage - String. The OAuth access token. +TODO -# METHODS +## Tests -## `base_url` +TODO -The generated code has the `base_url` already set as a default value. This method -returns (and optionally sets, but only if the API client has not been -created yet) the current value of `base_url`. +## Getting Started -## `api_factory` +Please follow the [installation procedure](#installation--usage) and then run the following: -Returns an API factory object. You probably won't need to call this directly. +```dart +import 'swagger.api'; +import 'swagger.model'; - $self->api_factory('Pet'); # returns a ::PetApi instance - - $self->pet_api; # the same +// TODO Configure OAuth2 access token for authorization: petstore_auth +//swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; -# MISSING METHODS +var api_instance = new PetApi(); +var body = new Pet(); // Pet | Pet object that needs to be added to the store -Most of the methods on the API are delegated to individual endpoint API objects -(e.g. Pet API, Store API, User API etc). Where different endpoint APIs use the -same method name (e.g. `new()`), these methods can't be delegated. So you need -to call `$api->pet_api->new()`. - -In principle, every API is susceptible to the presence of a few, random, undelegatable -method names. In practice, because of the way method names are constructed, it's -unlikely in general that any methods will be undelegatable, except for: - - new() - class_documentation() - method_documentation() - -To call these methods, you need to get a handle on the relevant object, either -by calling `$api->foo_api` or by retrieving an object, e.g. -`$api->get_pet_by_id(pet_id => $pet_id)`. They are class methods, so -you could also call them on class names. - -# BUILDING YOUR LIBRARY - -See the homepage `https://github.com/swagger-api/swagger-codegen` for full details. -But briefly, clone the git repository, build the codegen codebase, set up your build -config file, then run the API build script. You will need git, Java 7 or 8 and Apache -maven 3.0.3 or better already installed. - -The config file should specify the project name for the generated library: - - {"moduleName":"WWW::MyProjectName"} - -Your library files will be built under `WWW::MyProjectName`. - - $ git clone https://github.com/swagger-api/swagger-codegen.git - $ cd swagger-codegen - $ mvn package - $ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ - -i [URL or file path to JSON swagger API spec] \ - -l perl \ - -c /path/to/config/file.json \ - -o /path/to/output/folder - -Bang, all done. Run the `autodoc` script in the `bin` directory to see the API -you just built. - -# AUTOMATIC DOCUMENTATION - -You can print out a summary of the generated API by running the included -`autodoc` script in the `bin` directory of your generated library. A few -output formats are supported: - - Usage: autodoc [OPTION] - - -w wide format (default) - -n narrow format - -p POD format - -H HTML format - -m Markdown format - -h print this help message - -c your application class - - -The `-c` option allows you to load and inspect your own application. A dummy -namespace is used if you don't supply your own class. - -# DOCUMENTATION FROM THE OpenAPI Spec - -Additional documentation for each class and method may be provided by the Swagger -spec. If so, this is available via the `class_documentation()` and -`method_documentation()` methods on each generated object class, and the -`method_documentation()` method on the endpoint API classes: - - my $cmdoc = $api->pet_api->method_documentation->{$method_name}; - - my $odoc = $api->get_pet_by_id->(pet_id => $pet_id)->class_documentation; - my $omdoc = $api->get_pet_by_id->(pet_id => $pet_id)->method_documentation->{method_name}; - - -Each of these calls returns a hashref with various useful pieces of information. - -# LOAD THE MODULES - -To load the API packages: -```perl -use ::PetApi; -use ::StoreApi; -use ::UserApi; - -``` - -To load the models: -```perl -use ::Object::ApiResponse; -use ::Object::Category; -use ::Object::Order; -use ::Object::Pet; -use ::Object::Tag; -use ::Object::User; - -```` - -# GETTING STARTED -Put the Perl SDK under the 'lib' folder in your project directory, then run the following -```perl -#!/usr/bin/perl -use lib 'lib'; -use strict; -use warnings; -# load the API package -use ::PetApi; -use ::StoreApi; -use ::UserApi; - -# load the models -use ::Object::ApiResponse; -use ::Object::Category; -use ::Object::Order; -use ::Object::Pet; -use ::Object::Tag; -use ::Object::User; - -# for displaying the API response data -use Data::Dumper; -use ::Configuration; -use ::; - -# Configure OAuth2 access token for authorization: petstore_auth -$::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; - -my $api_instance = ::PetApi->new(); -my $body = ::Object::Pet->new(); # Pet | Pet object that needs to be added to the store - -eval { - $api_instance->addPet(body => $body); -}; -if ($@) { - warn "Exception when calling PetApi->addPet: $@\n"; +try { + api_instance.addPet(body); +} catch (e) { + print("Exception when calling PetApi->addPet: $e\n"); } ``` -# DOCUMENTATION FOR API ENDPOINTS +## Documentation for API Endpoints All URIs are relative to *http://petstore.swagger.io/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- -*PetApi* | [**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store -*PetApi* | [**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet -*PetApi* | [**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status -*PetApi* | [**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags -*PetApi* | [**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID -*PetApi* | [**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet -*PetApi* | [**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data -*PetApi* | [**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image -*StoreApi* | [**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID -*StoreApi* | [**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status -*StoreApi* | [**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID -*StoreApi* | [**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet -*UserApi* | [**createUser**](UserApi.md#createUser) | **POST** /user | Create user -*UserApi* | [**createUsersWithArrayInput**](UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array -*UserApi* | [**createUsersWithListInput**](UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array -*UserApi* | [**deleteUser**](UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user -*UserApi* | [**getUserByName**](UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name -*UserApi* | [**loginUser**](UserApi.md#loginUser) | **GET** /user/login | Logs user into the system -*UserApi* | [**logoutUser**](UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session -*UserApi* | [**updateUser**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user - - -# DOCUMENTATION FOR MODELS - - [::Object::ApiResponse](ApiResponse.md) - - [::Object::Category](Category.md) - - [::Object::Order](Order.md) - - [::Object::Pet](Pet.md) - - [::Object::Tag](Tag.md) - - [::Object::User](User.md) - - -# DOCUMENTATION FOR AUTHORIZATION +*PetApi* | [**addPet**](/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store +*PetApi* | [**deletePet**](/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**findPetsByStatus**](/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**findPetsByTags**](/PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**getPetById**](/PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**updatePet**](/PetApi.md#updatepet) | **PUT** /pet | Update an existing pet +*PetApi* | [**updatePetWithForm**](/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data +*PetApi* | [**uploadFile**](/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image +*StoreApi* | [**deleteOrder**](/StoreApi.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*StoreApi* | [**getInventory**](/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**getOrderById**](/StoreApi.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID +*StoreApi* | [**placeOrder**](/StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet +*UserApi* | [**createUser**](/UserApi.md#createuser) | **POST** /user | Create user +*UserApi* | [**createUsersWithArrayInput**](/UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**createUsersWithListInput**](/UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**deleteUser**](/UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user +*UserApi* | [**getUserByName**](/UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name +*UserApi* | [**loginUser**](/UserApi.md#loginuser) | **GET** /user/login | Logs user into the system +*UserApi* | [**logoutUser**](/UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**updateUser**](/UserApi.md#updateuser) | **PUT** /user/{username} | Updated user + + +## Documentation For Models + + - [ApiResponse](/ApiResponse.md) + - [Category](/Category.md) + - [Order](/Order.md) + - [Pet](/Pet.md) + - [Tag](/Tag.md) + - [User](/User.md) + + +## Documentation For Authorization + ## api_key -- **Type**: API key +- **Type**: API key - **API key parameter name**: api_key - **Location**: HTTP header @@ -331,8 +94,12 @@ Class | Method | HTTP request | Description - **Flow**: implicit - **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog - **Scopes**: - - **write:pets**: modify pets in your account - - **read:pets**: read your pets + - **write:pets**: modify pets in your account + - **read:pets**: read your pets + + +## Author +apiteam@swagger.io diff --git a/samples/client/petstore/dart/swagger/docs/PetApi.md b/samples/client/petstore/dart/swagger/docs/PetApi.md index e7e2cf7ec8e..b916c4a8d21 100644 --- a/samples/client/petstore/dart/swagger/docs/PetApi.md +++ b/samples/client/petstore/dart/swagger/docs/PetApi.md @@ -30,11 +30,11 @@ Add a new pet to the store ```dart import 'swagger.api'; import 'swagger.model'; -// Configure OAuth2 access token for authorization: petstore_auth +// TODO Configure OAuth2 access token for authorization: petstore_auth //swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; -var api_instance = swagger.api.PetApi->new(); -var body = new swagger:Pet(); # Pet | Pet object that needs to be added to the store +var api_instance = new PetApi(); +var body = new Pet(); // Pet | Pet object that needs to be added to the store try { api_instance.addPet(body); @@ -75,12 +75,12 @@ Deletes a pet ```dart import 'swagger.api'; import 'swagger.model'; -// Configure OAuth2 access token for authorization: petstore_auth +// TODO Configure OAuth2 access token for authorization: petstore_auth //swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; -var api_instance = swagger.api.PetApi->new(); -var petId = 789; # int | Pet id to delete -var apiKey = apiKey_example; # String | +var api_instance = new PetApi(); +var petId = 789; // int | Pet id to delete +var apiKey = apiKey_example; // String | try { api_instance.deletePet(petId, apiKey); @@ -122,11 +122,11 @@ Multiple status values can be provided with comma separated strings ```dart import 'swagger.api'; import 'swagger.model'; -// Configure OAuth2 access token for authorization: petstore_auth +// TODO Configure OAuth2 access token for authorization: petstore_auth //swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; -var api_instance = swagger.api.PetApi->new(); -var status = []; # List | Status values that need to be considered for filter +var api_instance = new PetApi(); +var status = []; // List | Status values that need to be considered for filter try { var result = api_instance.findPetsByStatus(status); @@ -168,11 +168,11 @@ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 ```dart import 'swagger.api'; import 'swagger.model'; -// Configure OAuth2 access token for authorization: petstore_auth +// TODO Configure OAuth2 access token for authorization: petstore_auth //swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; -var api_instance = swagger.api.PetApi->new(); -var tags = []; # List | Tags to filter by +var api_instance = new PetApi(); +var tags = []; // List | Tags to filter by try { var result = api_instance.findPetsByTags(tags); @@ -214,13 +214,13 @@ Returns a single pet ```dart import 'swagger.api'; import 'swagger.model'; -// Configure API key authorization: api_key +// TODO Configure API key authorization: api_key //swagger.api.Configuration.apiKey{'api_key'} = 'YOUR_API_KEY'; // uncomment below to setup prefix (e.g. Bearer) for API key, if needed //swagger.api.Configuration.apiKeyPrefix{'api_key'} = "Bearer"; -var api_instance = swagger.api.PetApi->new(); -var petId = 789; # int | ID of pet to return +var api_instance = new PetApi(); +var petId = 789; // int | ID of pet to return try { var result = api_instance.getPetById(petId); @@ -262,11 +262,11 @@ Update an existing pet ```dart import 'swagger.api'; import 'swagger.model'; -// Configure OAuth2 access token for authorization: petstore_auth +// TODO Configure OAuth2 access token for authorization: petstore_auth //swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; -var api_instance = swagger.api.PetApi->new(); -var body = new swagger:Pet(); # Pet | Pet object that needs to be added to the store +var api_instance = new PetApi(); +var body = new Pet(); // Pet | Pet object that needs to be added to the store try { api_instance.updatePet(body); @@ -307,13 +307,13 @@ Updates a pet in the store with form data ```dart import 'swagger.api'; import 'swagger.model'; -// Configure OAuth2 access token for authorization: petstore_auth +// TODO Configure OAuth2 access token for authorization: petstore_auth //swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; -var api_instance = swagger.api.PetApi->new(); -var petId = 789; # int | ID of pet that needs to be updated -var name = name_example; # String | Updated name of the pet -var status = status_example; # String | Updated status of the pet +var api_instance = new PetApi(); +var petId = 789; // int | ID of pet that needs to be updated +var name = name_example; // String | Updated name of the pet +var status = status_example; // String | Updated status of the pet try { api_instance.updatePetWithForm(petId, name, status); @@ -356,13 +356,13 @@ uploads an image ```dart import 'swagger.api'; import 'swagger.model'; -// Configure OAuth2 access token for authorization: petstore_auth +// TODO Configure OAuth2 access token for authorization: petstore_auth //swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; -var api_instance = swagger.api.PetApi->new(); -var petId = 789; # int | ID of pet to update -var additionalMetadata = additionalMetadata_example; # String | Additional data to pass to server -var file = /path/to/file.txt; # MultipartFile | file to upload +var api_instance = new PetApi(); +var petId = 789; // int | ID of pet to update +var additionalMetadata = additionalMetadata_example; // String | Additional data to pass to server +var file = /path/to/file.txt; // MultipartFile | file to upload try { var result = api_instance.uploadFile(petId, additionalMetadata, file); diff --git a/samples/client/petstore/dart/swagger/docs/StoreApi.md b/samples/client/petstore/dart/swagger/docs/StoreApi.md index afb498db524..57494d55633 100644 --- a/samples/client/petstore/dart/swagger/docs/StoreApi.md +++ b/samples/client/petstore/dart/swagger/docs/StoreApi.md @@ -27,8 +27,8 @@ For valid response try integer IDs with value < 1000. Anything above 1000 or non import 'swagger.api'; import 'swagger.model'; -var api_instance = swagger.api.StoreApi->new(); -var orderId = orderId_example; # String | ID of the order that needs to be deleted +var api_instance = new StoreApi(); +var orderId = orderId_example; // String | ID of the order that needs to be deleted try { api_instance.deleteOrder(orderId); @@ -69,12 +69,12 @@ Returns a map of status codes to quantities ```dart import 'swagger.api'; import 'swagger.model'; -// Configure API key authorization: api_key +// TODO Configure API key authorization: api_key //swagger.api.Configuration.apiKey{'api_key'} = 'YOUR_API_KEY'; // uncomment below to setup prefix (e.g. Bearer) for API key, if needed //swagger.api.Configuration.apiKeyPrefix{'api_key'} = "Bearer"; -var api_instance = swagger.api.StoreApi->new(); +var api_instance = new StoreApi(); try { var result = api_instance.getInventory(); @@ -114,8 +114,8 @@ For valid response try integer IDs with value <= 5 or > 10. Other values will ge import 'swagger.api'; import 'swagger.model'; -var api_instance = swagger.api.StoreApi->new(); -var orderId = 789; # int | ID of pet that needs to be fetched +var api_instance = new StoreApi(); +var orderId = 789; // int | ID of pet that needs to be fetched try { var result = api_instance.getOrderById(orderId); @@ -158,8 +158,8 @@ Place an order for a pet import 'swagger.api'; import 'swagger.model'; -var api_instance = swagger.api.StoreApi->new(); -var body = new swagger:Order(); # Order | order placed for purchasing the pet +var api_instance = new StoreApi(); +var body = new Order(); // Order | order placed for purchasing the pet try { var result = api_instance.placeOrder(body); diff --git a/samples/client/petstore/dart/swagger/docs/UserApi.md b/samples/client/petstore/dart/swagger/docs/UserApi.md index c68837b5e42..7c2fd6e6356 100644 --- a/samples/client/petstore/dart/swagger/docs/UserApi.md +++ b/samples/client/petstore/dart/swagger/docs/UserApi.md @@ -31,8 +31,8 @@ This can only be done by the logged in user. import 'swagger.api'; import 'swagger.model'; -var api_instance = swagger.api.UserApi->new(); -var body = new swagger:User(); # User | Created user object +var api_instance = new UserApi(); +var body = new User(); // User | Created user object try { api_instance.createUser(body); @@ -74,8 +74,8 @@ Creates list of users with given input array import 'swagger.api'; import 'swagger.model'; -var api_instance = swagger.api.UserApi->new(); -var body = [new swagger:List<User>()]; # List | List of user object +var api_instance = new UserApi(); +var body = [new List<User>()]; // List | List of user object try { api_instance.createUsersWithArrayInput(body); @@ -117,8 +117,8 @@ Creates list of users with given input array import 'swagger.api'; import 'swagger.model'; -var api_instance = swagger.api.UserApi->new(); -var body = [new swagger:List<User>()]; # List | List of user object +var api_instance = new UserApi(); +var body = [new List<User>()]; // List | List of user object try { api_instance.createUsersWithListInput(body); @@ -160,8 +160,8 @@ This can only be done by the logged in user. import 'swagger.api'; import 'swagger.model'; -var api_instance = swagger.api.UserApi->new(); -var username = username_example; # String | The name that needs to be deleted +var api_instance = new UserApi(); +var username = username_example; // String | The name that needs to be deleted try { api_instance.deleteUser(username); @@ -203,8 +203,8 @@ Get user by user name import 'swagger.api'; import 'swagger.model'; -var api_instance = swagger.api.UserApi->new(); -var username = username_example; # String | The name that needs to be fetched. Use user1 for testing. +var api_instance = new UserApi(); +var username = username_example; // String | The name that needs to be fetched. Use user1 for testing. try { var result = api_instance.getUserByName(username); @@ -247,9 +247,9 @@ Logs user into the system import 'swagger.api'; import 'swagger.model'; -var api_instance = swagger.api.UserApi->new(); -var username = username_example; # String | The user name for login -var password = password_example; # String | The password for login in clear text +var api_instance = new UserApi(); +var username = username_example; // String | The user name for login +var password = password_example; // String | The password for login in clear text try { var result = api_instance.loginUser(username, password); @@ -293,7 +293,7 @@ Logs out current logged in user session import 'swagger.api'; import 'swagger.model'; -var api_instance = swagger.api.UserApi->new(); +var api_instance = new UserApi(); try { api_instance.logoutUser(); @@ -332,9 +332,9 @@ This can only be done by the logged in user. import 'swagger.api'; import 'swagger.model'; -var api_instance = swagger.api.UserApi->new(); -var username = username_example; # String | name that need to be deleted -var body = new swagger:User(); # User | Updated user object +var api_instance = new UserApi(); +var username = username_example; // String | name that need to be deleted +var body = new User(); // User | Updated user object try { api_instance.updateUser(username, body); From 4cb50106bcc9043f4beded567fe5aafa22193319 Mon Sep 17 00:00:00 2001 From: wing328 Date: Wed, 30 Nov 2016 16:40:14 +0800 Subject: [PATCH 6/8] update dart petstore sample --- .../codegen/languages/DartClientCodegen.java | 6 +- .../src/main/resources/dart/README.mustache | 2 +- .../client/petstore/dart/swagger/README.md | 56 +++++++++---------- 3 files changed, 33 insertions(+), 31 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/DartClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/DartClientCodegen.java index 1d7a2e62f2f..8d2591f0521 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/DartClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/DartClientCodegen.java @@ -149,6 +149,10 @@ public void processOpts() { this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER)); } + // make api and model doc path available in mustache template + additionalProperties.put("apiDocPath", apiDocPath); + additionalProperties.put("modelDocPath", modelDocPath); + final String libFolder = sourceFolder + File.separator + "lib"; supportingFiles.add(new SupportingFile("pubspec.mustache", "", "pubspec.yaml")); supportingFiles.add(new SupportingFile("analysis_options.mustache", "", ".analysis_options")); @@ -166,8 +170,6 @@ public void processOpts() { supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); - - } diff --git a/modules/swagger-codegen/src/main/resources/dart/README.mustache b/modules/swagger-codegen/src/main/resources/dart/README.mustache index e694760fcf0..37892f53e27 100644 --- a/modules/swagger-codegen/src/main/resources/dart/README.mustache +++ b/modules/swagger-codegen/src/main/resources/dart/README.mustache @@ -1,4 +1,4 @@ -# {{packagePath}} +# {{pubName}} {{#appDescription}} {{{appDescription}}} {{/appDescription}} diff --git a/samples/client/petstore/dart/swagger/README.md b/samples/client/petstore/dart/swagger/README.md index 8a2537ec8f2..c19e47488f9 100644 --- a/samples/client/petstore/dart/swagger/README.md +++ b/samples/client/petstore/dart/swagger/README.md @@ -1,10 +1,10 @@ -# +# swagger This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. This Dart package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: - API version: 1.0.0 -- Build date: 2016-11-30T16:30:21.205+08:00 +- Build date: 2016-11-30T16:35:08.271+08:00 - Build package: class io.swagger.codegen.languages.DartClientCodegen ## Requirements @@ -47,36 +47,36 @@ All URIs are relative to *http://petstore.swagger.io/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- -*PetApi* | [**addPet**](/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store -*PetApi* | [**deletePet**](/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet -*PetApi* | [**findPetsByStatus**](/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status -*PetApi* | [**findPetsByTags**](/PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags -*PetApi* | [**getPetById**](/PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID -*PetApi* | [**updatePet**](/PetApi.md#updatepet) | **PUT** /pet | Update an existing pet -*PetApi* | [**updatePetWithForm**](/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data -*PetApi* | [**uploadFile**](/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image -*StoreApi* | [**deleteOrder**](/StoreApi.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID -*StoreApi* | [**getInventory**](/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status -*StoreApi* | [**getOrderById**](/StoreApi.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID -*StoreApi* | [**placeOrder**](/StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet -*UserApi* | [**createUser**](/UserApi.md#createuser) | **POST** /user | Create user -*UserApi* | [**createUsersWithArrayInput**](/UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array -*UserApi* | [**createUsersWithListInput**](/UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array -*UserApi* | [**deleteUser**](/UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user -*UserApi* | [**getUserByName**](/UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name -*UserApi* | [**loginUser**](/UserApi.md#loginuser) | **GET** /user/login | Logs user into the system -*UserApi* | [**logoutUser**](/UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session -*UserApi* | [**updateUser**](/UserApi.md#updateuser) | **PUT** /user/{username} | Updated user +*PetApi* | [**addPet**](docs//PetApi.md#addpet) | **POST** /pet | Add a new pet to the store +*PetApi* | [**deletePet**](docs//PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**findPetsByStatus**](docs//PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**findPetsByTags**](docs//PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**getPetById**](docs//PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**updatePet**](docs//PetApi.md#updatepet) | **PUT** /pet | Update an existing pet +*PetApi* | [**updatePetWithForm**](docs//PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data +*PetApi* | [**uploadFile**](docs//PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image +*StoreApi* | [**deleteOrder**](docs//StoreApi.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*StoreApi* | [**getInventory**](docs//StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**getOrderById**](docs//StoreApi.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID +*StoreApi* | [**placeOrder**](docs//StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet +*UserApi* | [**createUser**](docs//UserApi.md#createuser) | **POST** /user | Create user +*UserApi* | [**createUsersWithArrayInput**](docs//UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**createUsersWithListInput**](docs//UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**deleteUser**](docs//UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user +*UserApi* | [**getUserByName**](docs//UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name +*UserApi* | [**loginUser**](docs//UserApi.md#loginuser) | **GET** /user/login | Logs user into the system +*UserApi* | [**logoutUser**](docs//UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**updateUser**](docs//UserApi.md#updateuser) | **PUT** /user/{username} | Updated user ## Documentation For Models - - [ApiResponse](/ApiResponse.md) - - [Category](/Category.md) - - [Order](/Order.md) - - [Pet](/Pet.md) - - [Tag](/Tag.md) - - [User](/User.md) + - [ApiResponse](docs//ApiResponse.md) + - [Category](docs//Category.md) + - [Order](docs//Order.md) + - [Pet](docs//Pet.md) + - [Tag](docs//Tag.md) + - [User](docs//User.md) ## Documentation For Authorization From 002c76e809457bdbbc49c90300295e0cf868509c Mon Sep 17 00:00:00 2001 From: wing328 Date: Wed, 30 Nov 2016 17:13:26 +0800 Subject: [PATCH 7/8] update dart petstore sample --- .../src/main/resources/dart/README.mustache | 27 +++++++++++++++-- .../src/main/resources/dart/api_doc.mustache | 2 +- .../main/resources/dart/object_doc.mustache | 2 +- .../client/petstore/dart/swagger/README.md | 29 ++++++++++++++++--- .../petstore/dart/swagger/docs/ApiResponse.md | 2 +- .../petstore/dart/swagger/docs/Category.md | 2 +- .../petstore/dart/swagger/docs/Order.md | 2 +- .../client/petstore/dart/swagger/docs/Pet.md | 2 +- .../petstore/dart/swagger/docs/PetApi.md | 2 +- .../petstore/dart/swagger/docs/StoreApi.md | 2 +- .../client/petstore/dart/swagger/docs/Tag.md | 2 +- .../client/petstore/dart/swagger/docs/User.md | 2 +- .../petstore/dart/swagger/docs/UserApi.md | 2 +- 13 files changed, 60 insertions(+), 18 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/dart/README.mustache b/modules/swagger-codegen/src/main/resources/dart/README.mustache index 37892f53e27..9f54e4ffdaf 100644 --- a/modules/swagger-codegen/src/main/resources/dart/README.mustache +++ b/modules/swagger-codegen/src/main/resources/dart/README.mustache @@ -23,7 +23,29 @@ Dart 1.20.0 and later ## Installation & Usage -TODO +### Github +Please include the following in pubspec.yaml +``` +name: {{pubName}} +version: {{pubVersion}} +description: {{pubDescription}} +dependencies: + {{pubName}}: + git: https://github.com/{{gitUserId}}/{{gitRepoId}}.git + version: 'any' +``` + +### Local +Please include the following in pubspec.yaml +``` +name: {{pubName}} +version: {{pubVersion}} +description: {{pubDescription}} +dependencies: + {{pubName}}: + git: https://github.com/{{gitUserId}}/{{gitRepoId}}.git + version: 'any' +``` ## Tests @@ -34,8 +56,7 @@ TODO Please follow the [installation procedure](#installation--usage) and then run the following: ```dart -import '{{pubName}}.api'; -import '{{pubName}}.model'; +import 'package:{{pubName}}/api.dart'; {{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}} {{#hasAuthMethods}} {{#authMethods}} diff --git a/modules/swagger-codegen/src/main/resources/dart/api_doc.mustache b/modules/swagger-codegen/src/main/resources/dart/api_doc.mustache index 8ab43869f4e..06491380ae8 100644 --- a/modules/swagger-codegen/src/main/resources/dart/api_doc.mustache +++ b/modules/swagger-codegen/src/main/resources/dart/api_doc.mustache @@ -3,7 +3,7 @@ ## Load the API package ```dart -import '{{pubName}}.api.{{classname}}'; +import 'package:{{pubName}}/api.dart'; ``` All URIs are relative to *{{basePath}}* diff --git a/modules/swagger-codegen/src/main/resources/dart/object_doc.mustache b/modules/swagger-codegen/src/main/resources/dart/object_doc.mustache index f640a87c360..9ad4463997b 100644 --- a/modules/swagger-codegen/src/main/resources/dart/object_doc.mustache +++ b/modules/swagger-codegen/src/main/resources/dart/object_doc.mustache @@ -2,7 +2,7 @@ ## Load the model package ```dart -import {{pubName}}.model.{{classname}}; +import 'package:{{pubName}}/api.dart'; ``` ## Properties diff --git a/samples/client/petstore/dart/swagger/README.md b/samples/client/petstore/dart/swagger/README.md index c19e47488f9..40a4e529a78 100644 --- a/samples/client/petstore/dart/swagger/README.md +++ b/samples/client/petstore/dart/swagger/README.md @@ -4,7 +4,7 @@ This is a sample server Petstore server. You can find out more about Swagger at This Dart package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: - API version: 1.0.0 -- Build date: 2016-11-30T16:35:08.271+08:00 +- Build date: 2016-11-30T17:13:22.674+08:00 - Build package: class io.swagger.codegen.languages.DartClientCodegen ## Requirements @@ -13,7 +13,29 @@ Dart 1.20.0 and later ## Installation & Usage -TODO +### Github +Please include the following in pubspec.yaml +``` +name: swagger +version: 1.0.0 +description: Swagger API client +dependencies: + swagger: + git: https://github.com/GIT_USER_ID/GIT_REPO_ID.git + version: 'any' +``` + +### Local +Please include the following in pubspec.yaml +``` +name: swagger +version: 1.0.0 +description: Swagger API client +dependencies: + swagger: + git: https://github.com/GIT_USER_ID/GIT_REPO_ID.git + version: 'any' +``` ## Tests @@ -24,8 +46,7 @@ TODO Please follow the [installation procedure](#installation--usage) and then run the following: ```dart -import 'swagger.api'; -import 'swagger.model'; +import 'package:swagger/api.dart'; // TODO Configure OAuth2 access token for authorization: petstore_auth //swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; diff --git a/samples/client/petstore/dart/swagger/docs/ApiResponse.md b/samples/client/petstore/dart/swagger/docs/ApiResponse.md index f5b16281f01..7bc0c834d78 100644 --- a/samples/client/petstore/dart/swagger/docs/ApiResponse.md +++ b/samples/client/petstore/dart/swagger/docs/ApiResponse.md @@ -2,7 +2,7 @@ ## Load the model package ```dart -import swagger.model.ApiResponse; +import 'package:swagger/api.dart'; ``` ## Properties diff --git a/samples/client/petstore/dart/swagger/docs/Category.md b/samples/client/petstore/dart/swagger/docs/Category.md index ca4dfef1274..3f5d01c5e1c 100644 --- a/samples/client/petstore/dart/swagger/docs/Category.md +++ b/samples/client/petstore/dart/swagger/docs/Category.md @@ -2,7 +2,7 @@ ## Load the model package ```dart -import swagger.model.Category; +import 'package:swagger/api.dart'; ``` ## Properties diff --git a/samples/client/petstore/dart/swagger/docs/Order.md b/samples/client/petstore/dart/swagger/docs/Order.md index 5425a272629..c076322a76e 100644 --- a/samples/client/petstore/dart/swagger/docs/Order.md +++ b/samples/client/petstore/dart/swagger/docs/Order.md @@ -2,7 +2,7 @@ ## Load the model package ```dart -import swagger.model.Order; +import 'package:swagger/api.dart'; ``` ## Properties diff --git a/samples/client/petstore/dart/swagger/docs/Pet.md b/samples/client/petstore/dart/swagger/docs/Pet.md index 6e3e6c156ff..3f8629fbd43 100644 --- a/samples/client/petstore/dart/swagger/docs/Pet.md +++ b/samples/client/petstore/dart/swagger/docs/Pet.md @@ -2,7 +2,7 @@ ## Load the model package ```dart -import swagger.model.Pet; +import 'package:swagger/api.dart'; ``` ## Properties diff --git a/samples/client/petstore/dart/swagger/docs/PetApi.md b/samples/client/petstore/dart/swagger/docs/PetApi.md index b916c4a8d21..310ea9ee57b 100644 --- a/samples/client/petstore/dart/swagger/docs/PetApi.md +++ b/samples/client/petstore/dart/swagger/docs/PetApi.md @@ -2,7 +2,7 @@ ## Load the API package ```dart -import 'swagger.api.PetApi'; +import 'package:swagger/api.dart'; ``` All URIs are relative to ** diff --git a/samples/client/petstore/dart/swagger/docs/StoreApi.md b/samples/client/petstore/dart/swagger/docs/StoreApi.md index 57494d55633..a51bfe07cfc 100644 --- a/samples/client/petstore/dart/swagger/docs/StoreApi.md +++ b/samples/client/petstore/dart/swagger/docs/StoreApi.md @@ -2,7 +2,7 @@ ## Load the API package ```dart -import 'swagger.api.StoreApi'; +import 'package:swagger/api.dart'; ``` All URIs are relative to ** diff --git a/samples/client/petstore/dart/swagger/docs/Tag.md b/samples/client/petstore/dart/swagger/docs/Tag.md index f0884cc1918..c644f1e826a 100644 --- a/samples/client/petstore/dart/swagger/docs/Tag.md +++ b/samples/client/petstore/dart/swagger/docs/Tag.md @@ -2,7 +2,7 @@ ## Load the model package ```dart -import swagger.model.Tag; +import 'package:swagger/api.dart'; ``` ## Properties diff --git a/samples/client/petstore/dart/swagger/docs/User.md b/samples/client/petstore/dart/swagger/docs/User.md index dfe783b2cf7..d49bb37d96c 100644 --- a/samples/client/petstore/dart/swagger/docs/User.md +++ b/samples/client/petstore/dart/swagger/docs/User.md @@ -2,7 +2,7 @@ ## Load the model package ```dart -import swagger.model.User; +import 'package:swagger/api.dart'; ``` ## Properties diff --git a/samples/client/petstore/dart/swagger/docs/UserApi.md b/samples/client/petstore/dart/swagger/docs/UserApi.md index 7c2fd6e6356..bc26daaa1d1 100644 --- a/samples/client/petstore/dart/swagger/docs/UserApi.md +++ b/samples/client/petstore/dart/swagger/docs/UserApi.md @@ -2,7 +2,7 @@ ## Load the API package ```dart -import 'swagger.api.UserApi'; +import 'package:swagger/api.dart'; ``` All URIs are relative to ** From 341193ef7ccc4493b913e2422424f656e8b76331 Mon Sep 17 00:00:00 2001 From: wing328 Date: Wed, 30 Nov 2016 17:17:33 +0800 Subject: [PATCH 8/8] update dart client installation instruction --- .../src/main/resources/dart/README.mustache | 10 +++------- samples/client/petstore/dart/swagger/README.md | 12 ++++-------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/dart/README.mustache b/modules/swagger-codegen/src/main/resources/dart/README.mustache index 9f54e4ffdaf..c6620349a4a 100644 --- a/modules/swagger-codegen/src/main/resources/dart/README.mustache +++ b/modules/swagger-codegen/src/main/resources/dart/README.mustache @@ -24,7 +24,7 @@ Dart 1.20.0 and later ## Installation & Usage ### Github -Please include the following in pubspec.yaml +If this Dart package is published to Github, please include the following in pubspec.yaml ``` name: {{pubName}} version: {{pubVersion}} @@ -36,15 +36,11 @@ dependencies: ``` ### Local -Please include the following in pubspec.yaml +To use the package in your local drive, please include the following in pubspec.yaml ``` -name: {{pubName}} -version: {{pubVersion}} -description: {{pubDescription}} dependencies: {{pubName}}: - git: https://github.com/{{gitUserId}}/{{gitRepoId}}.git - version: 'any' + path: /path/to/{{pubName}} ``` ## Tests diff --git a/samples/client/petstore/dart/swagger/README.md b/samples/client/petstore/dart/swagger/README.md index 40a4e529a78..4eb573e3d32 100644 --- a/samples/client/petstore/dart/swagger/README.md +++ b/samples/client/petstore/dart/swagger/README.md @@ -4,7 +4,7 @@ This is a sample server Petstore server. You can find out more about Swagger at This Dart package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: - API version: 1.0.0 -- Build date: 2016-11-30T17:13:22.674+08:00 +- Build date: 2016-11-30T17:17:22.024+08:00 - Build package: class io.swagger.codegen.languages.DartClientCodegen ## Requirements @@ -14,7 +14,7 @@ Dart 1.20.0 and later ## Installation & Usage ### Github -Please include the following in pubspec.yaml +If this Dart package is published to Github, please include the following in pubspec.yaml ``` name: swagger version: 1.0.0 @@ -26,15 +26,11 @@ dependencies: ``` ### Local -Please include the following in pubspec.yaml +To use the package in your local drive, please include the following in pubspec.yaml ``` -name: swagger -version: 1.0.0 -description: Swagger API client dependencies: swagger: - git: https://github.com/GIT_USER_ID/GIT_REPO_ID.git - version: 'any' + path: /path/to/swagger ``` ## Tests