diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/AbstractGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/AbstractGenerator.java index cadd7a1d85f..1d92c923c5c 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/AbstractGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/AbstractGenerator.java @@ -69,6 +69,7 @@ public Reader getTemplateReader(String name) { * * @param config Codegen config * @param templateFile Template file + * @return String Full template file path */ public String getFullTemplateFile(CodegenConfig config, String templateFile) { String library = config.getLibrary(); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java index 6809c4970d2..0253582a639 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java @@ -29,6 +29,8 @@ public interface CodegenConfig { String apiTestFileFolder(); + String apiDocFileFolder(); + String fileSuffix(); String outputFolder(); @@ -41,6 +43,8 @@ public interface CodegenConfig { String modelTestFileFolder(); + String modelDocFileFolder(); + String modelPackage(); String toApiName(String name); @@ -99,6 +103,10 @@ public interface CodegenConfig { Map modelTestTemplateFiles(); + Map apiDocTemplateFiles(); + + Map modelDocTemplateFiles(); + Set languageSpecificPrimitives(); void preprocessSwagger(Swagger swagger); @@ -115,6 +123,10 @@ public interface CodegenConfig { String toModelTestFilename(String name); + String toApiDocFilename(String name); + + String toModelDocFilename(String name); + String toModelImport(String name); String toApiImport(String name); @@ -137,6 +149,8 @@ public interface CodegenConfig { String apiTestFilename(String templateName, String tag); + String apiDocFilename(String templateName, String tag); + boolean shouldOverwrite(String filename); boolean isSkipOverwrite(); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java index 4a8c34e374f..d386b4c4dca 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java @@ -8,8 +8,9 @@ public class CodegenParameter { public Boolean isFormParam, isQueryParam, isPathParam, isHeaderParam, isCookieParam, isBodyParam, hasMore, isContainer, - secondaryParam, isCollectionFormatMulti; + secondaryParam, isCollectionFormatMulti, isPrimitiveType; public String baseName, paramName, dataType, datatypeWithEnum, collectionFormat, description, baseType, defaultValue; + public String example; // example value (x-example) public String jsonSchema; public Boolean isString, isInteger, isLong, isFloat, isDouble, isByteArray, isBinary, isBoolean, isDate, isDateTime; public Boolean isListContainer, isMapContainer; @@ -107,6 +108,7 @@ public CodegenParameter copy() { output.multipleOf = this.multipleOf; output.jsonSchema = this.jsonSchema; output.defaultValue = this.defaultValue; + output.example = this.example; output.isEnum = this.isEnum; if (this._enum != null) { output._enum = new ArrayList(this._enum); 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 071f6220cff..4ab37381d72 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 @@ -69,6 +69,8 @@ public class DefaultCodegen { protected Map modelTemplateFiles = new HashMap(); protected Map apiTestTemplateFiles = new HashMap(); protected Map modelTestTemplateFiles = new HashMap(); + protected Map apiDocTemplateFiles = new HashMap(); + protected Map modelDocTemplateFiles = new HashMap(); protected String templateDir; protected String embeddedTemplateDir; protected Map additionalProperties = new HashMap(); @@ -228,6 +230,14 @@ public String embeddedTemplateDir() { } } + public Map apiDocTemplateFiles() { + return apiDocTemplateFiles; + } + + public Map modelDocTemplateFiles() { + return modelDocTemplateFiles; + } + public Map apiTestTemplateFiles() { return apiTestTemplateFiles; } @@ -260,6 +270,14 @@ public String modelTestFileFolder() { return outputFolder + "/" + testPackage().replace('.', '/'); } + public String apiDocFileFolder() { + return outputFolder; + } + + public String modelDocFileFolder() { + return outputFolder; + } + public Map additionalProperties() { return additionalProperties; } @@ -322,6 +340,16 @@ public String toApiFilename(String name) { return toApiName(name); } + /** + * Return the file name of the Api Documentation + * + * @param name the file name of the Api + * @return the file name of the Api + */ + public String toApiDocFilename(String name) { + return toApiName(name); + } + /** * Return the file name of the Api Test * @@ -362,6 +390,16 @@ public String toModelTestFilename(String name) { return initialCaps(name) + "Test"; } + /** + * Return the capitalized file name of the model documentation + * + * @param name the model name + * @return the file name of the model + */ + public String toModelDocFilename(String name) { + return initialCaps(name); + } + /** * Return the operation ID (method name) * @@ -614,13 +652,21 @@ public String toInstantiationType(Property p) { } } + /** + * Return the example value of the parameter. + * + * @param p Swagger property object + */ + public void setParameterExampleValue(CodegenParameter p) { + + } + /** * Return the example value of the property * * @param p Swagger property object * @return string presentation of the example value of the property */ - @SuppressWarnings("static-method") public String toExampleValue(Property p) { if(p.getExample() != null) { return p.getExample().toString(); @@ -1452,6 +1498,14 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation } } } + + // set isPrimitiveType and baseType for allParams + /*if (languageSpecificPrimitives.contains(p.baseType)) { + p.isPrimitiveType = true; + p.baseType = getSwaggerType(p); + }*/ + + allParams.add(p); if (param instanceof QueryParameter) { p.isQueryParam = new Boolean(true); @@ -1723,7 +1777,9 @@ public CodegenParameter fromParameter(Parameter param, Set imports) { prop.setRequired(bp.getRequired()); CodegenProperty cp = fromProperty("property", prop); if (cp != null) { + p.baseType = cp.baseType; p.dataType = cp.datatype; + p.isPrimitiveType = cp.isPrimitiveType; p.isBinary = cp.datatype.toLowerCase().startsWith("byte"); } @@ -1743,6 +1799,8 @@ public CodegenParameter fromParameter(Parameter param, Set imports) { } imports.add(cp.baseType); p.dataType = cp.datatype; + p.baseType = cp.complexType; + p.isPrimitiveType = cp.isPrimitiveType; p.isContainer = true; p.isListContainer = true; @@ -1763,11 +1821,47 @@ public CodegenParameter fromParameter(Parameter param, Set imports) { name = getTypeDeclaration(name); } p.dataType = name; + p.baseType = name; } } p.paramName = toParamName(bp.getName()); } + // set the example value + // if not specified in x-example, generate a default value + if (p.vendorExtensions.containsKey("x-example")) { + p.example = (String) p.vendorExtensions.get("x-example"); + } else if (Boolean.TRUE.equals(p.isString)) { + p.example = p.paramName + "_example"; + } else if (Boolean.TRUE.equals(p.isBoolean)) { + p.example = new String("true"); + } else if (Boolean.TRUE.equals(p.isLong)) { + p.example = new String("789"); + } else if (Boolean.TRUE.equals(p.isInteger)) { + p.example = new String("56"); + } else if (Boolean.TRUE.equals(p.isFloat)) { + p.example = new String("3.4"); + } else if (Boolean.TRUE.equals(p.isDouble)) { + p.example = new String("1.2"); + } else if (Boolean.TRUE.equals(p.isBinary)) { + p.example = new String("BINARY_DATA_HERE"); + } else if (Boolean.TRUE.equals(p.isByteArray)) { + p.example = new String("B"); + } else if (Boolean.TRUE.equals(p.isDate)) { + p.example = new String("2013-10-20"); + } else if (Boolean.TRUE.equals(p.isDateTime)) { + p.example = new String("2013-10-20T19:20:30+01:00"); + } else if (param instanceof FormParameter && + ("file".equalsIgnoreCase(((FormParameter) param).getType()) || + "file".equals(p.baseType))) { + p.isFile = true; + p.example = new String("/path/to/file.txt"); + } + + // set the parameter excample value + // should be overridden by lang codegen + setParameterExampleValue(p); + postProcessParameter(p); return p; } @@ -2196,6 +2290,19 @@ public String apiFilename(String templateName, String tag) { return apiFileFolder() + '/' + toApiFilename(tag) + suffix; } + /** + * Return the full path and API documentation file + * + * @param templateName template name + * @param tag tag + * + * @return the API documentation file name with full path + */ + public String apiDocFilename(String templateName, String tag) { + String suffix = apiDocTemplateFiles().get(templateName); + return apiDocFileFolder() + '/' + toApiDocFilename(tag) + suffix; + } + /** * Return the full path and API test file * @@ -2361,24 +2468,34 @@ public void setParameterBooleanFlagWithCodegenProperty(CodegenParameter paramete if (Boolean.TRUE.equals(property.isString)) { parameter.isString = true; + parameter.isPrimitiveType = true; } else if (Boolean.TRUE.equals(property.isBoolean)) { parameter.isBoolean = true; + parameter.isPrimitiveType = true; } else if (Boolean.TRUE.equals(property.isLong)) { parameter.isLong = true; + parameter.isPrimitiveType = true; } else if (Boolean.TRUE.equals(property.isInteger)) { parameter.isInteger = true; + parameter.isPrimitiveType = true; } else if (Boolean.TRUE.equals(property.isDouble)) { parameter.isDouble = true; + parameter.isPrimitiveType = true; } else if (Boolean.TRUE.equals(property.isFloat)) { parameter.isFloat = true; + parameter.isPrimitiveType = true; } else if (Boolean.TRUE.equals(property.isByteArray)) { parameter.isByteArray = true; + parameter.isPrimitiveType = true; } else if (Boolean.TRUE.equals(property.isBinary)) { parameter.isByteArray = true; + parameter.isPrimitiveType = true; } else if (Boolean.TRUE.equals(property.isDate)) { parameter.isDate = true; + parameter.isPrimitiveType = true; } else if (Boolean.TRUE.equals(property.isDateTime)) { parameter.isDateTime = true; + parameter.isPrimitiveType = true; } else { LOGGER.debug("Property type is not primitive: " + property.datatype); } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java index c966cf6ba66..7bf60521d0e 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java @@ -263,6 +263,28 @@ public Reader getTemplate(String name) { writeToFile(filename, tmpl.execute(models)); files.add(new File(filename)); } + + // to generate model documentation files + for (String templateName : config.modelDocTemplateFiles().keySet()) { + String suffix = config.modelDocTemplateFiles().get(templateName); + String filename = config.modelDocFileFolder() + File.separator + config.toModelDocFilename(name) + suffix; + if (!config.shouldOverwrite(filename)) { + continue; + } + String templateFile = getFullTemplateFile(config, templateName); + String template = readTemplate(templateFile); + Template tmpl = Mustache.compiler() + .withLoader(new Mustache.TemplateLoader() { + @Override + public Reader getTemplate(String name) { + return getTemplateReader(getFullTemplateFile(config, name + ".mustache")); + } + }) + .defaultValue("") + .compile(template); + writeToFile(filename, tmpl.execute(models)); + files.add(new File(filename)); + } } catch (Exception e) { throw new RuntimeException("Could not generate model '" + name + "'", e); } @@ -368,6 +390,29 @@ public Reader getTemplate(String name) { files.add(new File(filename)); } + // to generate api documentation files + for (String templateName : config.apiDocTemplateFiles().keySet()) { + String filename = config.apiDocFilename(templateName, tag); + if (!config.shouldOverwrite(filename) && new File(filename).exists()) { + continue; + } + + String templateFile = getFullTemplateFile(config, templateName); + String template = readTemplate(templateFile); + Template tmpl = Mustache.compiler() + .withLoader(new Mustache.TemplateLoader() { + @Override + public Reader getTemplate(String name) { + return getTemplateReader(getFullTemplateFile(config, name + ".mustache")); + } + }) + .defaultValue("") + .compile(template); + + writeToFile(filename, tmpl.execute(operation)); + files.add(new File(filename)); + } + } catch (Exception e) { throw new RuntimeException("Could not generate api file for '" + tag + "'", e); } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PerlClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PerlClientCodegen.java index 740f9ac2b21..b05512f4426 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PerlClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PerlClientCodegen.java @@ -1,6 +1,7 @@ package io.swagger.codegen.languages; import io.swagger.codegen.CodegenConfig; +import io.swagger.codegen.CodegenParameter; import io.swagger.codegen.CodegenType; import io.swagger.codegen.DefaultCodegen; import io.swagger.codegen.SupportingFile; @@ -9,6 +10,17 @@ import io.swagger.models.properties.ArrayProperty; import io.swagger.models.properties.MapProperty; import io.swagger.models.properties.Property; +import io.swagger.models.properties.StringProperty; +import io.swagger.models.properties.LongProperty; +import io.swagger.models.properties.IntegerProperty; +import io.swagger.models.properties.FloatProperty; +import io.swagger.models.properties.DoubleProperty; +import io.swagger.models.properties.BooleanProperty; +import io.swagger.models.properties.BinaryProperty; +import io.swagger.models.properties.ByteArrayProperty; +import io.swagger.models.properties.DateTimeProperty; +import io.swagger.models.properties.DateProperty; + import java.io.File; import java.util.Arrays; @@ -23,6 +35,8 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig { protected String moduleName = "WWW::SwaggerClient"; protected String modulePathPart = moduleName.replaceAll("::", Matcher.quoteReplacement(File.separator)); protected String moduleVersion = "1.0.0"; + protected String apiDocPath = "docs/"; + protected String modelDocPath = "docs/"; protected static int emptyFunctionNameCounter = 0; @@ -34,6 +48,8 @@ public PerlClientCodegen() { apiTemplateFiles.put("api.mustache", ".pm"); modelTestTemplateFiles.put("object_test.mustache", ".t"); apiTestTemplateFiles.put("api_test.mustache", ".t"); + modelDocTemplateFiles.put("object_doc.mustache", ".md"); + apiDocTemplateFiles.put("api_doc.mustache", ".md"); embeddedTemplateDir = templateDir = "perl"; @@ -108,6 +124,10 @@ public void processOpts() { additionalProperties.put(MODULE_NAME, moduleName); } + // make api and model doc path available in mustache template + additionalProperties.put("apiDocPath", apiDocPath); + additionalProperties.put("modelDocPath", modelDocPath); + supportingFiles.add(new SupportingFile("ApiClient.mustache", ("lib/" + modulePathPart).replace('/', File.separatorChar), "ApiClient.pm")); supportingFiles.add(new SupportingFile("Configuration.mustache", ("lib/" + modulePathPart).replace('/', File.separatorChar), "Configuration.pm")); supportingFiles.add(new SupportingFile("ApiFactory.mustache", ("lib/" + modulePathPart).replace('/', File.separatorChar), "ApiFactory.pm")); @@ -147,7 +167,6 @@ public String modelFileFolder() { return (outputFolder + "/lib/" + modulePathPart + modelPackage()).replace('/', File.separatorChar); } - @Override public String apiTestFileFolder() { return (outputFolder + "/t").replace('/', File.separatorChar); @@ -158,6 +177,16 @@ public String modelTestFileFolder() { return (outputFolder + "/t").replace('/', File.separatorChar); } + @Override + public String apiDocFileFolder() { + return (outputFolder + "/" + apiDocPath).replace('/', File.separatorChar); + } + + @Override + public String modelDocFileFolder() { + return (outputFolder + "/" + modelDocPath).replace('/', File.separatorChar); + } + @Override public String getTypeDeclaration(Property p) { if (p instanceof ArrayProperty) { @@ -192,7 +221,43 @@ public String getSwaggerType(Property p) { @Override public String toDefaultValue(Property p) { - return "null"; + if (p instanceof StringProperty) { + StringProperty dp = (StringProperty) p; + if (dp.getDefault() != null) { + return "'" + dp.getDefault().toString() + "'"; + } + } else if (p instanceof BooleanProperty) { + BooleanProperty dp = (BooleanProperty) p; + if (dp.getDefault() != null) { + return dp.getDefault().toString(); + } + } else if (p instanceof DateProperty) { + // TODO + } else if (p instanceof DateTimeProperty) { + // TODO + } else if (p instanceof DoubleProperty) { + DoubleProperty dp = (DoubleProperty) p; + if (dp.getDefault() != null) { + return dp.getDefault().toString(); + } + } else if (p instanceof FloatProperty) { + FloatProperty dp = (FloatProperty) p; + if (dp.getDefault() != null) { + return dp.getDefault().toString(); + } + } else if (p instanceof IntegerProperty) { + IntegerProperty dp = (IntegerProperty) p; + if (dp.getDefault() != null) { + return dp.getDefault().toString(); + } + } else if (p instanceof LongProperty) { + LongProperty dp = (LongProperty) p; + if (dp.getDefault() != null) { + return dp.getDefault().toString(); + } + } + + return null; } @@ -251,11 +316,21 @@ public String toModelTestFilename(String name) { return toModelFilename(name) + "Test"; } + @Override + public String toModelDocFilename(String name) { + return toModelFilename(name); + } + @Override public String toApiTestFilename(String name) { return toApiFilename(name) + "Test"; } + @Override + public String toApiDocFilename(String name) { + return toApiFilename(name); + } + @Override public String toApiFilename(String name) { // replace - with _ e.g. created-at => created_at @@ -303,4 +378,20 @@ public void setModulePathPart(String modulePathPart) { public void setModuleVersion(String moduleVersion) { this.moduleVersion = moduleVersion; } + + @Override + public void setParameterExampleValue(CodegenParameter p) { + if (Boolean.TRUE.equals(p.isString) || Boolean.TRUE.equals(p.isBinary) || + Boolean.TRUE.equals(p.isByteArray) || Boolean.TRUE.equals(p.isFile)) { + p.example = "'" + p.example + "'"; + } else if (Boolean.TRUE.equals(p.isBoolean)) { + if (Boolean.parseBoolean(p.example)) + p.example = new String("1"); + else + p.example = new String("0"); + } else if (Boolean.TRUE.equals(p.isDateTime) || Boolean.TRUE.equals(p.isDate)) { + p.example = "DateTime->from_epoch(epoch => str2time('" + p.example + "'))"; + } + + } } diff --git a/modules/swagger-codegen/src/main/resources/perl/README.mustache b/modules/swagger-codegen/src/main/resources/perl/README.mustache index 62d57f6b3cf..d3214289e63 100644 --- a/modules/swagger-codegen/src/main/resources/perl/README.mustache +++ b/modules/swagger-codegen/src/main/resources/perl/README.mustache @@ -217,3 +217,17 @@ spec. If so, this is available via the `class_documentation()` and Each of these calls returns a hashref with various useful pieces of information. + +# DOCUMENTATION FOR API ENDPOINTS + +All URIs are relative to *{{basePath}}* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{nickname}}**]({{apiDocPath}}{{classname}}.md#{{nickname}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} + +# DOCUMENTATION FOR MODELS +{{#models}}{{#model}} - [{{moduleName}}::Object::{{classname}}]({{modelDocPath}}{{classname}}.md) +{{/model}}{{/models}} + diff --git a/modules/swagger-codegen/src/main/resources/perl/api.mustache b/modules/swagger-codegen/src/main/resources/perl/api.mustache index dcebb0bb518..9b0920c30c9 100644 --- a/modules/swagger-codegen/src/main/resources/perl/api.mustache +++ b/modules/swagger-codegen/src/main/resources/perl/api.mustache @@ -54,7 +54,7 @@ sub new { {{#operation}} # -# {{{nickname}}} +# {{{operationId}}} # # {{{summary}}} # @@ -70,7 +70,7 @@ sub new { }, {{/allParams}} }; - __PACKAGE__->method_documentation->{ {{nickname}} } = { + __PACKAGE__->method_documentation->{ {{operationId}} } = { summary => '{{summary}}', params => $params, returns => {{#returnType}}'{{{returnType}}}'{{/returnType}}{{^returnType}}undef{{/returnType}}, @@ -78,13 +78,13 @@ sub new { } # @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} # -sub {{nickname}} { +sub {{operationId}} { my ($self, %args) = @_; {{#allParams}}{{#required}} # verify the required parameter '{{paramName}}' is set unless (exists $args{'{{paramName}}'}) { - croak("Missing the required parameter '{{paramName}}' when calling {{nickname}}"); + croak("Missing the required parameter '{{paramName}}' when calling {{operationId}}"); } {{/required}}{{/allParams}} diff --git a/modules/swagger-codegen/src/test/resources/2_0/petstore.json b/modules/swagger-codegen/src/test/resources/2_0/petstore.json index 3034c0a8ce5..d418e35c141 100644 --- a/modules/swagger-codegen/src/test/resources/2_0/petstore.json +++ b/modules/swagger-codegen/src/test/resources/2_0/petstore.json @@ -1293,6 +1293,7 @@ } }, "Return": { + "descripton": "Model for testing reserved words", "properties": { "return": { "type": "integer", diff --git a/samples/client/petstore/perl/README.md b/samples/client/petstore/perl/README.md index 06dc39ccad2..3a10c7a5652 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-04T14:39:09.479+08:00 +- Build date: 2016-03-08T16:48:08.361+08:00 - Build package: class io.swagger.codegen.languages.PerlClientCodegen - Codegen version: @@ -217,3 +217,48 @@ spec. If so, this is available via the `class_documentation()` and Each of these calls returns a hashref with various useful pieces of information. + +# DOCUMENTATION FOR API ENDPOINTS + +All URIs are relative to *http://petstore.swagger.io/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user +*UserApi* | [**create_users_with_array_input**](docs/UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**create_users_with_list_input**](docs/UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**login_user**](docs/UserApi.md#login_user) | **GET** /user/login | Logs user into the system +*UserApi* | [**logout_user**](docs/UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**get_user_by_name**](docs/UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name +*UserApi* | [**update_user**](docs/UserApi.md#update_user) | **PUT** /user/{username} | Updated user +*UserApi* | [**delete_user**](docs/UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user +*PetApi* | [**update_pet**](docs/PetApi.md#update_pet) | **PUT** /pet | Update an existing pet +*PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store +*PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**find_pets_by_tags**](docs/PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**get_pet_by_id**](docs/PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**update_pet_with_form**](docs/PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data +*PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**upload_file**](docs/PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image +*PetApi* | [**get_pet_by_id_in_object**](docs/PetApi.md#get_pet_by_id_in_object) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' +*PetApi* | [**pet_pet_idtesting_byte_arraytrue_get**](docs/PetApi.md#pet_pet_idtesting_byte_arraytrue_get) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' +*PetApi* | [**add_pet_using_byte_array**](docs/PetApi.md#add_pet_using_byte_array) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store +*StoreApi* | [**find_orders_by_status**](docs/StoreApi.md#find_orders_by_status) | **GET** /store/findByStatus | Finds orders by status +*StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**get_inventory_in_object**](docs/StoreApi.md#get_inventory_in_object) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' +*StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet +*StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID +*StoreApi* | [**delete_order**](docs/StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID + + +# DOCUMENTATION FOR MODELS + - [WWW::SwaggerClient::Object::User](docs/User.md) + - [WWW::SwaggerClient::Object::Category](docs/Category.md) + - [WWW::SwaggerClient::Object::Pet](docs/Pet.md) + - [WWW::SwaggerClient::Object::Tag](docs/Tag.md) + - [WWW::SwaggerClient::Object::ModelReturn](docs/ModelReturn.md) + - [WWW::SwaggerClient::Object::Order](docs/Order.md) + - [WWW::SwaggerClient::Object::SpecialModelName](docs/SpecialModelName.md) + - [WWW::SwaggerClient::Object::InlineResponse200](docs/InlineResponse200.md) + + diff --git a/samples/client/petstore/perl/docs/Category.md b/samples/client/petstore/perl/docs/Category.md new file mode 100644 index 00000000000..ff26d61c18b --- /dev/null +++ b/samples/client/petstore/perl/docs/Category.md @@ -0,0 +1,14 @@ +# WWW::SwaggerClient::Object::Category + +## Import the module +```perl +use WWW::SwaggerClient::Object::Category; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**name** | **string** | | [optional] + + diff --git a/samples/client/petstore/perl/docs/InlineResponse200.md b/samples/client/petstore/perl/docs/InlineResponse200.md new file mode 100644 index 00000000000..a97179f7ddd --- /dev/null +++ b/samples/client/petstore/perl/docs/InlineResponse200.md @@ -0,0 +1,18 @@ +# WWW::SwaggerClient::Object::InlineResponse200 + +## Import the module +```perl +use WWW::SwaggerClient::Object::InlineResponse200; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**tags** | [**ARRAY[Tag]**](Tag.md) | | [optional] +**id** | **int** | | +**category** | **object** | | [optional] +**status** | **string** | pet status in the store | [optional] +**name** | **string** | | [optional] +**photo_urls** | **ARRAY[string]** | | [optional] + + diff --git a/samples/client/petstore/perl/docs/ObjectReturn.md b/samples/client/petstore/perl/docs/ObjectReturn.md new file mode 100644 index 00000000000..2bd4ff37640 --- /dev/null +++ b/samples/client/petstore/perl/docs/ObjectReturn.md @@ -0,0 +1,13 @@ +# WWW::SwaggerClient::Object::ObjectReturn + +## Import the module +```perl +use WWW::SwaggerClient::Object::ObjectReturn; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**return** | **int** | | [optional] + + diff --git a/samples/client/petstore/perl/docs/Order.md b/samples/client/petstore/perl/docs/Order.md new file mode 100644 index 00000000000..3f519eabc94 --- /dev/null +++ b/samples/client/petstore/perl/docs/Order.md @@ -0,0 +1,18 @@ +# WWW::SwaggerClient::Object::Order + +## Import the module +```perl +use WWW::SwaggerClient::Object::Order; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**pet_id** | **int** | | [optional] +**quantity** | **int** | | [optional] +**ship_date** | **DateTime** | | [optional] +**status** | **string** | Order Status | [optional] +**complete** | **boolean** | | [optional] + + diff --git a/samples/client/petstore/perl/docs/Pet.md b/samples/client/petstore/perl/docs/Pet.md new file mode 100644 index 00000000000..bc143f0cc26 --- /dev/null +++ b/samples/client/petstore/perl/docs/Pet.md @@ -0,0 +1,18 @@ +# WWW::SwaggerClient::Object::Pet + +## Import the module +```perl +use WWW::SwaggerClient::Object::Pet; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**category** | [**Category**](Category.md) | | [optional] +**name** | **string** | | +**photo_urls** | **ARRAY[string]** | | +**tags** | [**ARRAY[Tag]**](Tag.md) | | [optional] +**status** | **string** | pet status in the store | [optional] + + diff --git a/samples/client/petstore/perl/docs/PetApi.md b/samples/client/petstore/perl/docs/PetApi.md new file mode 100644 index 00000000000..677b4d390e8 --- /dev/null +++ b/samples/client/petstore/perl/docs/PetApi.md @@ -0,0 +1,491 @@ +# WWW::SwaggerClient::PetApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**update_pet**](PetApi.md#update_pet) | **PUT** /pet | Update an existing pet +[**add_pet**](PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store +[**find_pets_by_status**](PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status +[**find_pets_by_tags**](PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags +[**get_pet_by_id**](PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID +[**update_pet_with_form**](PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data +[**delete_pet**](PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet +[**upload_file**](PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image +[**get_pet_by_id_in_object**](PetApi.md#get_pet_by_id_in_object) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' +[**pet_pet_idtesting_byte_arraytrue_get**](PetApi.md#pet_pet_idtesting_byte_arraytrue_get) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' +[**add_pet_using_byte_array**](PetApi.md#add_pet_using_byte_array) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store + + +# **update_pet** +> update_pet(body => $body) + +Update an existing pet + + + +### Example +```perl +my $api = WWW::SwaggerClient::PetApi->new(); +my $body = WWW::SwaggerClient::Object::Pet->new(); # [Pet] Pet object that needs to be added to the store + +eval { + $api->update_pet(body => $body); +}; +if ($@) { + warn "Exception when calling update_pet: $@\n"; +} +``` + +### Parameters +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional] + +### Return type + +void (empty response body) + +### HTTP headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/json, application/xml + +### Authentication scheme + +petstore_auth + + + + + +# **add_pet** +> add_pet(body => $body) + +Add a new pet to the store + + + +### Example +```perl +my $api = WWW::SwaggerClient::PetApi->new(); +my $body = WWW::SwaggerClient::Object::Pet->new(); # [Pet] Pet object that needs to be added to the store + +eval { + $api->add_pet(body => $body); +}; +if ($@) { + warn "Exception when calling add_pet: $@\n"; +} +``` + +### Parameters +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional] + +### Return type + +void (empty response body) + +### HTTP headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/json, application/xml + +### Authentication scheme + +petstore_auth + + + + + +# **find_pets_by_status** +> ARRAY[Pet] find_pets_by_status(status => $status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example +```perl +my $api = WWW::SwaggerClient::PetApi->new(); +my $status = (); # [ARRAY[string]] Status values that need to be considered for query + +eval { + my $result = $api->find_pets_by_status(status => $status); +}; +if ($@) { + warn "Exception when calling find_pets_by_status: $@\n"; +} +``` + +### Parameters +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | [**ARRAY[string]**](string.md)| Status values that need to be considered for query | [optional] [default to available] + +### Return type + +[**ARRAY[Pet]**](Pet.md) + +### HTTP headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +### Authentication scheme + +petstore_auth + + + + + +# **find_pets_by_tags** +> ARRAY[Pet] find_pets_by_tags(tags => $tags) + +Finds Pets by tags + +Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + +### Example +```perl +my $api = WWW::SwaggerClient::PetApi->new(); +my $tags = (); # [ARRAY[string]] Tags to filter by + +eval { + my $result = $api->find_pets_by_tags(tags => $tags); +}; +if ($@) { + warn "Exception when calling find_pets_by_tags: $@\n"; +} +``` + +### Parameters +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **tags** | [**ARRAY[string]**](string.md)| Tags to filter by | [optional] + +### Return type + +[**ARRAY[Pet]**](Pet.md) + +### HTTP headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +### Authentication scheme + +petstore_auth + + + + + +# **get_pet_by_id** +> Pet get_pet_by_id(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 +my $api = WWW::SwaggerClient::PetApi->new(); +my $pet_id = 789; # [int] ID of pet that needs to be fetched + +eval { + my $result = $api->get_pet_by_id(pet_id => $pet_id); +}; +if ($@) { + warn "Exception when calling get_pet_by_id: $@\n"; +} +``` + +### Parameters +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet that needs to be fetched | + +### Return type + +[**Pet**](Pet.md) + +### HTTP headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +### Authentication scheme + +api_keypetstore_auth + + + + + +# **update_pet_with_form** +> update_pet_with_form(pet_id => $pet_id, name => $name, status => $status) + +Updates a pet in the store with form data + + + +### Example +```perl +my $api = WWW::SwaggerClient::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->update_pet_with_form(pet_id => $pet_id, name => $name, status => $status); +}; +if ($@) { + warn "Exception when calling update_pet_with_form: $@\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) + +### HTTP headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: application/json, application/xml + +### Authentication scheme + +petstore_auth + + + + + +# **delete_pet** +> delete_pet(pet_id => $pet_id, api_key => $api_key) + +Deletes a pet + + + +### Example +```perl +my $api = WWW::SwaggerClient::PetApi->new(); +my $pet_id = 789; # [int] Pet id to delete +my $api_key = 'api_key_example'; # [string] + +eval { + $api->delete_pet(pet_id => $pet_id, api_key => $api_key); +}; +if ($@) { + warn "Exception when calling delete_pet: $@\n"; +} +``` + +### Parameters +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| Pet id to delete | + **api_key** | **string**| | [optional] + +### Return type + +void (empty response body) + +### HTTP headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +### Authentication scheme + +petstore_auth + + + + + +# **upload_file** +> upload_file(pet_id => $pet_id, additional_metadata => $additional_metadata, file => $file) + +uploads an image + + + +### Example +```perl +my $api = WWW::SwaggerClient::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 = '/path/to/file.txt'; # [File] file to upload + +eval { + $api->upload_file(pet_id => $pet_id, additional_metadata => $additional_metadata, file => $file); +}; +if ($@) { + warn "Exception when calling upload_file: $@\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** | [**File**](.md)| file to upload | [optional] + +### Return type + +void (empty response body) + +### HTTP headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json, application/xml + +### Authentication scheme + +petstore_auth + + + + + +# **get_pet_by_id_in_object** +> InlineResponse200 get_pet_by_id_in_object(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 +my $api = WWW::SwaggerClient::PetApi->new(); +my $pet_id = 789; # [int] ID of pet that needs to be fetched + +eval { + my $result = $api->get_pet_by_id_in_object(pet_id => $pet_id); +}; +if ($@) { + warn "Exception when calling get_pet_by_id_in_object: $@\n"; +} +``` + +### Parameters +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet that needs to be fetched | + +### Return type + +[**InlineResponse200**](InlineResponse200.md) + +### HTTP headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +### Authentication scheme + +api_keypetstore_auth + + + + + +# **pet_pet_idtesting_byte_arraytrue_get** +> string pet_pet_idtesting_byte_arraytrue_get(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 +my $api = WWW::SwaggerClient::PetApi->new(); +my $pet_id = 789; # [int] ID of pet that needs to be fetched + +eval { + my $result = $api->pet_pet_idtesting_byte_arraytrue_get(pet_id => $pet_id); +}; +if ($@) { + warn "Exception when calling pet_pet_idtesting_byte_arraytrue_get: $@\n"; +} +``` + +### Parameters +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet that needs to be fetched | + +### Return type + +**string** + +### HTTP headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +### Authentication scheme + +api_keypetstore_auth + + + + + +# **add_pet_using_byte_array** +> add_pet_using_byte_array(body => $body) + +Fake endpoint to test byte array in body parameter for adding a new pet to the store + + + +### Example +```perl +my $api = WWW::SwaggerClient::PetApi->new(); +my $body = WWW::SwaggerClient::Object::string->new(); # [string] Pet object in the form of byte array + +eval { + $api->add_pet_using_byte_array(body => $body); +}; +if ($@) { + warn "Exception when calling add_pet_using_byte_array: $@\n"; +} +``` + +### Parameters +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **string**| Pet object in the form of byte array | [optional] + +### Return type + +void (empty response body) + +### HTTP headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/json, application/xml + +### Authentication scheme + +petstore_auth + + + + + diff --git a/samples/client/petstore/perl/docs/SpecialModelName.md b/samples/client/petstore/perl/docs/SpecialModelName.md new file mode 100644 index 00000000000..13ac1ac2c98 --- /dev/null +++ b/samples/client/petstore/perl/docs/SpecialModelName.md @@ -0,0 +1,13 @@ +# WWW::SwaggerClient::Object::SpecialModelName + +## Import the module +```perl +use WWW::SwaggerClient::Object::SpecialModelName; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**__special[property/name]** | **int** | | [optional] + + diff --git a/samples/client/petstore/perl/docs/StoreApi.md b/samples/client/petstore/perl/docs/StoreApi.md new file mode 100644 index 00000000000..fb004bce30f --- /dev/null +++ b/samples/client/petstore/perl/docs/StoreApi.md @@ -0,0 +1,262 @@ +# WWW::SwaggerClient::StoreApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**find_orders_by_status**](StoreApi.md#find_orders_by_status) | **GET** /store/findByStatus | Finds orders by status +[**get_inventory**](StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status +[**get_inventory_in_object**](StoreApi.md#get_inventory_in_object) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' +[**place_order**](StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet +[**get_order_by_id**](StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID +[**delete_order**](StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID + + +# **find_orders_by_status** +> ARRAY[Order] find_orders_by_status(status => $status) + +Finds orders by status + +A single status value can be provided as a string + +### Example +```perl +my $api = WWW::SwaggerClient::StoreApi->new(); +my $status = 'status_example'; # [string] Status value that needs to be considered for query + +eval { + my $result = $api->find_orders_by_status(status => $status); +}; +if ($@) { + warn "Exception when calling find_orders_by_status: $@\n"; +} +``` + +### Parameters +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | **string**| Status value that needs to be considered for query | [optional] [default to placed] + +### Return type + +[**ARRAY[Order]**](Order.md) + +### HTTP headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +### Authentication scheme + +test_api_client_idtest_api_client_secret + + + + + +# **get_inventory** +> HASH[string,int] get_inventory() + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example +```perl +my $api = WWW::SwaggerClient::StoreApi->new(); + +eval { + my $result = $api->get_inventory(); +}; +if ($@) { + warn "Exception when calling get_inventory: $@\n"; +} +``` + +### Parameters +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + +### Return type + +**HASH[string,int]** + +### HTTP headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +### Authentication scheme + +api_key + + + + + +# **get_inventory_in_object** +> object get_inventory_in_object() + +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 +my $api = WWW::SwaggerClient::StoreApi->new(); + +eval { + my $result = $api->get_inventory_in_object(); +}; +if ($@) { + warn "Exception when calling get_inventory_in_object: $@\n"; +} +``` + +### Parameters +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + +### Return type + +**object** + +### HTTP headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +### Authentication scheme + +api_key + + + + + +# **place_order** +> Order place_order(body => $body) + +Place an order for a pet + + + +### Example +```perl +my $api = WWW::SwaggerClient::StoreApi->new(); +my $body = WWW::SwaggerClient::Object::Order->new(); # [Order] order placed for purchasing the pet + +eval { + my $result = $api->place_order(body => $body); +}; +if ($@) { + warn "Exception when calling place_order: $@\n"; +} +``` + +### Parameters +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Order**](Order.md)| order placed for purchasing the pet | [optional] + +### Return type + +[**Order**](Order.md) + +### HTTP headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +### Authentication scheme + +test_api_client_idtest_api_client_secret + + + + + +# **get_order_by_id** +> Order get_order_by_id(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 +my $api = WWW::SwaggerClient::StoreApi->new(); +my $order_id = 'order_id_example'; # [string] ID of pet that needs to be fetched + +eval { + my $result = $api->get_order_by_id(order_id => $order_id); +}; +if ($@) { + warn "Exception when calling get_order_by_id: $@\n"; +} +``` + +### Parameters +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order_id** | **string**| ID of pet that needs to be fetched | + +### Return type + +[**Order**](Order.md) + +### HTTP headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +### Authentication scheme + +test_api_key_headertest_api_key_query + + + + + +# **delete_order** +> delete_order(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 +my $api = WWW::SwaggerClient::StoreApi->new(); +my $order_id = 'order_id_example'; # [string] ID of the order that needs to be deleted + +eval { + $api->delete_order(order_id => $order_id); +}; +if ($@) { + warn "Exception when calling delete_order: $@\n"; +} +``` + +### Parameters +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order_id** | **string**| ID of the order that needs to be deleted | + +### Return type + +void (empty response body) + +### HTTP headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +### Authentication scheme + +No authentiation required + + + + + diff --git a/samples/client/petstore/perl/docs/Tag.md b/samples/client/petstore/perl/docs/Tag.md new file mode 100644 index 00000000000..b97e36a7ca4 --- /dev/null +++ b/samples/client/petstore/perl/docs/Tag.md @@ -0,0 +1,14 @@ +# WWW::SwaggerClient::Object::Tag + +## Import the module +```perl +use WWW::SwaggerClient::Object::Tag; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**name** | **string** | | [optional] + + diff --git a/samples/client/petstore/perl/docs/User.md b/samples/client/petstore/perl/docs/User.md new file mode 100644 index 00000000000..35c5c4ef91d --- /dev/null +++ b/samples/client/petstore/perl/docs/User.md @@ -0,0 +1,20 @@ +# WWW::SwaggerClient::Object::User + +## Import the module +```perl +use WWW::SwaggerClient::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] + + diff --git a/samples/client/petstore/perl/docs/UserApi.md b/samples/client/petstore/perl/docs/UserApi.md new file mode 100644 index 00000000000..e60e51cfb2d --- /dev/null +++ b/samples/client/petstore/perl/docs/UserApi.md @@ -0,0 +1,354 @@ +# WWW::SwaggerClient::UserApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**create_user**](UserApi.md#create_user) | **POST** /user | Create user +[**create_users_with_array_input**](UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array +[**create_users_with_list_input**](UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array +[**login_user**](UserApi.md#login_user) | **GET** /user/login | Logs user into the system +[**logout_user**](UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session +[**get_user_by_name**](UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name +[**update_user**](UserApi.md#update_user) | **PUT** /user/{username} | Updated user +[**delete_user**](UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user + + +# **create_user** +> create_user(body => $body) + +Create user + +This can only be done by the logged in user. + +### Example +```perl +my $api = WWW::SwaggerClient::UserApi->new(); +my $body = WWW::SwaggerClient::Object::User->new(); # [User] Created user object + +eval { + $api->create_user(body => $body); +}; +if ($@) { + warn "Exception when calling create_user: $@\n"; +} +``` + +### Parameters +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**User**](User.md)| Created user object | [optional] + +### Return type + +void (empty response body) + +### HTTP headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +### Authentication scheme + +No authentiation required + + + + + +# **create_users_with_array_input** +> create_users_with_array_input(body => $body) + +Creates list of users with given input array + + + +### Example +```perl +my $api = WWW::SwaggerClient::UserApi->new(); +my $body = (WWW::SwaggerClient::Object::ARRAY[User]->new()); # [ARRAY[User]] List of user object + +eval { + $api->create_users_with_array_input(body => $body); +}; +if ($@) { + warn "Exception when calling create_users_with_array_input: $@\n"; +} +``` + +### Parameters +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**ARRAY[User]**](User.md)| List of user object | [optional] + +### Return type + +void (empty response body) + +### HTTP headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +### Authentication scheme + +No authentiation required + + + + + +# **create_users_with_list_input** +> create_users_with_list_input(body => $body) + +Creates list of users with given input array + + + +### Example +```perl +my $api = WWW::SwaggerClient::UserApi->new(); +my $body = (WWW::SwaggerClient::Object::ARRAY[User]->new()); # [ARRAY[User]] List of user object + +eval { + $api->create_users_with_list_input(body => $body); +}; +if ($@) { + warn "Exception when calling create_users_with_list_input: $@\n"; +} +``` + +### Parameters +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**ARRAY[User]**](User.md)| List of user object | [optional] + +### Return type + +void (empty response body) + +### HTTP headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +### Authentication scheme + +No authentiation required + + + + + +# **login_user** +> string login_user(username => $username, password => $password) + +Logs user into the system + + + +### Example +```perl +my $api = WWW::SwaggerClient::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->login_user(username => $username, password => $password); +}; +if ($@) { + warn "Exception when calling login_user: $@\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** + +### HTTP headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +### Authentication scheme + +No authentiation required + + + + + +# **logout_user** +> logout_user() + +Logs out current logged in user session + + + +### Example +```perl +my $api = WWW::SwaggerClient::UserApi->new(); + +eval { + $api->logout_user(); +}; +if ($@) { + warn "Exception when calling logout_user: $@\n"; +} +``` + +### Parameters +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + +### Return type + +void (empty response body) + +### HTTP headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +### Authentication scheme + +No authentiation required + + + + + +# **get_user_by_name** +> User get_user_by_name(username => $username) + +Get user by user name + + + +### Example +```perl +my $api = WWW::SwaggerClient::UserApi->new(); +my $username = 'username_example'; # [string] The name that needs to be fetched. Use user1 for testing. + +eval { + my $result = $api->get_user_by_name(username => $username); +}; +if ($@) { + warn "Exception when calling get_user_by_name: $@\n"; +} +``` + +### Parameters +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **string**| The name that needs to be fetched. Use user1 for testing. | + +### Return type + +[**User**](User.md) + +### HTTP headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +### Authentication scheme + +No authentiation required + + + + + +# **update_user** +> update_user(username => $username, body => $body) + +Updated user + +This can only be done by the logged in user. + +### Example +```perl +my $api = WWW::SwaggerClient::UserApi->new(); +my $username = 'username_example'; # [string] name that need to be deleted +my $body = WWW::SwaggerClient::Object::User->new(); # [User] Updated user object + +eval { + $api->update_user(username => $username, body => $body); +}; +if ($@) { + warn "Exception when calling update_user: $@\n"; +} +``` + +### Parameters +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **string**| name that need to be deleted | + **body** | [**User**](User.md)| Updated user object | [optional] + +### Return type + +void (empty response body) + +### HTTP headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +### Authentication scheme + +No authentiation required + + + + + +# **delete_user** +> delete_user(username => $username) + +Delete user + +This can only be done by the logged in user. + +### Example +```perl +my $api = WWW::SwaggerClient::UserApi->new(); +my $username = 'username_example'; # [string] The name that needs to be deleted + +eval { + $api->delete_user(username => $username); +}; +if ($@) { + warn "Exception when calling delete_user: $@\n"; +} +``` + +### Parameters +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **string**| The name that needs to be deleted | + +### Return type + +void (empty response body) + +### HTTP headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +### Authentication scheme + +No authentiation required + + + + + diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/InlineResponse200.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/InlineResponse200.pm index 61ce10e3a2e..90f7bad236e 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/InlineResponse200.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/InlineResponse200.pm @@ -103,6 +103,13 @@ __PACKAGE__->class_documentation({description => '', } ); __PACKAGE__->method_documentation({ + 'tags' => { + datatype => 'ARRAY[Tag]', + base_name => 'tags', + description => '', + format => '', + read_only => '', + }, 'id' => { datatype => 'int', base_name => 'id', @@ -117,6 +124,13 @@ __PACKAGE__->method_documentation({ format => '', read_only => '', }, + 'status' => { + datatype => 'string', + base_name => 'status', + description => 'pet status in the store', + format => '', + read_only => '', + }, 'name' => { datatype => 'string', base_name => 'name', @@ -124,19 +138,32 @@ __PACKAGE__->method_documentation({ format => '', read_only => '', }, + 'photo_urls' => { + datatype => 'ARRAY[string]', + base_name => 'photoUrls', + description => '', + format => '', + read_only => '', + }, }); __PACKAGE__->swagger_types( { + 'tags' => 'ARRAY[Tag]', 'id' => 'int', 'category' => 'object', - 'name' => 'string' + 'status' => 'string', + 'name' => 'string', + 'photo_urls' => 'ARRAY[string]' } ); __PACKAGE__->attribute_map( { + 'tags' => 'tags', 'id' => 'id', 'category' => 'category', - 'name' => 'name' + 'status' => 'status', + 'name' => 'name', + 'photo_urls' => 'photoUrls' } ); __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map}); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm index 1334b695271..d0e21454fc3 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-04T14:39:09.479+08:00', + generated_date => '2016-03-08T16:48:08.361+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-04T14:39:09.479+08:00 +=item Build date: 2016-03-08T16:48:08.361+08:00 =item Build package: class io.swagger.codegen.languages.PerlClientCodegen diff --git a/samples/client/petstore/perl/test.pl b/samples/client/petstore/perl/test.pl index b12105c9054..626d25357fc 100755 --- a/samples/client/petstore/perl/test.pl +++ b/samples/client/petstore/perl/test.pl @@ -25,6 +25,14 @@ my $api = WWW::SwaggerClient::PetApi->new(); +# exception handling +#eval { +# print "\nget_pet_by_id:".Dumper $api->get_pet_by_id(pet_id => 9999); +#}; +#if ($@) { +# print "Exception when calling: $@\n"; +#} + my $pet_id = 10008; my $category = WWW::SwaggerClient::Object::Category->new('id' => '2', 'name' => 'perl');