From 532d22c5a301ae8e38919e725fe2e264dc3f76d8 Mon Sep 17 00:00:00 2001 From: wing328 Date: Mon, 14 Mar 2016 17:25:11 +0800 Subject: [PATCH 1/4] add api documentation to php --- .../codegen/languages/PhpClientCodegen.java | 99 +++- .../src/main/resources/php/README.mustache | 40 +- .../src/main/resources/php/composer.mustache | 2 +- .../php/SwaggerClient-php/docs/Category.md | 16 + .../docs/InlineResponse200.md | 20 + .../php/SwaggerClient-php/docs/ModelReturn.md | 15 + .../php/SwaggerClient-php/docs/Name.md | 15 + .../php/SwaggerClient-php/docs/Order.md | 20 + .../php/SwaggerClient-php/docs/Pet.md | 20 + .../php/SwaggerClient-php/docs/PetApi.md | 557 ++++++++++++++++++ .../docs/SpecialModelName.md | 15 + .../php/SwaggerClient-php/docs/StoreApi.md | 311 ++++++++++ .../php/SwaggerClient-php/docs/Tag.md | 16 + .../php/SwaggerClient-php/docs/User.md | 22 + .../php/SwaggerClient-php/docs/UserApi.md | 371 ++++++++++++ .../php/SwaggerClient-php/lib/Api/UserApi.php | 5 + 16 files changed, 1539 insertions(+), 5 deletions(-) create mode 100644 samples/client/petstore/php/SwaggerClient-php/docs/Category.md create mode 100644 samples/client/petstore/php/SwaggerClient-php/docs/InlineResponse200.md create mode 100644 samples/client/petstore/php/SwaggerClient-php/docs/ModelReturn.md create mode 100644 samples/client/petstore/php/SwaggerClient-php/docs/Name.md create mode 100644 samples/client/petstore/php/SwaggerClient-php/docs/Order.md create mode 100644 samples/client/petstore/php/SwaggerClient-php/docs/Pet.md create mode 100644 samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md create mode 100644 samples/client/petstore/php/SwaggerClient-php/docs/SpecialModelName.md create mode 100644 samples/client/petstore/php/SwaggerClient-php/docs/StoreApi.md create mode 100644 samples/client/petstore/php/SwaggerClient-php/docs/Tag.md create mode 100644 samples/client/petstore/php/SwaggerClient-php/docs/User.md create mode 100644 samples/client/petstore/php/SwaggerClient-php/docs/UserApi.md diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java index 89eb2ebed7e..b8a891e4c66 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java @@ -3,6 +3,7 @@ package io.swagger.codegen.languages; import io.swagger.codegen.CliOption; import io.swagger.codegen.CodegenConfig; import io.swagger.codegen.CodegenConstants; +import io.swagger.codegen.CodegenParameter; import io.swagger.codegen.CodegenType; import io.swagger.codegen.DefaultCodegen; import io.swagger.codegen.SupportingFile; @@ -35,6 +36,8 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig { protected String artifactVersion = "1.0.0"; protected String srcBasePath = "lib"; protected String variableNamingConvention= "snake_case"; + protected String apiDocPath = "docs/"; + protected String modelDocPath = "docs/"; public PhpClientCodegen() { super(); @@ -49,6 +52,9 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig { modelPackage = invokerPackage + "\\Model"; testPackage = invokerPackage + "\\Tests"; + modelDocTemplateFiles.put("model_doc.mustache", ".md"); + apiDocTemplateFiles.put("api_doc.mustache", ".md"); + setReservedWordsLowerCase( Arrays.asList( // local variables used in api methods (endpoints) @@ -110,8 +116,8 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig { cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, "The main namespace to use for all classes. e.g. Yay\\Pets")); cliOptions.add(new CliOption(PACKAGE_PATH, "The main package name for classes. e.g. GeneratedPetstore")); cliOptions.add(new CliOption(SRC_BASE_PATH, "The directory under packagePath to serve as source root.")); - cliOptions.add(new CliOption(COMPOSER_VENDOR_NAME, "The vendor name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. yaypets")); - cliOptions.add(new CliOption(COMPOSER_PROJECT_NAME, "The project name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. petstore-client")); + cliOptions.add(new CliOption(COMPOSER_VENDOR_NAME, "The vendor name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. yaypets. IMPORTANT NOTE (2016/03): composerVendorName will be deprecated and replaced by gitUserId in the next swagger-codegen release")); + cliOptions.add(new CliOption(COMPOSER_PROJECT_NAME, "The project name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. petstore-client. IMPORTANT NOTE (2016/03): composerProjectName will be deprecated and replaced by gitRepoId in the next swagger-codegen release")); cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, "The version to use in the composer package version field. e.g. 1.2.3")); } @@ -217,6 +223,10 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig { additionalProperties.put("escapedInvokerPackage", invokerPackage.replace("\\", "\\\\")); + // make api and model doc path available in mustache template + additionalProperties.put("apiDocPath", apiDocPath); + additionalProperties.put("modelDocPath", modelDocPath); + supportingFiles.add(new SupportingFile("configuration.mustache", toPackagePath(invokerPackage, srcBasePath), "Configuration.php")); supportingFiles.add(new SupportingFile("ApiClient.mustache", toPackagePath(invokerPackage, srcBasePath), "ApiClient.php")); supportingFiles.add(new SupportingFile("ApiException.mustache", toPackagePath(invokerPackage, srcBasePath), "ApiException.php")); @@ -254,6 +264,28 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig { return (outputFolder + "/" + toPackagePath(testPackage, srcBasePath)); } + @Override + public String apiDocFileFolder() { + //return (outputFolder + "/" + apiDocPath).replace('/', File.separatorChar); + return (outputFolder + "/" + getPackagePath() + "/" + apiDocPath); + } + + @Override + public String modelDocFileFolder() { + //return (outputFolder + "/" + modelDocPath).replace('/', File.separatorChar); + return (outputFolder + "/" + getPackagePath() + "/" + modelDocPath); + } + + @Override + public String toModelDocFilename(String name) { + return toModelName(name); + } + + @Override + public String toApiDocFilename(String name) { + return toApiName(name); + } + @Override public String getTypeDeclaration(Property p) { if (p instanceof ArrayProperty) { @@ -460,4 +492,67 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig { return null; } + @Override + public void setParameterExampleValue(CodegenParameter p) { + String example; + + if (p.defaultValue == null) { + example = p.example; + } else { + example = p.defaultValue; + } + + String type = p.baseType; + if (type == null) { + type = p.dataType; + } + + if ("String".equals(type)) { + if (example == null) { + example = p.paramName + "_example"; + } + example = "\"" + escapeText(example) + "\""; + } else if ("Integer".equals(type)) { + if (example == null) { + example = "56"; + } + } else if ("Float".equals(type)) { + if (example == null) { + example = "3.4"; + } + } else if ("BOOLEAN".equals(type)) { + if (example == null) { + example = "True"; + } + } else if ("File".equals(type)) { + if (example == null) { + example = "/path/to/file"; + } + example = escapeText(example); + } else if ("Date".equals(type)) { + if (example == null) { + example = "2013-10-20"; + } + example = "new DateTime(\"" + escapeText(example) + "\")"; + } else if ("DateTime".equals(type)) { + if (example == null) { + example = "2013-10-20T19:20:30+01:00"; + } + example = "new DateTime(\"" + escapeText(example) + "\")"; + } else if (!languageSpecificPrimitives.contains(type)) { + // type is a model class, e.g. User + example = "new " + type + "()"; + } + + if (example == null) { + example = "NULL"; + } else if (Boolean.TRUE.equals(p.isListContainer)) { + example = "array(" + example + ")"; + } else if (Boolean.TRUE.equals(p.isMapContainer)) { + example = "array('key' => " + example + ")"; + } + + p.example = example; + } + } diff --git a/modules/swagger-codegen/src/main/resources/php/README.mustache b/modules/swagger-codegen/src/main/resources/php/README.mustache index a795b58be1d..00146f48944 100644 --- a/modules/swagger-codegen/src/main/resources/php/README.mustache +++ b/modules/swagger-codegen/src/main/resources/php/README.mustache @@ -14,11 +14,11 @@ You can install the bindings via [Composer](http://getcomposer.org/). Add this t "repositories": [ { "type": "git", - "url": "https://github.com/{{composerVendorName}}/{{composerProjectName}}.git" + "url": "https://github.com/{{#gitUserId}}{{.}}{{/gitUserId}}{{^gitUserId}}{{composerVendorName}}{{/gitUserId}}/{{#gitRepoId}}{{.}}{{/gitRepoId}}{{^gitRepoId}}{{composerProjectName}}{{/gitRepoId}}.git" } ], "require": { - "{{composerVendorName}}/{{composerProjectName}}": "*@dev" + "{{#gitUserId}}{{.}}{{/gitUserId}}{{^gitUserId}}{{composerVendorName}}{{/gitUserId}}/{{#gitRepoId}}{{.}}{{/gitRepoId}}{{^gitRepoId}}{{composerProjectName}}{{/gitRepoId}}": "*@dev" } } ``` @@ -40,6 +40,42 @@ composer install ./vendor/bin/phpunit lib/Tests ``` +## 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}} - [{{{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}}} +- **Authorizatoin URL**: {{{authorizationUrl}}} +- **Scopes**: {{^scopes}}N/A{{/scopes}} +{{#scopes}} - **{{{scope}}}**: {{{description}}} +{{/scopes}} +{{/isOAuth}} + +{{/authMethods}} + ## Author {{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}} diff --git a/modules/swagger-codegen/src/main/resources/php/composer.mustache b/modules/swagger-codegen/src/main/resources/php/composer.mustache index 994b6f1ccc7..64564e4ec57 100644 --- a/modules/swagger-codegen/src/main/resources/php/composer.mustache +++ b/modules/swagger-codegen/src/main/resources/php/composer.mustache @@ -1,5 +1,5 @@ { - "name": "{{composerVendorName}}/{{composerProjectName}}",{{#artifactVersion}} + "name": "{{#gitUserId}}{{.}}{{/gitUserId}}{{^gitUserId}}{{composerVendorName}}{{/gitUserId}}/{{#gitRepoId}}{{.}}{{/gitRepoId}}{{^gitRepoId}}{{composerProjectName}}{{/gitRepoId}}",{{#artifactVersion}} "version": "{{artifactVersion}}",{{/artifactVersion}} "description": "{{description}}", "keywords": [ diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/Category.md b/samples/client/petstore/php/SwaggerClient-php/docs/Category.md new file mode 100644 index 00000000000..1f57eb29678 --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/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] +**name** | **string** | | [optional] + +[[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/php/SwaggerClient-php/docs/InlineResponse200.md b/samples/client/petstore/php/SwaggerClient-php/docs/InlineResponse200.md new file mode 100644 index 00000000000..116f6808b07 --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/docs/InlineResponse200.md @@ -0,0 +1,20 @@ +# ::Object::InlineResponse200 + +## Load the model package +```perl +use ::Object::InlineResponse200; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**tags** | [**\Swagger\Client\Model\Tag[]**](Tag.md) | | [optional] +**id** | **int** | | +**category** | **object** | | [optional] +**status** | **string** | pet status in the store | [optional] +**name** | **string** | | [optional] +**photo_urls** | **string[]** | | [optional] + +[[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/php/SwaggerClient-php/docs/ModelReturn.md b/samples/client/petstore/php/SwaggerClient-php/docs/ModelReturn.md new file mode 100644 index 00000000000..1d6a183fecb --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/docs/ModelReturn.md @@ -0,0 +1,15 @@ +# ::Object::ModelReturn + +## Load the model package +```perl +use ::Object::ModelReturn; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**return** | **int** | | [optional] + +[[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/php/SwaggerClient-php/docs/Name.md b/samples/client/petstore/php/SwaggerClient-php/docs/Name.md new file mode 100644 index 00000000000..2c95721327a --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Name.md @@ -0,0 +1,15 @@ +# ::Object::Name + +## Load the model package +```perl +use ::Object::Name; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **int** | | [optional] + +[[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/php/SwaggerClient-php/docs/Order.md b/samples/client/petstore/php/SwaggerClient-php/docs/Order.md new file mode 100644 index 00000000000..79c68cff275 --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/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] +**pet_id** | **int** | | [optional] +**quantity** | **int** | | [optional] +**ship_date** | [**\DateTime**](\DateTime.md) | | [optional] +**status** | **string** | Order Status | [optional] +**complete** | **bool** | | [optional] + +[[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/php/SwaggerClient-php/docs/Pet.md b/samples/client/petstore/php/SwaggerClient-php/docs/Pet.md new file mode 100644 index 00000000000..a97841d399b --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/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] +**category** | [**\Swagger\Client\Model\Category**](Category.md) | | [optional] +**name** | **string** | | +**photo_urls** | **string[]** | | +**tags** | [**\Swagger\Client\Model\Tag[]**](Tag.md) | | [optional] +**status** | **string** | pet status in the store | [optional] + +[[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/php/SwaggerClient-php/docs/PetApi.md b/samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md new file mode 100644 index 00000000000..946074e7687 --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md @@ -0,0 +1,557 @@ +# ::PetApi + +## Load the API package +```perl +use ::Object::PetApi; +``` + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store +[**addPetUsingByteArray**](PetApi.md#addPetUsingByteArray) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding 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 +[**getPetByIdInObject**](PetApi.md#getPetByIdInObject) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' +[**petPetIdtestingByteArraytrueGet**](PetApi.md#petPetIdtestingByteArraytrueGet) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by '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 +```perl +use Data::Dumper; + +# Configure OAuth2 access token for authorization: petstore_auth +::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; + +my $api = ::PetApi->new(); +my $body = ::Object::\Swagger\Client\Model\Pet->new(); # [\Swagger\Client\Model\Pet] Pet object that needs to be added to the store + +eval { + $api->addPet(body => $body); +}; +if ($@) { + warn "Exception when calling PetApi->addPet: $@\n"; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**\Swagger\Client\Model\Pet**](\Swagger\Client\Model\Pet.md)| Pet object that needs to be added to the store | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/json, application/xml + +[[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) + +# **addPetUsingByteArray** +> addPetUsingByteArray(body => $body) + +Fake endpoint to test byte array in body parameter for adding a new pet to the store + + + +### Example +```perl +use Data::Dumper; + +# Configure OAuth2 access token for authorization: petstore_auth +::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; + +my $api = ::PetApi->new(); +my $body = ::Object::string->new(); # [string] Pet object in the form of byte array + +eval { + $api->addPetUsingByteArray(body => $body); +}; +if ($@) { + warn "Exception when calling PetApi->addPetUsingByteArray: $@\n"; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **string**| Pet object in the form of byte array | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/json, application/xml + +[[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(pet_id => $pet_id, api_key => $api_key) + +Deletes a pet + + + +### Example +```perl +use Data::Dumper; + +# Configure OAuth2 access token for authorization: petstore_auth +::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; + +my $api = ::PetApi->new(); +my $pet_id = 789; # [int] Pet id to delete +my $api_key = api_key_example; # [string] + +eval { + $api->deletePet(pet_id => $pet_id, api_key => $api_key); +}; +if ($@) { + warn "Exception when calling PetApi->deletePet: $@\n"; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| Pet id to delete | + **api_key** | **string**| | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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** +> \Swagger\Client\Model\Pet[] findPetsByStatus(status => $status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example +```perl +use Data::Dumper; + +# Configure OAuth2 access token for authorization: petstore_auth +::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; + +my $api = ::PetApi->new(); +my $status = (array(available)); # [string[]] Status values that need to be considered for query + +eval { + my $result = $api->findPetsByStatus(status => $status); + print Dumper($result); +}; +if ($@) { + warn "Exception when calling PetApi->findPetsByStatus: $@\n"; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | [**string[]**](string.md)| Status values that need to be considered for query | [optional] [default to available] + +### Return type + +[**\Swagger\Client\Model\Pet[]**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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** +> \Swagger\Client\Model\Pet[] findPetsByTags(tags => $tags) + +Finds Pets by tags + +Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + +### Example +```perl +use Data::Dumper; + +# Configure OAuth2 access token for authorization: petstore_auth +::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; + +my $api = ::PetApi->new(); +my $tags = (nil); # [string[]] Tags to filter by + +eval { + my $result = $api->findPetsByTags(tags => $tags); + print Dumper($result); +}; +if ($@) { + warn "Exception when calling PetApi->findPetsByTags: $@\n"; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **tags** | [**string[]**](string.md)| Tags to filter by | [optional] + +### Return type + +[**\Swagger\Client\Model\Pet[]**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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** +> \Swagger\Client\Model\Pet getPetById(pet_id => $pet_id) + +Find pet by ID + +Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + +### Example +```perl +use Data::Dumper; + +# 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"; +# Configure OAuth2 access token for authorization: petstore_auth +::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; + +my $api = ::PetApi->new(); +my $pet_id = 789; # [int] ID of pet that needs to be fetched + +eval { + my $result = $api->getPetById(pet_id => $pet_id); + print Dumper($result); +}; +if ($@) { + warn "Exception when calling PetApi->getPetById: $@\n"; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet that needs to be fetched | + +### Return type + +[**\Swagger\Client\Model\Pet**](Pet.md) + +### Authorization + +[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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) + +# **getPetByIdInObject** +> \Swagger\Client\Model\InlineResponse200 getPetByIdInObject(pet_id => $pet_id) + +Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + +Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + +### Example +```perl +use Data::Dumper; + +# 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"; +# Configure OAuth2 access token for authorization: petstore_auth +::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; + +my $api = ::PetApi->new(); +my $pet_id = 789; # [int] ID of pet that needs to be fetched + +eval { + my $result = $api->getPetByIdInObject(pet_id => $pet_id); + print Dumper($result); +}; +if ($@) { + warn "Exception when calling PetApi->getPetByIdInObject: $@\n"; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet that needs to be fetched | + +### Return type + +[**\Swagger\Client\Model\InlineResponse200**](InlineResponse200.md) + +### Authorization + +[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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) + +# **petPetIdtestingByteArraytrueGet** +> string petPetIdtestingByteArraytrueGet(pet_id => $pet_id) + +Fake endpoint to test byte array return by 'Find pet by ID' + +Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + +### Example +```perl +use Data::Dumper; + +# 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"; +# Configure OAuth2 access token for authorization: petstore_auth +::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; + +my $api = ::PetApi->new(); +my $pet_id = 789; # [int] ID of pet that needs to be fetched + +eval { + my $result = $api->petPetIdtestingByteArraytrueGet(pet_id => $pet_id); + print Dumper($result); +}; +if ($@) { + warn "Exception when calling PetApi->petPetIdtestingByteArraytrueGet: $@\n"; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet that needs to be fetched | + +### Return type + +**string** + +### Authorization + +[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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 +```perl +use Data::Dumper; + +# Configure OAuth2 access token for authorization: petstore_auth +::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; + +my $api = ::PetApi->new(); +my $body = ::Object::\Swagger\Client\Model\Pet->new(); # [\Swagger\Client\Model\Pet] Pet object that needs to be added to the store + +eval { + $api->updatePet(body => $body); +}; +if ($@) { + warn "Exception when calling PetApi->updatePet: $@\n"; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**\Swagger\Client\Model\Pet**](\Swagger\Client\Model\Pet.md)| Pet object that needs to be added to the store | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/json, application/xml + +[[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(pet_id => $pet_id, name => $name, status => $status) + +Updates a pet in the store with form data + + + +### Example +```perl +use Data::Dumper; + +# Configure OAuth2 access token for authorization: petstore_auth +::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; + +my $api = ::PetApi->new(); +my $pet_id = pet_id_example; # [string] ID of pet that needs to be updated +my $name = name_example; # [string] Updated name of the pet +my $status = status_example; # [string] Updated status of the pet + +eval { + $api->updatePetWithForm(pet_id => $pet_id, name => $name, status => $status); +}; +if ($@) { + warn "Exception when calling PetApi->updatePetWithForm: $@\n"; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **string**| 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 reuqest headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: application/json, application/xml + +[[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** +> uploadFile(pet_id => $pet_id, additional_metadata => $additional_metadata, file => $file) + +uploads an image + + + +### Example +```perl +use Data::Dumper; + +# Configure OAuth2 access token for authorization: petstore_auth +::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; + +my $api = ::PetApi->new(); +my $pet_id = 789; # [int] ID of pet to update +my $additional_metadata = additional_metadata_example; # [string] Additional data to pass to server +my $file = new Swagger\Client\\SplFileObject(); # [\SplFileObject] file to upload + +eval { + $api->uploadFile(pet_id => $pet_id, additional_metadata => $additional_metadata, file => $file); +}; +if ($@) { + warn "Exception when calling PetApi->uploadFile: $@\n"; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet to update | + **additional_metadata** | **string**| Additional data to pass to server | [optional] + **file** | **\SplFileObject**| file to upload | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json, application/xml + +[[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/php/SwaggerClient-php/docs/SpecialModelName.md b/samples/client/petstore/php/SwaggerClient-php/docs/SpecialModelName.md new file mode 100644 index 00000000000..d0775fc6a2f --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/docs/SpecialModelName.md @@ -0,0 +1,15 @@ +# ::Object::SpecialModelName + +## Load the model package +```perl +use ::Object::SpecialModelName; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**special_property_name** | **int** | | [optional] + +[[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/php/SwaggerClient-php/docs/StoreApi.md b/samples/client/petstore/php/SwaggerClient-php/docs/StoreApi.md new file mode 100644 index 00000000000..f8d61015d5c --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/docs/StoreApi.md @@ -0,0 +1,311 @@ +# ::StoreApi + +## Load the API package +```perl +use ::Object::StoreApi; +``` + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +[**findOrdersByStatus**](StoreApi.md#findOrdersByStatus) | **GET** /store/findByStatus | Finds orders by status +[**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status +[**getInventoryInObject**](StoreApi.md#getInventoryInObject) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' +[**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(order_id => $order_id) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Example +```perl +use Data::Dumper; + +my $api = ::StoreApi->new(); +my $order_id = order_id_example; # [string] ID of the order that needs to be deleted + +eval { + $api->deleteOrder(order_id => $order_id); +}; +if ($@) { + warn "Exception when calling StoreApi->deleteOrder: $@\n"; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order_id** | **string**| ID of the order that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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) + +# **findOrdersByStatus** +> \Swagger\Client\Model\Order[] findOrdersByStatus(status => $status) + +Finds orders by status + +A single status value can be provided as a string + +### Example +```perl +use Data::Dumper; + +# Configure API key authorization: test_api_client_id +::Configuration::api_key->{'x-test_api_client_id'} = 'YOUR_API_KEY'; +# uncomment below to setup prefix (e.g. BEARER) for API key, if needed +#::Configuration::api_key_prefix->{'x-test_api_client_id'} = "BEARER"; +# Configure API key authorization: test_api_client_secret +::Configuration::api_key->{'x-test_api_client_secret'} = 'YOUR_API_KEY'; +# uncomment below to setup prefix (e.g. BEARER) for API key, if needed +#::Configuration::api_key_prefix->{'x-test_api_client_secret'} = "BEARER"; + +my $api = ::StoreApi->new(); +my $status = placed; # [string] Status value that needs to be considered for query + +eval { + my $result = $api->findOrdersByStatus(status => $status); + print Dumper($result); +}; +if ($@) { + warn "Exception when calling StoreApi->findOrdersByStatus: $@\n"; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | **string**| Status value that needs to be considered for query | [optional] [default to placed] + +### Return type + +[**\Swagger\Client\Model\Order[]**](Order.md) + +### Authorization + +[test_api_client_id](../README.md#test_api_client_id), [test_api_client_secret](../README.md#test_api_client_secret) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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[string,int] getInventory() + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example +```perl +use Data::Dumper; + +# 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"; + +my $api = ::StoreApi->new(); + +eval { + my $result = $api->getInventory(); + print Dumper($result); +}; +if ($@) { + warn "Exception when calling StoreApi->getInventory: $@\n"; +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**map[string,int]**](map.md) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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) + +# **getInventoryInObject** +> object getInventoryInObject() + +Fake endpoint to test arbitrary object return by 'Get inventory' + +Returns an arbitrary object which is actually a map of status codes to quantities + +### Example +```perl +use Data::Dumper; + +# 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"; + +my $api = ::StoreApi->new(); + +eval { + my $result = $api->getInventoryInObject(); + print Dumper($result); +}; +if ($@) { + warn "Exception when calling StoreApi->getInventoryInObject: $@\n"; +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**object** + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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** +> \Swagger\Client\Model\Order getOrderById(order_id => $order_id) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + +### Example +```perl +use Data::Dumper; + +# Configure API key authorization: test_api_key_header +::Configuration::api_key->{'test_api_key_header'} = 'YOUR_API_KEY'; +# uncomment below to setup prefix (e.g. BEARER) for API key, if needed +#::Configuration::api_key_prefix->{'test_api_key_header'} = "BEARER"; +# Configure API key authorization: test_api_key_query +::Configuration::api_key->{'test_api_key_query'} = 'YOUR_API_KEY'; +# uncomment below to setup prefix (e.g. BEARER) for API key, if needed +#::Configuration::api_key_prefix->{'test_api_key_query'} = "BEARER"; + +my $api = ::StoreApi->new(); +my $order_id = order_id_example; # [string] ID of pet that needs to be fetched + +eval { + my $result = $api->getOrderById(order_id => $order_id); + print Dumper($result); +}; +if ($@) { + warn "Exception when calling StoreApi->getOrderById: $@\n"; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order_id** | **string**| ID of pet that needs to be fetched | + +### Return type + +[**\Swagger\Client\Model\Order**](Order.md) + +### Authorization + +[test_api_key_header](../README.md#test_api_key_header), [test_api_key_query](../README.md#test_api_key_query) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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** +> \Swagger\Client\Model\Order placeOrder(body => $body) + +Place an order for a pet + + + +### Example +```perl +use Data::Dumper; + +# Configure API key authorization: test_api_client_id +::Configuration::api_key->{'x-test_api_client_id'} = 'YOUR_API_KEY'; +# uncomment below to setup prefix (e.g. BEARER) for API key, if needed +#::Configuration::api_key_prefix->{'x-test_api_client_id'} = "BEARER"; +# Configure API key authorization: test_api_client_secret +::Configuration::api_key->{'x-test_api_client_secret'} = 'YOUR_API_KEY'; +# uncomment below to setup prefix (e.g. BEARER) for API key, if needed +#::Configuration::api_key_prefix->{'x-test_api_client_secret'} = "BEARER"; + +my $api = ::StoreApi->new(); +my $body = ::Object::\Swagger\Client\Model\Order->new(); # [\Swagger\Client\Model\Order] order placed for purchasing the pet + +eval { + my $result = $api->placeOrder(body => $body); + print Dumper($result); +}; +if ($@) { + warn "Exception when calling StoreApi->placeOrder: $@\n"; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**\Swagger\Client\Model\Order**](\Swagger\Client\Model\Order.md)| order placed for purchasing the pet | [optional] + +### Return type + +[**\Swagger\Client\Model\Order**](Order.md) + +### Authorization + +[test_api_client_id](../README.md#test_api_client_id), [test_api_client_secret](../README.md#test_api_client_secret) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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/php/SwaggerClient-php/docs/Tag.md b/samples/client/petstore/php/SwaggerClient-php/docs/Tag.md new file mode 100644 index 00000000000..fe7f063852d --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/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] +**name** | **string** | | [optional] + +[[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/php/SwaggerClient-php/docs/User.md b/samples/client/petstore/php/SwaggerClient-php/docs/User.md new file mode 100644 index 00000000000..306021a79d0 --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/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] +**username** | **string** | | [optional] +**first_name** | **string** | | [optional] +**last_name** | **string** | | [optional] +**email** | **string** | | [optional] +**password** | **string** | | [optional] +**phone** | **string** | | [optional] +**user_status** | **int** | User Status | [optional] + +[[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/php/SwaggerClient-php/docs/UserApi.md b/samples/client/petstore/php/SwaggerClient-php/docs/UserApi.md new file mode 100644 index 00000000000..8de0f56fec4 --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/docs/UserApi.md @@ -0,0 +1,371 @@ +# ::UserApi + +## Load the API package +```perl +use ::Object::UserApi; +``` + +All URIs are relative to *http://petstore.swagger.io/v2* + +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 +```perl +use Data::Dumper; + +my $api = ::UserApi->new(); +my $body = ::Object::\Swagger\Client\Model\User->new(); # [\Swagger\Client\Model\User] Created user object + +eval { + $api->createUser(body => $body); +}; +if ($@) { + warn "Exception when calling UserApi->createUser: $@\n"; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**\Swagger\Client\Model\User**](\Swagger\Client\Model\User.md)| Created user object | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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 +```perl +use Data::Dumper; + +my $api = ::UserApi->new(); +my $body = (::Object::\Swagger\Client\Model\User[]->new()); # [\Swagger\Client\Model\User[]] List of user object + +eval { + $api->createUsersWithArrayInput(body => $body); +}; +if ($@) { + warn "Exception when calling UserApi->createUsersWithArrayInput: $@\n"; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**\Swagger\Client\Model\User[]**](User.md)| List of user object | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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 +```perl +use Data::Dumper; + +my $api = ::UserApi->new(); +my $body = (::Object::\Swagger\Client\Model\User[]->new()); # [\Swagger\Client\Model\User[]] List of user object + +eval { + $api->createUsersWithListInput(body => $body); +}; +if ($@) { + warn "Exception when calling UserApi->createUsersWithListInput: $@\n"; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**\Swagger\Client\Model\User[]**](User.md)| List of user object | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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 +```perl +use Data::Dumper; + +# Configure HTTP basic authorization: test_http_basic +::Configuration::username = 'YOUR_USERNAME'; +::Configuration::password = 'YOUR_PASSWORD'; + +my $api = ::UserApi->new(); +my $username = username_example; # [string] The name that needs to be deleted + +eval { + $api->deleteUser(username => $username); +}; +if ($@) { + warn "Exception when calling UserApi->deleteUser: $@\n"; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **string**| The name that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +[test_http_basic](../README.md#test_http_basic) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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** +> \Swagger\Client\Model\User getUserByName(username => $username) + +Get user by user name + + + +### Example +```perl +use Data::Dumper; + +my $api = ::UserApi->new(); +my $username = username_example; # [string] The name that needs to be fetched. Use user1 for testing. + +eval { + my $result = $api->getUserByName(username => $username); + print Dumper($result); +}; +if ($@) { + warn "Exception when calling UserApi->getUserByName: $@\n"; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **string**| The name that needs to be fetched. Use user1 for testing. | + +### Return type + +[**\Swagger\Client\Model\User**](User.md) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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 +```perl +use Data::Dumper; + +my $api = ::UserApi->new(); +my $username = username_example; # [string] The user name for login +my $password = password_example; # [string] The password for login in clear text + +eval { + my $result = $api->loginUser(username => $username, password => $password); + print Dumper($result); +}; +if ($@) { + warn "Exception when calling UserApi->loginUser: $@\n"; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **string**| The user name for login | [optional] + **password** | **string**| The password for login in clear text | [optional] + +### Return type + +**string** + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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 +```perl +use Data::Dumper; + +my $api = ::UserApi->new(); + +eval { + $api->logoutUser(); +}; +if ($@) { + warn "Exception when calling UserApi->logoutUser: $@\n"; +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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 +```perl +use Data::Dumper; + +my $api = ::UserApi->new(); +my $username = username_example; # [string] name that need to be deleted +my $body = ::Object::\Swagger\Client\Model\User->new(); # [\Swagger\Client\Model\User] Updated user object + +eval { + $api->updateUser(username => $username, body => $body); +}; +if ($@) { + warn "Exception when calling UserApi->updateUser: $@\n"; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **string**| name that need to be deleted | + **body** | [**\Swagger\Client\Model\User**](\Swagger\Client\Model\User.md)| Updated user object | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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/php/SwaggerClient-php/lib/Api/UserApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php index 298cc1bba50..259581ee2f5 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php @@ -397,6 +397,11 @@ class UserApi $httpBody = $formParams; // for HTTP post (form) } + // this endpoint requires HTTP basic authentication + if (strlen($this->apiClient->getConfig()->getUsername()) !== 0 or strlen($this->apiClient->getConfig()->getPassword()) !== 0) { + $headerParams['Authorization'] = 'Basic ' . base64_encode($this->apiClient->getConfig()->getUsername() . ":" . $this->apiClient->getConfig()->getPassword()); + } + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( From 7b31dabe77ba01de1dc448d3a30730985f34b77c Mon Sep 17 00:00:00 2001 From: wing328 Date: Wed, 16 Mar 2016 14:58:19 +0800 Subject: [PATCH 2/4] fix perl, ruby auth doc in readme --- .../src/main/resources/perl/README.mustache | 2 +- .../src/main/resources/ruby/README.mustache | 2 +- samples/client/petstore/perl/README.md | 6 +- .../perl/lib/WWW/SwaggerClient/Role.pm | 4 +- samples/client/petstore/ruby/README.md | 6 +- samples/client/petstore/ruby/docs/UserApi.md | 18 ++++++ samples/client/petstore/ruby/git_push.sh | 6 +- .../petstore/ruby/lib/petstore/api/pet_api.rb | 6 +- .../ruby/lib/petstore/api/store_api.rb | 2 +- .../ruby/lib/petstore/configuration.rb | 49 ++++++-------- .../petstore/models/inline_response_200.rb | 64 +++++++++---------- 11 files changed, 88 insertions(+), 77 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/perl/README.mustache b/modules/swagger-codegen/src/main/resources/perl/README.mustache index c2a0f8f3f2b..771dd76b8b1 100644 --- a/modules/swagger-codegen/src/main/resources/perl/README.mustache +++ b/modules/swagger-codegen/src/main/resources/perl/README.mustache @@ -260,7 +260,7 @@ Class | Method | HTTP request | Description - **Flow**: {{{flow}}} - **Authorizatoin URL**: {{{authorizationUrl}}} - **Scopes**: {{^scopes}}N/A{{/scopes}} -{{#scopes}} - **{{{scope}}}**: {{{description}}} +{{#scopes}} - **{{{scope}}}**: {{{description}}} {{/scopes}} {{/isOAuth}} diff --git a/modules/swagger-codegen/src/main/resources/ruby/README.mustache b/modules/swagger-codegen/src/main/resources/ruby/README.mustache index c9a21277c77..d55fe28ad25 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/README.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/README.mustache @@ -100,7 +100,7 @@ Class | Method | HTTP request | Description - **Flow**: {{flow}} - **Authorizatoin URL**: {{authorizationUrl}} - **Scopes**: {{^scopes}}N/A{{/scopes}} -{{#scopes}}-- {{scope}}: {{description}} +{{#scopes}} - {{scope}}: {{description}} {{/scopes}} {{/isOAuth}} diff --git a/samples/client/petstore/perl/README.md b/samples/client/petstore/perl/README.md index 3758d282ddd..3f87edd1ec5 100644 --- a/samples/client/petstore/perl/README.md +++ b/samples/client/petstore/perl/README.md @@ -8,7 +8,7 @@ WWW::SwaggerClient::Role - a Moose role for the Swagger Petstore Automatically generated by the Perl Swagger Codegen project: -- Build date: 2016-03-13T22:43:11.863+08:00 +- Build date: 2016-03-16T14:57:20.078+08:00 - Build package: class io.swagger.codegen.languages.PerlClientCodegen - Codegen version: @@ -329,8 +329,8 @@ Class | Method | HTTP request | Description - **Flow**: implicit - **Authorizatoin 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 diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm index ab84d287c40..99a175ea451 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm @@ -37,7 +37,7 @@ has version_info => ( is => 'ro', default => sub { { app_name => 'Swagger Petstore', app_version => '1.0.0', - generated_date => '2016-03-13T22:43:11.863+08:00', + generated_date => '2016-03-16T14:57:20.078+08:00', generator_class => 'class io.swagger.codegen.languages.PerlClientCodegen', } }, documentation => 'Information about the application version and the codegen codebase version' @@ -103,7 +103,7 @@ Automatically generated by the Perl Swagger Codegen project: =over 4 -=item Build date: 2016-03-13T22:43:11.863+08:00 +=item Build date: 2016-03-16T14:57:20.078+08:00 =item Build package: class io.swagger.codegen.languages.PerlClientCodegen diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index 7cbfdadfc67..bb77c31c8ea 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -6,7 +6,7 @@ Version: 1.0.0 Automatically generated by the Ruby Swagger Codegen project: -- Build date: 2016-03-14T21:56:19.858+08:00 +- Build date: 2016-03-16T14:58:08.710+08:00 - Build package: class io.swagger.codegen.languages.RubyClientCodegen ## Installation @@ -159,6 +159,6 @@ Class | Method | HTTP request | Description - **Flow**: implicit - **Authorizatoin 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 diff --git a/samples/client/petstore/ruby/docs/UserApi.md b/samples/client/petstore/ruby/docs/UserApi.md index 284c5e3a314..c629e696410 100644 --- a/samples/client/petstore/ruby/docs/UserApi.md +++ b/samples/client/petstore/ruby/docs/UserApi.md @@ -23,6 +23,8 @@ This can only be done by the logged in user. ### Example ```ruby +require 'petstore' + api = Petstore::UserApi.new opts = { @@ -66,6 +68,8 @@ Creates list of users with given input array ### Example ```ruby +require 'petstore' + api = Petstore::UserApi.new opts = { @@ -109,6 +113,8 @@ Creates list of users with given input array ### Example ```ruby +require 'petstore' + api = Petstore::UserApi.new opts = { @@ -152,6 +158,8 @@ This can only be done by the logged in user. ### Example ```ruby +require 'petstore' + Petstore.configure do |config| # Configure HTTP basic authorization: test_http_basic config.username = 'YOUR USERNAME' @@ -200,6 +208,8 @@ Get user by user name ### Example ```ruby +require 'petstore' + api = Petstore::UserApi.new username = "username_example" # [String] The name that needs to be fetched. Use user1 for testing. @@ -207,6 +217,7 @@ username = "username_example" # [String] The name that needs to be fetched. Use begin result = api.get_user_by_name(username) + p result rescue Petstore::ApiError => e puts "Exception when calling get_user_by_name: #{e}" end @@ -242,6 +253,8 @@ Logs user into the system ### Example ```ruby +require 'petstore' + api = Petstore::UserApi.new opts = { @@ -251,6 +264,7 @@ opts = { begin result = api.login_user(opts) + p result rescue Petstore::ApiError => e puts "Exception when calling login_user: #{e}" end @@ -287,6 +301,8 @@ Logs out current logged in user session ### Example ```ruby +require 'petstore' + api = Petstore::UserApi.new begin @@ -323,6 +339,8 @@ This can only be done by the logged in user. ### Example ```ruby +require 'petstore' + api = Petstore::UserApi.new username = "username_example" # [String] name that need to be deleted diff --git a/samples/client/petstore/ruby/git_push.sh b/samples/client/petstore/ruby/git_push.sh index 6ca091b49d9..1a36388db02 100644 --- a/samples/client/petstore/ruby/git_push.sh +++ b/samples/client/petstore/ruby/git_push.sh @@ -8,17 +8,17 @@ git_repo_id=$2 release_note=$3 if [ "$git_user_id" = "" ]; then - git_user_id="" + git_user_id="YOUR_GIT_USR_ID" echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" fi if [ "$git_repo_id" = "" ]; then - git_repo_id="" + git_repo_id="YOUR_GIT_REPO_ID" echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" fi if [ "$release_note" = "" ]; then - release_note="" + release_note="Minor update" echo "[INFO] No command line input provided. Set \$release_note to $release_note" fi diff --git a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb index 4a5d45d766c..29f631a983e 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb @@ -360,7 +360,7 @@ module Petstore # http body (model) post_body = nil - auth_names = ['petstore_auth', 'api_key'] + auth_names = ['api_key', 'petstore_auth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, @@ -420,7 +420,7 @@ module Petstore # http body (model) post_body = nil - auth_names = ['petstore_auth', 'api_key'] + auth_names = ['api_key', 'petstore_auth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, @@ -480,7 +480,7 @@ module Petstore # http body (model) post_body = nil - auth_names = ['petstore_auth', 'api_key'] + auth_names = ['api_key', 'petstore_auth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, diff --git a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb index 7bdfd013bf6..11bdfaadf62 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb @@ -301,7 +301,7 @@ module Petstore # http body (model) post_body = nil - auth_names = ['test_api_key_query', 'test_api_key_header'] + auth_names = ['test_api_key_header', 'test_api_key_query'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, diff --git a/samples/client/petstore/ruby/lib/petstore/configuration.rb b/samples/client/petstore/ruby/lib/petstore/configuration.rb index 94a1b566a1e..5125ebe5960 100644 --- a/samples/client/petstore/ruby/lib/petstore/configuration.rb +++ b/samples/client/petstore/ruby/lib/petstore/configuration.rb @@ -157,33 +157,12 @@ module Petstore # Returns Auth Settings hash for api client. def auth_settings { - 'petstore_auth' => - { - type: 'oauth2', - in: 'header', - key: 'Authorization', - value: "Bearer #{access_token}" - }, - 'test_api_client_id' => + 'test_api_key_header' => { type: 'api_key', in: 'header', - key: 'x-test_api_client_id', - value: api_key_with_prefix('x-test_api_client_id') - }, - 'test_http_basic' => - { - type: 'basic', - in: 'header', - key: 'Authorization', - value: basic_auth_token - }, - 'test_api_client_secret' => - { - type: 'api_key', - in: 'header', - key: 'x-test_api_client_secret', - value: api_key_with_prefix('x-test_api_client_secret') + key: 'test_api_key_header', + value: api_key_with_prefix('test_api_key_header') }, 'api_key' => { @@ -199,6 +178,20 @@ module Petstore key: 'Authorization', value: basic_auth_token }, + 'test_api_client_secret' => + { + type: 'api_key', + in: 'header', + key: 'x-test_api_client_secret', + value: api_key_with_prefix('x-test_api_client_secret') + }, + 'test_api_client_id' => + { + type: 'api_key', + in: 'header', + key: 'x-test_api_client_id', + value: api_key_with_prefix('x-test_api_client_id') + }, 'test_api_key_query' => { type: 'api_key', @@ -206,12 +199,12 @@ module Petstore key: 'test_api_key_query', value: api_key_with_prefix('test_api_key_query') }, - 'test_api_key_header' => + 'petstore_auth' => { - type: 'api_key', + type: 'oauth2', in: 'header', - key: 'test_api_key_header', - value: api_key_with_prefix('test_api_key_header') + key: 'Authorization', + value: "Bearer #{access_token}" }, } end diff --git a/samples/client/petstore/ruby/lib/petstore/models/inline_response_200.rb b/samples/client/petstore/ruby/lib/petstore/models/inline_response_200.rb index a793250e45b..190170f18eb 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/inline_response_200.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/inline_response_200.rb @@ -18,34 +18,34 @@ require 'date' module Petstore class InlineResponse200 - attr_accessor :photo_urls - - attr_accessor :name + attr_accessor :tags attr_accessor :id attr_accessor :category - attr_accessor :tags - # pet status in the store attr_accessor :status + attr_accessor :name + + attr_accessor :photo_urls + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { - :'photo_urls' => :'photoUrls', - - :'name' => :'name', + :'tags' => :'tags', :'id' => :'id', :'category' => :'category', - :'tags' => :'tags', + :'status' => :'status', - :'status' => :'status' + :'name' => :'name', + + :'photo_urls' => :'photoUrls' } end @@ -53,12 +53,12 @@ module Petstore # Attribute type mapping. def self.swagger_types { - :'photo_urls' => :'Array', - :'name' => :'String', + :'tags' => :'Array', :'id' => :'Integer', :'category' => :'Object', - :'tags' => :'Array', - :'status' => :'String' + :'status' => :'String', + :'name' => :'String', + :'photo_urls' => :'Array' } end @@ -70,16 +70,12 @@ module Petstore attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} - if attributes[:'photoUrls'] - if (value = attributes[:'photoUrls']).is_a?(Array) - self.photo_urls = value + if attributes[:'tags'] + if (value = attributes[:'tags']).is_a?(Array) + self.tags = value end end - if attributes[:'name'] - self.name = attributes[:'name'] - end - if attributes[:'id'] self.id = attributes[:'id'] end @@ -88,16 +84,20 @@ module Petstore self.category = attributes[:'category'] end - if attributes[:'tags'] - if (value = attributes[:'tags']).is_a?(Array) - self.tags = value - end - end - if attributes[:'status'] self.status = attributes[:'status'] end + if attributes[:'name'] + self.name = attributes[:'name'] + end + + if attributes[:'photoUrls'] + if (value = attributes[:'photoUrls']).is_a?(Array) + self.photo_urls = value + end + end + end # Custom attribute writer method checking allowed values (enum). @@ -113,12 +113,12 @@ module Petstore def ==(o) return true if self.equal?(o) self.class == o.class && - photo_urls == o.photo_urls && - name == o.name && + tags == o.tags && id == o.id && category == o.category && - tags == o.tags && - status == o.status + status == o.status && + name == o.name && + photo_urls == o.photo_urls end # @see the `==` method @@ -128,7 +128,7 @@ module Petstore # Calculate hash code according to all attributes. def hash - [photo_urls, name, id, category, tags, status].hash + [tags, id, category, status, name, photo_urls].hash end # build the object from hash From c101c1204ec19ddb6d05c7bb5387b8d95942ed42 Mon Sep 17 00:00:00 2001 From: wing328 Date: Wed, 16 Mar 2016 16:14:04 +0800 Subject: [PATCH 3/4] add php documentation --- .../io/swagger/codegen/CodegenOperation.java | 1 + .../io/swagger/codegen/DefaultCodegen.java | 2 +- .../codegen/languages/PhpClientCodegen.java | 10 +- .../src/main/resources/php/README.mustache | 2 +- .../src/main/resources/php/api_doc.mustache | 72 ++++ .../src/main/resources/php/model_doc.mustache | 11 + samples/client/petstore/perl/README.md | 2 +- .../perl/lib/WWW/SwaggerClient/Role.pm | 4 +- .../petstore/php/SwaggerClient-php/README.md | 97 +++++- .../php/SwaggerClient-php/composer.json | 2 +- .../php/SwaggerClient-php/docs/Category.md | 7 +- .../docs/InlineResponse200.md | 7 +- .../php/SwaggerClient-php/docs/ModelReturn.md | 7 +- .../php/SwaggerClient-php/docs/Name.md | 7 +- .../php/SwaggerClient-php/docs/Order.md | 7 +- .../php/SwaggerClient-php/docs/Pet.md | 7 +- .../php/SwaggerClient-php/docs/PetApi.md | 326 +++++++++--------- .../docs/SpecialModelName.md | 7 +- .../php/SwaggerClient-php/docs/StoreApi.md | 199 +++++------ .../php/SwaggerClient-php/docs/Tag.md | 7 +- .../php/SwaggerClient-php/docs/User.md | 7 +- .../php/SwaggerClient-php/docs/UserApi.md | 185 +++++----- .../lib/ObjectSerializer.php | 12 +- 23 files changed, 571 insertions(+), 417 deletions(-) create mode 100644 modules/swagger-codegen/src/main/resources/php/api_doc.mustache create mode 100644 modules/swagger-codegen/src/main/resources/php/model_doc.mustache diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java index 956e906b44f..120465bca67 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java @@ -32,6 +32,7 @@ public class CodegenOperation { public ExternalDocs externalDocs; public Map vendorExtensions; public String nickname; // legacy support + public String operationIdLowerCase; // for mardown documentation /** * Check if there's at least one parameter diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java index 65ed6a456ef..86bb99598ec 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java @@ -1575,7 +1575,6 @@ public class DefaultCodegen { // legacy support op.nickname = op.operationId; - if (op.allParams.size() > 0) { op.hasParams = true; } @@ -2075,6 +2074,7 @@ public class DefaultCodegen { LOGGER.warn("generated unique operationId `" + uniqueName + "`"); } co.operationId = uniqueName; + co.operationIdLowerCase = uniqueName.toLowerCase(); opList.add(co); co.baseName = tag; } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java index b8a891e4c66..e0dfe6cfb2a 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java @@ -507,12 +507,12 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig { type = p.dataType; } - if ("String".equals(type)) { + if ("String".equalsIgnoreCase(type)) { if (example == null) { example = p.paramName + "_example"; } example = "\"" + escapeText(example) + "\""; - } else if ("Integer".equals(type)) { + } else if ("Integer".equals(type) || "int".equals(type)) { if (example == null) { example = "56"; } @@ -533,15 +533,17 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig { if (example == null) { example = "2013-10-20"; } - example = "new DateTime(\"" + escapeText(example) + "\")"; + example = "new \\DateTime(\"" + escapeText(example) + "\")"; } else if ("DateTime".equals(type)) { if (example == null) { example = "2013-10-20T19:20:30+01:00"; } - example = "new DateTime(\"" + escapeText(example) + "\")"; + example = "new \\DateTime(\"" + escapeText(example) + "\")"; } else if (!languageSpecificPrimitives.contains(type)) { // type is a model class, e.g. User example = "new " + type + "()"; + } else { + LOGGER.warn("Type " + type + " not handled properly in setParameterExampleValue"); } if (example == null) { diff --git a/modules/swagger-codegen/src/main/resources/php/README.mustache b/modules/swagger-codegen/src/main/resources/php/README.mustache index 00146f48944..12b78b3f7ed 100644 --- a/modules/swagger-codegen/src/main/resources/php/README.mustache +++ b/modules/swagger-codegen/src/main/resources/php/README.mustache @@ -46,7 +46,7 @@ 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 diff --git a/modules/swagger-codegen/src/main/resources/php/api_doc.mustache b/modules/swagger-codegen/src/main/resources/php/api_doc.mustache new file mode 100644 index 00000000000..a4377003803 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/php/api_doc.mustache @@ -0,0 +1,72 @@ +# {{invokerPackage}}\{{classname}}{{#description}} +{{description}}{{/description}} + +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}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) + +{{{summary}}}{{#notes}} + +{{{notes}}}{{/notes}} + +### Example +```php +setUsername('YOUR_USERNAME'); +{{{invokerPackage}}}::getDefaultConfiguration->setPassword('YOUR_PASSWORD');{{/isBasic}}{{#isApiKey}} +// Configure API key authorization: {{{name}}} +{{{invokerPackage}}}::getDefaultConfiguration->setApiKey('{{{keyParamName}}}', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +// {{{invokerPackage}}}::getDefaultConfiguration->setApiKeyPrefix('{{{keyParamName}}}', 'BEARER');{{/isApiKey}}{{#isOAuth}} +// Configure OAuth2 access token for authorization: {{{name}}} +{{{invokerPackage}}}::getDefaultConfiguration->setAccessToken('YOUR_ACCESS_TOKEN');{{/isOAuth}}{{/authMethods}} +{{/hasAuthMethods}} + +$api_instance = new {{invokerPackage}}\{{classname}}(); +{{#allParams}}${{paramName}} = {{{example}}}; // {{{dataType}}} | {{{description}}} +{{/allParams}} + +try { + {{#returnType}}$result = {{/returnType}}$api_instance->{{{operationId}}}({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}} + print_r($result);{{/returnType}} +} catch (Exception $e) { + echo 'Exception when calling {{classname}}->{{operationId}}: ', $e->getMessage(), "\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 reuqest 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/php/model_doc.mustache b/modules/swagger-codegen/src/main/resources/php/model_doc.mustache new file mode 100644 index 00000000000..569550df372 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/php/model_doc.mustache @@ -0,0 +1,11 @@ +{{#models}}{{#model}}# {{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}} +{{/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/perl/README.md b/samples/client/petstore/perl/README.md index 3f87edd1ec5..772a3e556ff 100644 --- a/samples/client/petstore/perl/README.md +++ b/samples/client/petstore/perl/README.md @@ -8,7 +8,7 @@ WWW::SwaggerClient::Role - a Moose role for the Swagger Petstore Automatically generated by the Perl Swagger Codegen project: -- Build date: 2016-03-16T14:57:20.078+08:00 +- Build date: 2016-03-16T15:35:49.140+08:00 - Build package: class io.swagger.codegen.languages.PerlClientCodegen - Codegen version: diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm index 99a175ea451..83c93817626 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm @@ -37,7 +37,7 @@ has version_info => ( is => 'ro', default => sub { { app_name => 'Swagger Petstore', app_version => '1.0.0', - generated_date => '2016-03-16T14:57:20.078+08:00', + generated_date => '2016-03-16T15:35:49.140+08:00', generator_class => 'class io.swagger.codegen.languages.PerlClientCodegen', } }, documentation => 'Information about the application version and the codegen codebase version' @@ -103,7 +103,7 @@ Automatically generated by the Perl Swagger Codegen project: =over 4 -=item Build date: 2016-03-16T14:57:20.078+08:00 +=item Build date: 2016-03-16T15:35:49.140+08:00 =item Build package: class io.swagger.codegen.languages.PerlClientCodegen diff --git a/samples/client/petstore/php/SwaggerClient-php/README.md b/samples/client/petstore/php/SwaggerClient-php/README.md index 0566cb0af39..4a0f064aada 100644 --- a/samples/client/petstore/php/SwaggerClient-php/README.md +++ b/samples/client/petstore/php/SwaggerClient-php/README.md @@ -14,11 +14,11 @@ You can install the bindings via [Composer](http://getcomposer.org/). Add this t "repositories": [ { "type": "git", - "url": "https://github.com/swagger/swagger-client.git" + "url": "https://github.com/YOUR_GIT_USR_ID/YOUR_GIT_REPO_ID.git" } ], "require": { - "swagger/swagger-client": "*@dev" + "YOUR_GIT_USR_ID/YOUR_GIT_REPO_ID": "*@dev" } } ``` @@ -40,6 +40,99 @@ composer install ./vendor/bin/phpunit lib/Tests ``` +## Documentation for API Endpoints + +All URIs are relative to *http://petstore.swagger.io/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*PetApi* | [**addPet**](docs/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store +*PetApi* | [**addPetUsingByteArray**](docs/PetApi.md#addpetusingbytearray) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding 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* | [**getPetByIdInObject**](docs/PetApi.md#getpetbyidinobject) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' +*PetApi* | [**petPetIdtestingByteArraytrueGet**](docs/PetApi.md#petpetidtestingbytearraytrueget) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by '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* | [**findOrdersByStatus**](docs/StoreApi.md#findordersbystatus) | **GET** /store/findByStatus | Finds orders by status +*StoreApi* | [**getInventory**](docs/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**getInventoryInObject**](docs/StoreApi.md#getinventoryinobject) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' +*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 + + - [Category](docs/Category.md) + - [InlineResponse200](docs/InlineResponse200.md) + - [ModelReturn](docs/ModelReturn.md) + - [Name](docs/Name.md) + - [Order](docs/Order.md) + - [Pet](docs/Pet.md) + - [SpecialModelName](docs/SpecialModelName.md) + - [Tag](docs/Tag.md) + - [User](docs/User.md) + + +## Documentation For Authorization + + +## test_api_key_header + +- **Type**: API key +- **API key parameter name**: test_api_key_header +- **Location**: HTTP header + +## api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + +## test_http_basic + +- **Type**: HTTP basic authentication + +## test_api_client_secret + +- **Type**: API key +- **API key parameter name**: x-test_api_client_secret +- **Location**: HTTP header + +## test_api_client_id + +- **Type**: API key +- **API key parameter name**: x-test_api_client_id +- **Location**: HTTP header + +## test_api_key_query + +- **Type**: API key +- **API key parameter name**: test_api_key_query +- **Location**: URL query string + +## petstore_auth + +- **Type**: OAuth +- **Flow**: implicit +- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - **write:pets**: modify pets in your account + - **read:pets**: read your pets + + ## Author apiteam@swagger.io diff --git a/samples/client/petstore/php/SwaggerClient-php/composer.json b/samples/client/petstore/php/SwaggerClient-php/composer.json index 3b432d83b92..3889aee8a36 100644 --- a/samples/client/petstore/php/SwaggerClient-php/composer.json +++ b/samples/client/petstore/php/SwaggerClient-php/composer.json @@ -1,5 +1,5 @@ { - "name": "swagger/swagger-client", + "name": "YOUR_GIT_USR_ID/YOUR_GIT_REPO_ID", "version": "1.0.0", "description": "", "keywords": [ diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/Category.md b/samples/client/petstore/php/SwaggerClient-php/docs/Category.md index 1f57eb29678..80aef312e5e 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/Category.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Category.md @@ -1,9 +1,4 @@ -# ::Object::Category - -## Load the model package -```perl -use ::Object::Category; -``` +# Category ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/InlineResponse200.md b/samples/client/petstore/php/SwaggerClient-php/docs/InlineResponse200.md index 116f6808b07..1c0b9237453 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/InlineResponse200.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/InlineResponse200.md @@ -1,9 +1,4 @@ -# ::Object::InlineResponse200 - -## Load the model package -```perl -use ::Object::InlineResponse200; -``` +# InlineResponse200 ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/ModelReturn.md b/samples/client/petstore/php/SwaggerClient-php/docs/ModelReturn.md index 1d6a183fecb..9adb62e1e12 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/ModelReturn.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/ModelReturn.md @@ -1,9 +1,4 @@ -# ::Object::ModelReturn - -## Load the model package -```perl -use ::Object::ModelReturn; -``` +# ModelReturn ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/Name.md b/samples/client/petstore/php/SwaggerClient-php/docs/Name.md index 2c95721327a..b9842d31abf 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/Name.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Name.md @@ -1,9 +1,4 @@ -# ::Object::Name - -## Load the model package -```perl -use ::Object::Name; -``` +# Name ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/Order.md b/samples/client/petstore/php/SwaggerClient-php/docs/Order.md index 79c68cff275..8932478b022 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/Order.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Order.md @@ -1,9 +1,4 @@ -# ::Object::Order - -## Load the model package -```perl -use ::Object::Order; -``` +# Order ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/Pet.md b/samples/client/petstore/php/SwaggerClient-php/docs/Pet.md index a97841d399b..4525fe7d776 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/Pet.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Pet.md @@ -1,9 +1,4 @@ -# ::Object::Pet - -## Load the model package -```perl -use ::Object::Pet; -``` +# Pet ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md b/samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md index 946074e7687..db95061a841 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md @@ -1,9 +1,4 @@ -# ::PetApi - -## Load the API package -```perl -use ::Object::PetApi; -``` +# Swagger\Client\PetApi All URIs are relative to *http://petstore.swagger.io/v2* @@ -23,28 +18,29 @@ Method | HTTP request | Description # **addPet** -> addPet(body => $body) +> addPet($body) Add a new pet to the store ### Example -```perl -use Data::Dumper; +```php +setAccessToken('YOUR_ACCESS_TOKEN'); -my $api = ::PetApi->new(); -my $body = ::Object::\Swagger\Client\Model\Pet->new(); # [\Swagger\Client\Model\Pet] Pet object that needs to be added to the store +$api_instance = new Swagger\Client\PetApi(); +$body = new \Swagger\Client\Model\Pet(); // \Swagger\Client\Model\Pet | Pet object that needs to be added to the store -eval { - $api->addPet(body => $body); -}; -if ($@) { - warn "Exception when calling PetApi->addPet: $@\n"; +try { + $api_instance->addPet($body); +} catch (Exception $e) { + echo 'Exception when calling PetApi->addPet: ', $e->getMessage(), "\n"; } +?> ``` ### Parameters @@ -69,28 +65,29 @@ 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) # **addPetUsingByteArray** -> addPetUsingByteArray(body => $body) +> addPetUsingByteArray($body) Fake endpoint to test byte array in body parameter for adding a new pet to the store ### Example -```perl -use Data::Dumper; +```php +setAccessToken('YOUR_ACCESS_TOKEN'); -my $api = ::PetApi->new(); -my $body = ::Object::string->new(); # [string] Pet object in the form of byte array +$api_instance = new Swagger\Client\PetApi(); +$body = "B"; // string | Pet object in the form of byte array -eval { - $api->addPetUsingByteArray(body => $body); -}; -if ($@) { - warn "Exception when calling PetApi->addPetUsingByteArray: $@\n"; +try { + $api_instance->addPetUsingByteArray($body); +} catch (Exception $e) { + echo 'Exception when calling PetApi->addPetUsingByteArray: ', $e->getMessage(), "\n"; } +?> ``` ### Parameters @@ -115,29 +112,30 @@ 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(pet_id => $pet_id, api_key => $api_key) +> deletePet($pet_id, $api_key) Deletes a pet ### Example -```perl -use Data::Dumper; +```php +setAccessToken('YOUR_ACCESS_TOKEN'); -my $api = ::PetApi->new(); -my $pet_id = 789; # [int] Pet id to delete -my $api_key = api_key_example; # [string] +$api_instance = new Swagger\Client\PetApi(); +$pet_id = 789; // int | Pet id to delete +$api_key = "api_key_example"; // string | -eval { - $api->deletePet(pet_id => $pet_id, api_key => $api_key); -}; -if ($@) { - warn "Exception when calling PetApi->deletePet: $@\n"; +try { + $api_instance->deletePet($pet_id, $api_key); +} catch (Exception $e) { + echo 'Exception when calling PetApi->deletePet: ', $e->getMessage(), "\n"; } +?> ``` ### Parameters @@ -163,29 +161,30 @@ 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** -> \Swagger\Client\Model\Pet[] findPetsByStatus(status => $status) +> \Swagger\Client\Model\Pet[] findPetsByStatus($status) Finds Pets by status Multiple status values can be provided with comma separated strings ### Example -```perl -use Data::Dumper; +```php +setAccessToken('YOUR_ACCESS_TOKEN'); -my $api = ::PetApi->new(); -my $status = (array(available)); # [string[]] Status values that need to be considered for query +$api_instance = new Swagger\Client\PetApi(); +$status = array("available"); // string[] | Status values that need to be considered for query -eval { - my $result = $api->findPetsByStatus(status => $status); - print Dumper($result); -}; -if ($@) { - warn "Exception when calling PetApi->findPetsByStatus: $@\n"; +try { + $result = $api_instance->findPetsByStatus($status); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PetApi->findPetsByStatus: ', $e->getMessage(), "\n"; } +?> ``` ### Parameters @@ -210,29 +209,30 @@ 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** -> \Swagger\Client\Model\Pet[] findPetsByTags(tags => $tags) +> \Swagger\Client\Model\Pet[] findPetsByTags($tags) Finds Pets by tags Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. ### Example -```perl -use Data::Dumper; +```php +setAccessToken('YOUR_ACCESS_TOKEN'); -my $api = ::PetApi->new(); -my $tags = (nil); # [string[]] Tags to filter by +$api_instance = new Swagger\Client\PetApi(); +$tags = array("tags_example"); // string[] | Tags to filter by -eval { - my $result = $api->findPetsByTags(tags => $tags); - print Dumper($result); -}; -if ($@) { - warn "Exception when calling PetApi->findPetsByTags: $@\n"; +try { + $result = $api_instance->findPetsByTags($tags); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PetApi->findPetsByTags: ', $e->getMessage(), "\n"; } +?> ``` ### Parameters @@ -257,33 +257,34 @@ 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** -> \Swagger\Client\Model\Pet getPetById(pet_id => $pet_id) +> \Swagger\Client\Model\Pet getPetById($pet_id) Find pet by ID Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions ### Example -```perl -use Data::Dumper; +```php +{'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"; -# Configure OAuth2 access token for authorization: petstore_auth -::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; +// Configure API key authorization: api_key +Swagger\Client::getDefaultConfiguration->setApiKey('api_key', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +// Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('api_key', 'BEARER'); +// Configure OAuth2 access token for authorization: petstore_auth +Swagger\Client::getDefaultConfiguration->setAccessToken('YOUR_ACCESS_TOKEN'); -my $api = ::PetApi->new(); -my $pet_id = 789; # [int] ID of pet that needs to be fetched +$api_instance = new Swagger\Client\PetApi(); +$pet_id = 789; // int | ID of pet that needs to be fetched -eval { - my $result = $api->getPetById(pet_id => $pet_id); - print Dumper($result); -}; -if ($@) { - warn "Exception when calling PetApi->getPetById: $@\n"; +try { + $result = $api_instance->getPetById($pet_id); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PetApi->getPetById: ', $e->getMessage(), "\n"; } +?> ``` ### Parameters @@ -308,33 +309,34 @@ 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) # **getPetByIdInObject** -> \Swagger\Client\Model\InlineResponse200 getPetByIdInObject(pet_id => $pet_id) +> \Swagger\Client\Model\InlineResponse200 getPetByIdInObject($pet_id) Fake endpoint to test inline arbitrary object return by 'Find pet by ID' Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions ### Example -```perl -use Data::Dumper; +```php +{'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"; -# Configure OAuth2 access token for authorization: petstore_auth -::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; +// Configure API key authorization: api_key +Swagger\Client::getDefaultConfiguration->setApiKey('api_key', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +// Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('api_key', 'BEARER'); +// Configure OAuth2 access token for authorization: petstore_auth +Swagger\Client::getDefaultConfiguration->setAccessToken('YOUR_ACCESS_TOKEN'); -my $api = ::PetApi->new(); -my $pet_id = 789; # [int] ID of pet that needs to be fetched +$api_instance = new Swagger\Client\PetApi(); +$pet_id = 789; // int | ID of pet that needs to be fetched -eval { - my $result = $api->getPetByIdInObject(pet_id => $pet_id); - print Dumper($result); -}; -if ($@) { - warn "Exception when calling PetApi->getPetByIdInObject: $@\n"; +try { + $result = $api_instance->getPetByIdInObject($pet_id); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PetApi->getPetByIdInObject: ', $e->getMessage(), "\n"; } +?> ``` ### Parameters @@ -359,33 +361,34 @@ 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) # **petPetIdtestingByteArraytrueGet** -> string petPetIdtestingByteArraytrueGet(pet_id => $pet_id) +> string petPetIdtestingByteArraytrueGet($pet_id) Fake endpoint to test byte array return by 'Find pet by ID' Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions ### Example -```perl -use Data::Dumper; +```php +{'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"; -# Configure OAuth2 access token for authorization: petstore_auth -::Configuration::access_token = 'YOUR_ACCESS_TOKEN'; +// Configure API key authorization: api_key +Swagger\Client::getDefaultConfiguration->setApiKey('api_key', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +// Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('api_key', 'BEARER'); +// Configure OAuth2 access token for authorization: petstore_auth +Swagger\Client::getDefaultConfiguration->setAccessToken('YOUR_ACCESS_TOKEN'); -my $api = ::PetApi->new(); -my $pet_id = 789; # [int] ID of pet that needs to be fetched +$api_instance = new Swagger\Client\PetApi(); +$pet_id = 789; // int | ID of pet that needs to be fetched -eval { - my $result = $api->petPetIdtestingByteArraytrueGet(pet_id => $pet_id); - print Dumper($result); -}; -if ($@) { - warn "Exception when calling PetApi->petPetIdtestingByteArraytrueGet: $@\n"; +try { + $result = $api_instance->petPetIdtestingByteArraytrueGet($pet_id); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PetApi->petPetIdtestingByteArraytrueGet: ', $e->getMessage(), "\n"; } +?> ``` ### Parameters @@ -410,28 +413,29 @@ 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 ### Example -```perl -use Data::Dumper; +```php +setAccessToken('YOUR_ACCESS_TOKEN'); -my $api = ::PetApi->new(); -my $body = ::Object::\Swagger\Client\Model\Pet->new(); # [\Swagger\Client\Model\Pet] Pet object that needs to be added to the store +$api_instance = new Swagger\Client\PetApi(); +$body = new \Swagger\Client\Model\Pet(); // \Swagger\Client\Model\Pet | Pet object that needs to be added to the store -eval { - $api->updatePet(body => $body); -}; -if ($@) { - warn "Exception when calling PetApi->updatePet: $@\n"; +try { + $api_instance->updatePet($body); +} catch (Exception $e) { + echo 'Exception when calling PetApi->updatePet: ', $e->getMessage(), "\n"; } +?> ``` ### Parameters @@ -456,30 +460,31 @@ 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(pet_id => $pet_id, name => $name, status => $status) +> updatePetWithForm($pet_id, $name, $status) Updates a pet in the store with form data ### Example -```perl -use Data::Dumper; +```php +setAccessToken('YOUR_ACCESS_TOKEN'); -my $api = ::PetApi->new(); -my $pet_id = pet_id_example; # [string] ID of pet that needs to be updated -my $name = name_example; # [string] Updated name of the pet -my $status = status_example; # [string] Updated status of the pet +$api_instance = new Swagger\Client\PetApi(); +$pet_id = "pet_id_example"; // string | ID of pet that needs to be updated +$name = "name_example"; // string | Updated name of the pet +$status = "status_example"; // string | Updated status of the pet -eval { - $api->updatePetWithForm(pet_id => $pet_id, name => $name, status => $status); -}; -if ($@) { - warn "Exception when calling PetApi->updatePetWithForm: $@\n"; +try { + $api_instance->updatePetWithForm($pet_id, $name, $status); +} catch (Exception $e) { + echo 'Exception when calling PetApi->updatePetWithForm: ', $e->getMessage(), "\n"; } +?> ``` ### Parameters @@ -506,30 +511,31 @@ 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** -> uploadFile(pet_id => $pet_id, additional_metadata => $additional_metadata, file => $file) +> uploadFile($pet_id, $additional_metadata, $file) uploads an image ### Example -```perl -use Data::Dumper; +```php +setAccessToken('YOUR_ACCESS_TOKEN'); -my $api = ::PetApi->new(); -my $pet_id = 789; # [int] ID of pet to update -my $additional_metadata = additional_metadata_example; # [string] Additional data to pass to server -my $file = new Swagger\Client\\SplFileObject(); # [\SplFileObject] file to upload +$api_instance = new Swagger\Client\PetApi(); +$pet_id = 789; // int | ID of pet to update +$additional_metadata = "additional_metadata_example"; // string | Additional data to pass to server +$file = new \SplFileObject(); // \SplFileObject | file to upload -eval { - $api->uploadFile(pet_id => $pet_id, additional_metadata => $additional_metadata, file => $file); -}; -if ($@) { - warn "Exception when calling PetApi->uploadFile: $@\n"; +try { + $api_instance->uploadFile($pet_id, $additional_metadata, $file); +} catch (Exception $e) { + echo 'Exception when calling PetApi->uploadFile: ', $e->getMessage(), "\n"; } +?> ``` ### Parameters diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/SpecialModelName.md b/samples/client/petstore/php/SwaggerClient-php/docs/SpecialModelName.md index d0775fc6a2f..022ee19169c 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/SpecialModelName.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/SpecialModelName.md @@ -1,9 +1,4 @@ -# ::Object::SpecialModelName - -## Load the model package -```perl -use ::Object::SpecialModelName; -``` +# SpecialModelName ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/StoreApi.md b/samples/client/petstore/php/SwaggerClient-php/docs/StoreApi.md index f8d61015d5c..cc4a5600f04 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/StoreApi.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/StoreApi.md @@ -1,9 +1,4 @@ -# ::StoreApi - -## Load the API package -```perl -use ::Object::StoreApi; -``` +# Swagger\Client\StoreApi All URIs are relative to *http://petstore.swagger.io/v2* @@ -18,25 +13,26 @@ Method | HTTP request | Description # **deleteOrder** -> deleteOrder(order_id => $order_id) +> deleteOrder($order_id) Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors ### Example -```perl -use Data::Dumper; +```php +new(); -my $order_id = order_id_example; # [string] ID of the order that needs to be deleted +$api_instance = new Swagger\Client\StoreApi(); +$order_id = "order_id_example"; // string | ID of the order that needs to be deleted -eval { - $api->deleteOrder(order_id => $order_id); -}; -if ($@) { - warn "Exception when calling StoreApi->deleteOrder: $@\n"; +try { + $api_instance->deleteOrder($order_id); +} catch (Exception $e) { + echo 'Exception when calling StoreApi->deleteOrder: ', $e->getMessage(), "\n"; } +?> ``` ### Parameters @@ -61,35 +57,36 @@ 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) # **findOrdersByStatus** -> \Swagger\Client\Model\Order[] findOrdersByStatus(status => $status) +> \Swagger\Client\Model\Order[] findOrdersByStatus($status) Finds orders by status A single status value can be provided as a string ### Example -```perl -use Data::Dumper; +```php +{'x-test_api_client_id'} = 'YOUR_API_KEY'; -# uncomment below to setup prefix (e.g. BEARER) for API key, if needed -#::Configuration::api_key_prefix->{'x-test_api_client_id'} = "BEARER"; -# Configure API key authorization: test_api_client_secret -::Configuration::api_key->{'x-test_api_client_secret'} = 'YOUR_API_KEY'; -# uncomment below to setup prefix (e.g. BEARER) for API key, if needed -#::Configuration::api_key_prefix->{'x-test_api_client_secret'} = "BEARER"; +// Configure API key authorization: test_api_client_id +Swagger\Client::getDefaultConfiguration->setApiKey('x-test_api_client_id', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +// Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('x-test_api_client_id', 'BEARER'); +// Configure API key authorization: test_api_client_secret +Swagger\Client::getDefaultConfiguration->setApiKey('x-test_api_client_secret', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +// Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('x-test_api_client_secret', 'BEARER'); -my $api = ::StoreApi->new(); -my $status = placed; # [string] Status value that needs to be considered for query +$api_instance = new Swagger\Client\StoreApi(); +$status = "placed"; // string | Status value that needs to be considered for query -eval { - my $result = $api->findOrdersByStatus(status => $status); - print Dumper($result); -}; -if ($@) { - warn "Exception when calling StoreApi->findOrdersByStatus: $@\n"; +try { + $result = $api_instance->findOrdersByStatus($status); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling StoreApi->findOrdersByStatus: ', $e->getMessage(), "\n"; } +?> ``` ### Parameters @@ -121,23 +118,24 @@ Returns pet inventories by status Returns a map of status codes to quantities ### Example -```perl -use Data::Dumper; +```php +{'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"; +// Configure API key authorization: api_key +Swagger\Client::getDefaultConfiguration->setApiKey('api_key', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +// Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('api_key', 'BEARER'); -my $api = ::StoreApi->new(); +$api_instance = new Swagger\Client\StoreApi(); -eval { - my $result = $api->getInventory(); - print Dumper($result); -}; -if ($@) { - warn "Exception when calling StoreApi->getInventory: $@\n"; +try { + $result = $api_instance->getInventory(); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling StoreApi->getInventory: ', $e->getMessage(), "\n"; } +?> ``` ### Parameters @@ -166,23 +164,24 @@ Fake endpoint to test arbitrary object return by 'Get inventory' Returns an arbitrary object which is actually a map of status codes to quantities ### Example -```perl -use Data::Dumper; +```php +{'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"; +// Configure API key authorization: api_key +Swagger\Client::getDefaultConfiguration->setApiKey('api_key', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +// Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('api_key', 'BEARER'); -my $api = ::StoreApi->new(); +$api_instance = new Swagger\Client\StoreApi(); -eval { - my $result = $api->getInventoryInObject(); - print Dumper($result); -}; -if ($@) { - warn "Exception when calling StoreApi->getInventoryInObject: $@\n"; +try { + $result = $api_instance->getInventoryInObject(); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling StoreApi->getInventoryInObject: ', $e->getMessage(), "\n"; } +?> ``` ### Parameters @@ -204,35 +203,36 @@ 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** -> \Swagger\Client\Model\Order getOrderById(order_id => $order_id) +> \Swagger\Client\Model\Order getOrderById($order_id) Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions ### Example -```perl -use Data::Dumper; +```php +{'test_api_key_header'} = 'YOUR_API_KEY'; -# uncomment below to setup prefix (e.g. BEARER) for API key, if needed -#::Configuration::api_key_prefix->{'test_api_key_header'} = "BEARER"; -# Configure API key authorization: test_api_key_query -::Configuration::api_key->{'test_api_key_query'} = 'YOUR_API_KEY'; -# uncomment below to setup prefix (e.g. BEARER) for API key, if needed -#::Configuration::api_key_prefix->{'test_api_key_query'} = "BEARER"; +// Configure API key authorization: test_api_key_header +Swagger\Client::getDefaultConfiguration->setApiKey('test_api_key_header', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +// Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('test_api_key_header', 'BEARER'); +// Configure API key authorization: test_api_key_query +Swagger\Client::getDefaultConfiguration->setApiKey('test_api_key_query', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +// Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('test_api_key_query', 'BEARER'); -my $api = ::StoreApi->new(); -my $order_id = order_id_example; # [string] ID of pet that needs to be fetched +$api_instance = new Swagger\Client\StoreApi(); +$order_id = "order_id_example"; // string | ID of pet that needs to be fetched -eval { - my $result = $api->getOrderById(order_id => $order_id); - print Dumper($result); -}; -if ($@) { - warn "Exception when calling StoreApi->getOrderById: $@\n"; +try { + $result = $api_instance->getOrderById($order_id); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling StoreApi->getOrderById: ', $e->getMessage(), "\n"; } +?> ``` ### Parameters @@ -257,35 +257,36 @@ 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) # **placeOrder** -> \Swagger\Client\Model\Order placeOrder(body => $body) +> \Swagger\Client\Model\Order placeOrder($body) Place an order for a pet ### Example -```perl -use Data::Dumper; +```php +{'x-test_api_client_id'} = 'YOUR_API_KEY'; -# uncomment below to setup prefix (e.g. BEARER) for API key, if needed -#::Configuration::api_key_prefix->{'x-test_api_client_id'} = "BEARER"; -# Configure API key authorization: test_api_client_secret -::Configuration::api_key->{'x-test_api_client_secret'} = 'YOUR_API_KEY'; -# uncomment below to setup prefix (e.g. BEARER) for API key, if needed -#::Configuration::api_key_prefix->{'x-test_api_client_secret'} = "BEARER"; +// Configure API key authorization: test_api_client_id +Swagger\Client::getDefaultConfiguration->setApiKey('x-test_api_client_id', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +// Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('x-test_api_client_id', 'BEARER'); +// Configure API key authorization: test_api_client_secret +Swagger\Client::getDefaultConfiguration->setApiKey('x-test_api_client_secret', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +// Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('x-test_api_client_secret', 'BEARER'); -my $api = ::StoreApi->new(); -my $body = ::Object::\Swagger\Client\Model\Order->new(); # [\Swagger\Client\Model\Order] order placed for purchasing the pet +$api_instance = new Swagger\Client\StoreApi(); +$body = new \Swagger\Client\Model\Order(); // \Swagger\Client\Model\Order | order placed for purchasing the pet -eval { - my $result = $api->placeOrder(body => $body); - print Dumper($result); -}; -if ($@) { - warn "Exception when calling StoreApi->placeOrder: $@\n"; +try { + $result = $api_instance->placeOrder($body); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling StoreApi->placeOrder: ', $e->getMessage(), "\n"; } +?> ``` ### Parameters diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/Tag.md b/samples/client/petstore/php/SwaggerClient-php/docs/Tag.md index fe7f063852d..15ec3e0a91d 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/Tag.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Tag.md @@ -1,9 +1,4 @@ -# ::Object::Tag - -## Load the model package -```perl -use ::Object::Tag; -``` +# Tag ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/User.md b/samples/client/petstore/php/SwaggerClient-php/docs/User.md index 306021a79d0..ff278fd4889 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/User.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/User.md @@ -1,9 +1,4 @@ -# ::Object::User - -## Load the model package -```perl -use ::Object::User; -``` +# User ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/UserApi.md b/samples/client/petstore/php/SwaggerClient-php/docs/UserApi.md index 8de0f56fec4..45e49d3e9ab 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/UserApi.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/UserApi.md @@ -1,9 +1,4 @@ -# ::UserApi - -## Load the API package -```perl -use ::Object::UserApi; -``` +# Swagger\Client\UserApi All URIs are relative to *http://petstore.swagger.io/v2* @@ -20,25 +15,26 @@ Method | HTTP request | Description # **createUser** -> createUser(body => $body) +> createUser($body) Create user This can only be done by the logged in user. ### Example -```perl -use Data::Dumper; +```php +new(); -my $body = ::Object::\Swagger\Client\Model\User->new(); # [\Swagger\Client\Model\User] Created user object +$api_instance = new Swagger\Client\UserApi(); +$body = new \Swagger\Client\Model\User(); // \Swagger\Client\Model\User | Created user object -eval { - $api->createUser(body => $body); -}; -if ($@) { - warn "Exception when calling UserApi->createUser: $@\n"; +try { + $api_instance->createUser($body); +} catch (Exception $e) { + echo 'Exception when calling UserApi->createUser: ', $e->getMessage(), "\n"; } +?> ``` ### Parameters @@ -63,25 +59,26 @@ 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 ### Example -```perl -use Data::Dumper; +```php +new(); -my $body = (::Object::\Swagger\Client\Model\User[]->new()); # [\Swagger\Client\Model\User[]] List of user object +$api_instance = new Swagger\Client\UserApi(); +$body = array(new User()); // \Swagger\Client\Model\User[] | List of user object -eval { - $api->createUsersWithArrayInput(body => $body); -}; -if ($@) { - warn "Exception when calling UserApi->createUsersWithArrayInput: $@\n"; +try { + $api_instance->createUsersWithArrayInput($body); +} catch (Exception $e) { + echo 'Exception when calling UserApi->createUsersWithArrayInput: ', $e->getMessage(), "\n"; } +?> ``` ### Parameters @@ -106,25 +103,26 @@ 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 ### Example -```perl -use Data::Dumper; +```php +new(); -my $body = (::Object::\Swagger\Client\Model\User[]->new()); # [\Swagger\Client\Model\User[]] List of user object +$api_instance = new Swagger\Client\UserApi(); +$body = array(new User()); // \Swagger\Client\Model\User[] | List of user object -eval { - $api->createUsersWithListInput(body => $body); -}; -if ($@) { - warn "Exception when calling UserApi->createUsersWithListInput: $@\n"; +try { + $api_instance->createUsersWithListInput($body); +} catch (Exception $e) { + echo 'Exception when calling UserApi->createUsersWithListInput: ', $e->getMessage(), "\n"; } +?> ``` ### Parameters @@ -149,29 +147,30 @@ 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 This can only be done by the logged in user. ### Example -```perl -use Data::Dumper; +```php +setUsername('YOUR_USERNAME'); +Swagger\Client::getDefaultConfiguration->setPassword('YOUR_PASSWORD'); -my $api = ::UserApi->new(); -my $username = username_example; # [string] The name that needs to be deleted +$api_instance = new Swagger\Client\UserApi(); +$username = "username_example"; // string | The name that needs to be deleted -eval { - $api->deleteUser(username => $username); -}; -if ($@) { - warn "Exception when calling UserApi->deleteUser: $@\n"; +try { + $api_instance->deleteUser($username); +} catch (Exception $e) { + echo 'Exception when calling UserApi->deleteUser: ', $e->getMessage(), "\n"; } +?> ``` ### Parameters @@ -196,26 +195,27 @@ 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) # **getUserByName** -> \Swagger\Client\Model\User getUserByName(username => $username) +> \Swagger\Client\Model\User getUserByName($username) Get user by user name ### Example -```perl -use Data::Dumper; +```php +new(); -my $username = username_example; # [string] The name that needs to be fetched. Use user1 for testing. +$api_instance = new Swagger\Client\UserApi(); +$username = "username_example"; // string | The name that needs to be fetched. Use user1 for testing. -eval { - my $result = $api->getUserByName(username => $username); - print Dumper($result); -}; -if ($@) { - warn "Exception when calling UserApi->getUserByName: $@\n"; +try { + $result = $api_instance->getUserByName($username); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling UserApi->getUserByName: ', $e->getMessage(), "\n"; } +?> ``` ### Parameters @@ -240,27 +240,28 @@ 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 ### Example -```perl -use Data::Dumper; +```php +new(); -my $username = username_example; # [string] The user name for login -my $password = password_example; # [string] The password for login in clear text +$api_instance = new Swagger\Client\UserApi(); +$username = "username_example"; // string | The user name for login +$password = "password_example"; // string | The password for login in clear text -eval { - my $result = $api->loginUser(username => $username, password => $password); - print Dumper($result); -}; -if ($@) { - warn "Exception when calling UserApi->loginUser: $@\n"; +try { + $result = $api_instance->loginUser($username, $password); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling UserApi->loginUser: ', $e->getMessage(), "\n"; } +?> ``` ### Parameters @@ -293,17 +294,18 @@ Logs out current logged in user session ### Example -```perl -use Data::Dumper; +```php +new(); +$api_instance = new Swagger\Client\UserApi(); -eval { - $api->logoutUser(); -}; -if ($@) { - warn "Exception when calling UserApi->logoutUser: $@\n"; +try { + $api_instance->logoutUser(); +} catch (Exception $e) { + echo 'Exception when calling UserApi->logoutUser: ', $e->getMessage(), "\n"; } +?> ``` ### Parameters @@ -325,26 +327,27 @@ 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 This can only be done by the logged in user. ### Example -```perl -use Data::Dumper; +```php +new(); -my $username = username_example; # [string] name that need to be deleted -my $body = ::Object::\Swagger\Client\Model\User->new(); # [\Swagger\Client\Model\User] Updated user object +$api_instance = new Swagger\Client\UserApi(); +$username = "username_example"; // string | name that need to be deleted +$body = new \Swagger\Client\Model\User(); // \Swagger\Client\Model\User | Updated user object -eval { - $api->updateUser(username => $username, body => $body); -}; -if ($@) { - warn "Exception when calling UserApi->updateUser: $@\n"; +try { + $api_instance->updateUser($username, $body); +} catch (Exception $e) { + echo 'Exception when calling UserApi->updateUser: ', $e->getMessage(), "\n"; } +?> ``` ### Parameters diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php index 3ad09a2cd06..11c13201a3e 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php @@ -245,7 +245,17 @@ class ObjectSerializer settype($data, 'array'); $deserialized = $data; } elseif ($class === '\DateTime') { - $deserialized = new \DateTime($data); + // Some API's return an invalid, empty string as a + // date-time property. DateTime::__construct() will return + // the current time for empty input which is probably not + // what is meant. The invalid empty string is probably to + // be interpreted as a missing field/value. Let's handle + // this graceful. + if (!empty($data)) { + $deserialized = new \DateTime($data); + } else { + $deserialized = null; + } } elseif (in_array($class, array('integer', 'int', 'void', 'number', 'object', 'double', 'float', 'byte', 'DateTime', 'string', 'mixed', 'boolean', 'bool'))) { settype($data, $class); $deserialized = $data; From 2eda3b16cfffe3940e0813b854e9cc588de72794 Mon Sep 17 00:00:00 2001 From: wing328 Date: Wed, 16 Mar 2016 16:25:32 +0800 Subject: [PATCH 4/4] fix file example --- .../swagger/codegen/languages/PhpClientCodegen.java | 12 ++++++------ .../petstore/php/SwaggerClient-php/docs/PetApi.md | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java index e0dfe6cfb2a..6e82c3fc8f2 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java @@ -516,25 +516,25 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig { if (example == null) { example = "56"; } - } else if ("Float".equals(type)) { + } else if ("Float".equalsIgnoreCase(type) || "Double".equalsIgnoreCase(type)) { if (example == null) { example = "3.4"; } - } else if ("BOOLEAN".equals(type)) { + } else if ("BOOLEAN".equalsIgnoreCase(type) || "bool".equalsIgnoreCase(type)) { if (example == null) { example = "True"; } - } else if ("File".equals(type)) { + } else if ("\\SplFileObject".equalsIgnoreCase(type)) { if (example == null) { example = "/path/to/file"; } - example = escapeText(example); - } else if ("Date".equals(type)) { + example = "\"" + escapeText(example) + "\""; + } else if ("Date".equalsIgnoreCase(type)) { if (example == null) { example = "2013-10-20"; } example = "new \\DateTime(\"" + escapeText(example) + "\")"; - } else if ("DateTime".equals(type)) { + } else if ("DateTime".equalsIgnoreCase(type)) { if (example == null) { example = "2013-10-20T19:20:30+01:00"; } diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md b/samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md index db95061a841..3f37b7a4149 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md @@ -528,7 +528,7 @@ Swagger\Client::getDefaultConfiguration->setAccessToken('YOUR_ACCESS_TOKEN'); $api_instance = new Swagger\Client\PetApi(); $pet_id = 789; // int | ID of pet to update $additional_metadata = "additional_metadata_example"; // string | Additional data to pass to server -$file = new \SplFileObject(); // \SplFileObject | file to upload +$file = "/path/to/file.txt"; // \SplFileObject | file to upload try { $api_instance->uploadFile($pet_id, $additional_metadata, $file);