From 87265d9ac7e777d0ee78440ed556a2d752ac4a24 Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Mon, 29 May 2017 20:47:31 -0400 Subject: [PATCH 1/4] [kotlin] api/model docs This commit adds Api/Model/Auth documentation to the generated README.md. Because auth support is not yet fully implemented (users can manually set default headers globally), there aren't examples for helper auth methods. Models with inline enums document allowed values rather than pointing to a generated enum class. Two global additionalProperties were added (generateApiDocs, generateModelDocs) to allow templates to conditionally display documentatoin depending on these mutually exclusive settings. All current generators supporting docs will attempt to link to generated models when only api docs are specified. This also moves the $@ bash parameter in bin/kotlin-client-petstore.sh to the end of the args variable. This is because $@ can only be used to pass System properties like -DdebugModels, can can already be passed as: JAVA_OPTS="$JAVA_OPTS -DdebugModels" ./bin/kotlin-client-petstore.sh By moving the $@ to the end of the args, it allows us to pass additional properties and other switches directly to the script. --- bin/kotlin-client-petstore.sh | 2 +- .../io/swagger/codegen/CodegenConstants.java | 6 ++ .../io/swagger/codegen/DefaultGenerator.java | 4 + .../languages/KotlinClientCodegen.java | 21 ++++- .../main/resources/kotlin-client/README.md | 29 ------- .../resources/kotlin-client/README.mustache | 85 +++++++++++++++++++ .../resources/kotlin-client/api_doc.mustache | 65 ++++++++++++++ .../kotlin-client/class_doc.mustache | 15 ++++ .../resources/kotlin-client/enum_doc.mustache | 7 ++ .../kotlin-client/model_doc.mustache | 3 + samples/client/kotlin/README.md | 69 ++++++++++++++- 11 files changed, 270 insertions(+), 36 deletions(-) delete mode 100644 modules/swagger-codegen/src/main/resources/kotlin-client/README.md create mode 100644 modules/swagger-codegen/src/main/resources/kotlin-client/README.mustache create mode 100644 modules/swagger-codegen/src/main/resources/kotlin-client/api_doc.mustache create mode 100644 modules/swagger-codegen/src/main/resources/kotlin-client/class_doc.mustache create mode 100644 modules/swagger-codegen/src/main/resources/kotlin-client/enum_doc.mustache create mode 100644 modules/swagger-codegen/src/main/resources/kotlin-client/model_doc.mustache diff --git a/bin/kotlin-client-petstore.sh b/bin/kotlin-client-petstore.sh index fa017f1e8ef..4f5a84e472b 100755 --- a/bin/kotlin-client-petstore.sh +++ b/bin/kotlin-client-petstore.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -t modules/swagger-codegen/src/main/resources/kotlin-client -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l kotlin -o samples/client/kotlin" +ags="generate -t modules/swagger-codegen/src/main/resources/kotlin-client -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l kotlin -o samples/client/kotlin $@" java ${JAVA_OPTS} -jar ${executable} ${ags} diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConstants.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConstants.java index 47a97e4d89d..d9bf80c1b62 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConstants.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConstants.java @@ -173,9 +173,15 @@ public class CodegenConstants { public static final String EXCLUDE_TESTS = "excludeTests"; public static final String EXCLUDE_TESTS_DESC = "Specifies that no tests are to be generated."; + // Not user-configurable. System provided for use in templates. + public static final String GENERATE_API_DOCS = "generateApiDocs"; + public static final String GENERATE_API_TESTS = "generateApiTests"; public static final String GENERATE_API_TESTS_DESC = "Specifies that api tests are to be generated."; + // Not user-configurable. System provided for use in templates. + public static final String GENERATE_MODEL_DOCS = "generateModelDocs"; + public static final String GENERATE_MODEL_TESTS = "generateModelTests"; public static final String GENERATE_MODEL_TESTS_DESC = "Specifies that model tests are to be generated."; 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 f28e8d20cb3..5a1ea3e1227 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 @@ -120,6 +120,10 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { // Additional properties added for tests to exclude references in project related files config.additionalProperties().put(CodegenConstants.GENERATE_API_TESTS, generateApiTests); config.additionalProperties().put(CodegenConstants.GENERATE_MODEL_TESTS, generateModelTests); + + config.additionalProperties().put(CodegenConstants.GENERATE_API_DOCS, generateApiDocumentation); + config.additionalProperties().put(CodegenConstants.GENERATE_MODEL_DOCS, generateModelDocumentation); + if(!generateApiTests && !generateModelTests) { config.additionalProperties().put(CodegenConstants.EXCLUDE_TESTS, true); } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/KotlinClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/KotlinClientCodegen.java index aa1a0039ded..50ed2dc1ee3 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/KotlinClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/KotlinClientCodegen.java @@ -20,6 +20,8 @@ public class KotlinClientCodegen extends DefaultCodegen implements CodegenConfig protected String artifactVersion = "1.0.0"; protected String sourceFolder = "src/main/kotlin"; protected String packageName = "io.swagger.client"; + protected String apiDocPath = "docs/"; + protected String modelDocPath = "docs/"; /** * Constructs an instance of `KotlinClientCodegen`. @@ -30,7 +32,8 @@ public class KotlinClientCodegen extends DefaultCodegen implements CodegenConfig outputFolder = "generated-code" + File.separator + "kotlin-client"; modelTemplateFiles.put("model.mustache", ".kt"); apiTemplateFiles.put("api.mustache", ".kt"); - // TODO: Documentation generation + modelDocTemplateFiles.put("model_doc.mustache", ".md"); + apiDocTemplateFiles.put("api_doc.mustache", ".md"); embeddedTemplateDir = templateDir = "kotlin-client"; apiPackage = packageName + ".apis"; modelPackage = packageName + ".models"; @@ -227,7 +230,10 @@ public class KotlinClientCodegen extends DefaultCodegen implements CodegenConfig additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage()); additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage()); - supportingFiles.add(new SupportingFile("README.md", "", "README.md")); + additionalProperties.put("apiDocPath", apiDocPath); + additionalProperties.put("modelDocPath", modelDocPath); + + supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); supportingFiles.add(new SupportingFile("build.gradle.mustache", "", "build.gradle")); supportingFiles.add(new SupportingFile("settings.gradle.mustache", "", "settings.gradle")); @@ -255,11 +261,22 @@ public class KotlinClientCodegen extends DefaultCodegen implements CodegenConfig return input.replace("\"", ""); } + @Override + public String apiDocFileFolder() { + return (outputFolder + "/" + apiDocPath).replace('/', File.separatorChar); + } + @Override public String apiFileFolder() { return outputFolder + File.separator + sourceFolder + File.separator + apiPackage().replace('.', File.separatorChar); } + @Override + public String modelDocFileFolder() { + return (outputFolder + "/" + modelDocPath).replace('/', File.separatorChar); + } + + @Override public String modelFileFolder() { return outputFolder + File.separator + sourceFolder + File.separator + modelPackage().replace('.', File.separatorChar); diff --git a/modules/swagger-codegen/src/main/resources/kotlin-client/README.md b/modules/swagger-codegen/src/main/resources/kotlin-client/README.md deleted file mode 100644 index 885688a0fd6..00000000000 --- a/modules/swagger-codegen/src/main/resources/kotlin-client/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# Generated Kotlin Client library - -## Requires - -* Kotlin 1.1.2 -* Gradle 3.3 - -## Build - -First, create the gradle wrapper script: - -``` -gradle wrapper -``` - -Then, run: - -``` -./gradlew check assemble -``` - -This runs all tests and packages the library. - -## Notes - -* Supports JSON inputs/outputs, File inputs, and Form inputs. -* Supports collection formats for query parameters: csv, tsv, ssv, pipes. -* Some Kotlin and Java types are fully qualified to avoid conflicts with types defined in Swagger definitions. -* Implementation of ApiClient is intended to reduce method counts, specifically to benefit Android targets. \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/kotlin-client/README.mustache b/modules/swagger-codegen/src/main/resources/kotlin-client/README.mustache new file mode 100644 index 00000000000..7a10bab6c12 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/kotlin-client/README.mustache @@ -0,0 +1,85 @@ +# {{packageName}} - Kotlin client library for {{appName}} + +## Requires + +* Kotlin 1.1.2 +* Gradle 3.3 + +## Build + +First, create the gradle wrapper script: + +``` +gradle wrapper +``` + +Then, run: + +``` +./gradlew check assemble +``` + +This runs all tests and packages the library. + +## Features/Implementation Notes + +* Supports JSON inputs/outputs, File inputs, and Form inputs. +* Supports collection formats for query parameters: csv, tsv, ssv, pipes. +* Some Kotlin and Java types are fully qualified to avoid conflicts with types defined in Swagger definitions. +* Implementation of ApiClient is intended to reduce method counts, specifically to benefit Android targets. + +{{#generateApiDocs}} + +## Documentation for API Endpoints + +All URIs are relative to *{{{basePath}}}* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{{summary}}}{{/summary}} +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} +{{/generateApiDocs}} + +{{#generateModelDocs}} + +## Documentation for Models + +{{#modelPackage}} +{{#models}}{{#model}} - [{{{modelPackage}}}.{{{classname}}}]({{modelDocPath}}{{{classname}}}.md) +{{/model}}{{/models}} +{{/modelPackage}} +{{^modelPackage}} +No model defined in this package +{{/modelPackage}} +{{/generateModelDocs}} + +{{! TODO: optional documentation for authorization? }} +## Documentation for Authorization + +{{^authMethods}} +All endpoints do not require authorization. +{{/authMethods}} +{{#authMethods}} +{{#last}} +Authentication schemes defined for the API: +{{/last}} +{{/authMethods}} +{{#authMethods}} + +### {{name}} + +{{#isApiKey}}- **Type**: API key +- **API key parameter name**: {{keyParamName}} +- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} +{{/isApiKey}} +{{#isBasic}}- **Type**: HTTP basic authentication +{{/isBasic}} +{{#isOAuth}}- **Type**: OAuth +- **Flow**: {{flow}} +- **Authorization URL**: {{authorizationUrl}} +- **Scopes**: {{^scopes}}N/A{{/scopes}} +{{#scopes}} - {{scope}}: {{description}} +{{/scopes}} +{{/isOAuth}} + +{{/authMethods}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/kotlin-client/api_doc.mustache b/modules/swagger-codegen/src/main/resources/kotlin-client/api_doc.mustache new file mode 100644 index 00000000000..d288470ca88 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/kotlin-client/api_doc.mustache @@ -0,0 +1,65 @@ +# {{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 +```kotlin +// Import classes: +//import {{{packageName}}}.infrastructure.* +//import {{{modelPackage}}}.* + +{{! TODO: Auth method documentation examples}} +val apiInstance = {{{classname}}}() +{{#allParams}} +val {{{paramName}}} : {{{dataType}}} = {{{example}}} // {{{dataType}}} | {{{description}}} +{{/allParams}} +try { + {{#returnType}}val result : {{{returnType}}} = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} + println(result){{/returnType}} +} catch (e: ClientException) { + println("4xx response calling {{{classname}}}#{{{operationId}}}") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling {{{classname}}}#{{{operationId}}}") + e.printStackTrace() +} +``` + +### Parameters +{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} +Name | Type | Description | Notes +------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} +{{#allParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}{{#generateModelDocs}}[**{{dataType}}**]({{baseType}}.md){{/generateModelDocs}}{{^generateModelDocs}}**{{dataType}}**{{/generateModelDocs}}{{/isFile}}{{/isPrimitiveType}}| {{description}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{defaultValue}}]{{/defaultValue}}{{#allowableValues}} [enum: {{#values}}{{{.}}}{{^-last}}, {{/-last}}{{/values}}]{{/allowableValues}} +{{/allParams}} + +### Return type + +{{#returnType}}{{#returnTypeIsPrimitive}}**{{returnType}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}{{#generateModelDocs}}[**{{returnType}}**]({{returnBaseType}}.md){{/generateModelDocs}}{{^generateModelDocs}}**{{returnType}}**{{/generateModelDocs}}{{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}null (empty response body){{/returnType}} + +### Authorization + +{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{name}}](../README.md#{{name}}){{^-last}}, {{/-last}}{{/authMethods}} + +### HTTP request headers + + - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} + - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}} + +{{/operation}} +{{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/kotlin-client/class_doc.mustache b/modules/swagger-codegen/src/main/resources/kotlin-client/class_doc.mustache new file mode 100644 index 00000000000..45e19942734 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/kotlin-client/class_doc.mustache @@ -0,0 +1,15 @@ +# {{classname}} + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +{{#vars}}**{{name}}** | {{#isEnum}}[**inline**](#{{datatypeWithEnum}}){{/isEnum}}{{^isEnum}}{{#isPrimitiveType}}**{{datatype}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{datatype}}**]({{complexType}}.md){{/isPrimitiveType}}{{/isEnum}} | {{description}} | {{^required}} [optional]{{/required}}{{#readOnly}} [readonly]{{/readOnly}} +{{/vars}} +{{#vars}}{{#isEnum}} + +{{!NOTE: see java's resources "pojo_doc.mustache" once enums are fully implemented}} +## Enum: {{baseName}} +Name | Value +---- | -----{{#allowableValues}} +{{name}} | {{#values}}{{.}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}} +{{/isEnum}}{{/vars}} diff --git a/modules/swagger-codegen/src/main/resources/kotlin-client/enum_doc.mustache b/modules/swagger-codegen/src/main/resources/kotlin-client/enum_doc.mustache new file mode 100644 index 00000000000..fcb3d7e61aa --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/kotlin-client/enum_doc.mustache @@ -0,0 +1,7 @@ +# {{classname}} + +## Enum + +{{#allowableValues}}{{#enumVars}} + * `{{name}}` (value: `{{{value}}}`) +{{/enumVars}}{{/allowableValues}} diff --git a/modules/swagger-codegen/src/main/resources/kotlin-client/model_doc.mustache b/modules/swagger-codegen/src/main/resources/kotlin-client/model_doc.mustache new file mode 100644 index 00000000000..e3b71842118 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/kotlin-client/model_doc.mustache @@ -0,0 +1,3 @@ +{{#models}}{{#model}} +{{#isEnum}}{{>enum_doc}}{{/isEnum}}{{^isEnum}}{{>class_doc}}{{/isEnum}} +{{/model}}{{/models}} diff --git a/samples/client/kotlin/README.md b/samples/client/kotlin/README.md index 885688a0fd6..410e14e4adb 100644 --- a/samples/client/kotlin/README.md +++ b/samples/client/kotlin/README.md @@ -1,4 +1,4 @@ -# Generated Kotlin Client library +# io.swagger.client - Kotlin client library for Swagger Petstore ## Requires @@ -14,16 +14,77 @@ gradle wrapper ``` Then, run: - + ``` ./gradlew check assemble ``` This runs all tests and packages the library. -## Notes +## Features/Implementation Notes * Supports JSON inputs/outputs, File inputs, and Form inputs. * Supports collection formats for query parameters: csv, tsv, ssv, pipes. * Some Kotlin and Java types are fully qualified to avoid conflicts with types defined in Swagger definitions. -* Implementation of ApiClient is intended to reduce method counts, specifically to benefit Android targets. \ No newline at end of file +* Implementation of ApiClient is intended to reduce method counts, specifically to benefit Android targets. + + +## 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* | [**deletePet**](docs/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**findPetsByStatus**](docs/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**findPetsByTags**](docs/PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**getPetById**](docs/PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**updatePet**](docs/PetApi.md#updatepet) | **PUT** /pet | Update an existing pet +*PetApi* | [**updatePetWithForm**](docs/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data +*PetApi* | [**uploadFile**](docs/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image +*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*StoreApi* | [**getInventory**](docs/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**getOrderById**](docs/StoreApi.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID +*StoreApi* | [**placeOrder**](docs/StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet +*UserApi* | [**createUser**](docs/UserApi.md#createuser) | **POST** /user | Create user +*UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**createUsersWithListInput**](docs/UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**deleteUser**](docs/UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user +*UserApi* | [**getUserByName**](docs/UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name +*UserApi* | [**loginUser**](docs/UserApi.md#loginuser) | **GET** /user/login | Logs user into the system +*UserApi* | [**logoutUser**](docs/UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**updateUser**](docs/UserApi.md#updateuser) | **PUT** /user/{username} | Updated user + + + +## Documentation for Models + + - [io.swagger.client.models.ApiResponse](docs/ApiResponse.md) + - [io.swagger.client.models.Category](docs/Category.md) + - [io.swagger.client.models.Order](docs/Order.md) + - [io.swagger.client.models.Pet](docs/Pet.md) + - [io.swagger.client.models.Tag](docs/Tag.md) + - [io.swagger.client.models.User](docs/User.md) + + + +## Documentation for Authorization + + +### api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + + +### petstore_auth + +- **Type**: OAuth +- **Flow**: implicit +- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - write:pets: modify pets in your account + - read:pets: read your pets + From 9282098d722b5f66d5297c9c74f0eea867e64363 Mon Sep 17 00:00:00 2001 From: wing328 Date: Tue, 30 May 2017 22:07:53 +0800 Subject: [PATCH 2/4] remove unused folder --- .../XhhGitIgnore/sdk_unit_testing_binary.json | 67 ------------------- .../sdk_unit_testing_file_downloading.json | 30 --------- 2 files changed, 97 deletions(-) delete mode 100644 modules/swagger-codegen/XhhGitIgnore/sdk_unit_testing_binary.json delete mode 100644 modules/swagger-codegen/XhhGitIgnore/sdk_unit_testing_file_downloading.json diff --git a/modules/swagger-codegen/XhhGitIgnore/sdk_unit_testing_binary.json b/modules/swagger-codegen/XhhGitIgnore/sdk_unit_testing_binary.json deleted file mode 100644 index 2d87e3bcb7f..00000000000 --- a/modules/swagger-codegen/XhhGitIgnore/sdk_unit_testing_binary.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "version": "1.0.0", - "title": "SDK Unit Testing - File Downloading" - }, - "schemes": [ - "http" - ], - "host": "localhost:3000", - "basePath": "/unittesting", - "paths": { - "/request/file_uploading": { - "get": { - "operationId": "file_uploading", - "tags": [ - "Request" - ], - "parameters": [ - {"name": "f1", - "in": "formData", - "type": "string", - "format": "binary", - "required": true - }, - {"name": "f2", - "in": "formData", - "type": "string", - "format": "binary", - "required": false - } - ], - "consumes": [ - "multipart/form-data" - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "string" - } - } - } - } - }, - "/response/file_downloading": { - "get": { - "operationId": "file_downloading", - "tags": [ - "Response" - ], - "produces": [ - "multipart/form-data" - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "string", - "format": "binary" - } - } - } - } - } - } -} diff --git a/modules/swagger-codegen/XhhGitIgnore/sdk_unit_testing_file_downloading.json b/modules/swagger-codegen/XhhGitIgnore/sdk_unit_testing_file_downloading.json deleted file mode 100644 index 6169272c05d..00000000000 --- a/modules/swagger-codegen/XhhGitIgnore/sdk_unit_testing_file_downloading.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "version": "1.0.0", - "title": "SDK Unit Testing - File Downloading" - }, - "schemes": [ - "http" - ], - "host": "localhost:3000", - "basePath": "/unittesting", - "paths": { - "/response/file_downloading": { - "get": { - "operationId": "file_downloading", - "tags": [ - "Response" - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "file" - } - } - } - } - } - } -} \ No newline at end of file From 23cf641e8a9583a9a9e3c52038780c6c42db14a1 Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Tue, 30 May 2017 12:18:37 -0400 Subject: [PATCH 3/4] Kotlin client lists (#5729) * [kotlin] array->List instead of Array Serialization to/from primitive arrays can cause issues with valid responses. This commit considers swagger 'array' types as 'List' which, although not as memory efficient should provide a cleaner interface for users (and avoid serialization issues). Also, updates README.md to list new generator and excludes folder at samples/client/kotlin/bin/, which is not used. * [kotlin] Move sample under conventional directory samples/client/kotlin/ -> samples/client/petstore/kotlin/ Updated new.sh to generate client/server/docs into similar structure. Current documentation generators (cwiki, html, html.md, html2) aren't following a convention like client/server generators. --- README.md | 4 +- bin/kotlin-client-petstore.sh | 2 +- .../languages/KotlinClientCodegen.java | 4 +- .../kotlin/KotlinClientCodegenModelTest.java | 4 +- new.sh | 2 +- samples/client/kotlin/build.gradle | 32 ---------------- samples/client/kotlin/settings.gradle | 1 - .../client/{ => petstore}/kotlin/.gitignore | 2 +- .../kotlin/.swagger-codegen-ignore | 0 .../kotlin/.swagger-codegen/VERSION | 0 .../client/{ => petstore}/kotlin/README.md | 0 .../bin => petstore/kotlin}/build.gradle | 0 .../kotlin/gradle/wrapper/gradle-wrapper.jar | Bin 54208 -> 54208 bytes .../gradle/wrapper/gradle-wrapper.properties | 2 +- samples/client/{ => petstore}/kotlin/gradlew | 0 .../client/{ => petstore}/kotlin/gradlew.bat | 0 .../bin => petstore/kotlin}/settings.gradle | 0 .../kotlin/io/swagger/client/apis/PetApi.kt | 16 ++++---- .../kotlin/io/swagger/client/apis/StoreApi.kt | 0 .../kotlin/io/swagger/client/apis/UserApi.kt | 4 +- .../client/infrastructure/ApiClient.kt | 0 .../ApiInfrastructureResponse.kt | 0 .../infrastructure/ApplicationDelegates.kt | 0 .../swagger/client/infrastructure/Errors.kt | 0 .../client/infrastructure/RequestConfig.kt | 0 .../client/infrastructure/RequestMethod.kt | 0 .../infrastructure/ResponseExtensions.kt | 0 .../client/infrastructure/Serializer.kt | 0 .../io/swagger/client/models/ApiResponse.kt | 0 .../io/swagger/client/models/Category.kt | 0 .../kotlin/io/swagger/client/models/Order.kt | 0 .../kotlin/io/swagger/client/models/Pet.kt | 4 +- .../kotlin/io/swagger/client/models/Tag.kt | 0 .../kotlin/io/swagger/client/models/User.kt | 0 .../swagger/client/functional/EvaluateTest.kt | 35 ++++++++++++++++++ 35 files changed, 58 insertions(+), 54 deletions(-) delete mode 100644 samples/client/kotlin/build.gradle delete mode 100644 samples/client/kotlin/settings.gradle rename samples/client/{ => petstore}/kotlin/.gitignore (99%) rename samples/client/{ => petstore}/kotlin/.swagger-codegen-ignore (100%) rename samples/client/{ => petstore}/kotlin/.swagger-codegen/VERSION (100%) rename samples/client/{ => petstore}/kotlin/README.md (100%) rename samples/client/{kotlin/bin => petstore/kotlin}/build.gradle (100%) rename samples/client/{ => petstore}/kotlin/gradle/wrapper/gradle-wrapper.jar (99%) rename samples/client/{ => petstore}/kotlin/gradle/wrapper/gradle-wrapper.properties (86%) rename samples/client/{ => petstore}/kotlin/gradlew (100%) rename samples/client/{ => petstore}/kotlin/gradlew.bat (100%) rename samples/client/{kotlin/bin => petstore/kotlin}/settings.gradle (100%) rename samples/client/{ => petstore}/kotlin/src/main/kotlin/io/swagger/client/apis/PetApi.kt (96%) rename samples/client/{ => petstore}/kotlin/src/main/kotlin/io/swagger/client/apis/StoreApi.kt (100%) rename samples/client/{ => petstore}/kotlin/src/main/kotlin/io/swagger/client/apis/UserApi.kt (98%) rename samples/client/{ => petstore}/kotlin/src/main/kotlin/io/swagger/client/infrastructure/ApiClient.kt (100%) rename samples/client/{ => petstore}/kotlin/src/main/kotlin/io/swagger/client/infrastructure/ApiInfrastructureResponse.kt (100%) rename samples/client/{ => petstore}/kotlin/src/main/kotlin/io/swagger/client/infrastructure/ApplicationDelegates.kt (100%) rename samples/client/{ => petstore}/kotlin/src/main/kotlin/io/swagger/client/infrastructure/Errors.kt (100%) rename samples/client/{ => petstore}/kotlin/src/main/kotlin/io/swagger/client/infrastructure/RequestConfig.kt (100%) rename samples/client/{ => petstore}/kotlin/src/main/kotlin/io/swagger/client/infrastructure/RequestMethod.kt (100%) rename samples/client/{ => petstore}/kotlin/src/main/kotlin/io/swagger/client/infrastructure/ResponseExtensions.kt (100%) rename samples/client/{ => petstore}/kotlin/src/main/kotlin/io/swagger/client/infrastructure/Serializer.kt (100%) rename samples/client/{ => petstore}/kotlin/src/main/kotlin/io/swagger/client/models/ApiResponse.kt (100%) rename samples/client/{ => petstore}/kotlin/src/main/kotlin/io/swagger/client/models/Category.kt (100%) rename samples/client/{ => petstore}/kotlin/src/main/kotlin/io/swagger/client/models/Order.kt (100%) rename samples/client/{ => petstore}/kotlin/src/main/kotlin/io/swagger/client/models/Pet.kt (90%) rename samples/client/{ => petstore}/kotlin/src/main/kotlin/io/swagger/client/models/Tag.kt (100%) rename samples/client/{ => petstore}/kotlin/src/main/kotlin/io/swagger/client/models/User.kt (100%) create mode 100644 samples/client/petstore/kotlin/src/test/kotlin/io/swagger/client/functional/EvaluateTest.kt diff --git a/README.md b/README.md index 09b952dee03..39161f9efce 100644 --- a/README.md +++ b/README.md @@ -850,13 +850,14 @@ Swagger Codegen core team members are contributors who have been making signific |:-------------|:-------------| | ActionScript | | | C++ | | -| C# | @jimschubert (2016/05/01) | | +| C# | @jimschubert (2016/05/01) | | Clojure | @xhh (2016/05/01) | | Dart | | | Groovy | | | Go | @guohuang (2016/05/01) @neilotoole (2016/05/01) | | Java | @cbornet (2016/05/01) @xhh (2016/05/01) @epaul (2016/06/04) | | Java (Spring Cloud) | @cbornet (2016/07/19) | +| Kotlin | @jimschubert (2016/05/01) | | NodeJS/Javascript | @xhh (2016/05/01) | | ObjC | @mateuszmackowiak (2016/05/09) | | Perl | @wing328 (2016/05/01) | @@ -916,6 +917,7 @@ Here is a list of template creators: * Javascript/NodeJS: @jfiala * Javascript (Closure-annotated Angular) @achew22 * JMeter @davidkiss + * Kotlin @jimschubert * Perl: @wing328 * PHP (Guzzle): @baartosz * Swift: @tkqubo diff --git a/bin/kotlin-client-petstore.sh b/bin/kotlin-client-petstore.sh index fa017f1e8ef..1db46737d20 100755 --- a/bin/kotlin-client-petstore.sh +++ b/bin/kotlin-client-petstore.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -t modules/swagger-codegen/src/main/resources/kotlin-client -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l kotlin -o samples/client/kotlin" +ags="$@ generate -t modules/swagger-codegen/src/main/resources/kotlin-client -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l kotlin -o samples/client/petstore/kotlin" java ${JAVA_OPTS} -jar ${executable} ${ags} diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/KotlinClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/KotlinClientCodegen.java index aa1a0039ded..1012e3039e5 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/KotlinClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/KotlinClientCodegen.java @@ -122,7 +122,7 @@ public class KotlinClientCodegen extends DefaultCodegen implements CodegenConfig typeMapping.put("date-time", "java.time.LocalDateTime"); typeMapping.put("date", "java.time.LocalDateTime"); typeMapping.put("file", "java.io.File"); - typeMapping.put("array", "kotlin.Array"); + typeMapping.put("array", "kotlin.collections.List"); typeMapping.put("list", "kotlin.collections.List"); typeMapping.put("map", "kotlin.collections.Map"); typeMapping.put("object", "kotlin.Any"); @@ -130,7 +130,7 @@ public class KotlinClientCodegen extends DefaultCodegen implements CodegenConfig typeMapping.put("Date", "java.time.LocalDateTime"); typeMapping.put("DateTime", "java.time.LocalDateTime"); - instantiationTypes.put("array", "arrayOf"); + instantiationTypes.put("array", "listOf"); instantiationTypes.put("list", "listOf"); instantiationTypes.put("map", "mapOf"); diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/kotlin/KotlinClientCodegenModelTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/kotlin/KotlinClientCodegenModelTest.java index 23bf434bf3f..474806638d6 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/kotlin/KotlinClientCodegenModelTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/kotlin/KotlinClientCodegenModelTest.java @@ -104,10 +104,10 @@ public class KotlinClientCodegenModelTest { Assert.assertEquals(property.baseName, "examples"); Assert.assertEquals(property.getter, "getExamples"); Assert.assertEquals(property.setter, "setExamples"); - Assert.assertEquals(property.datatype, "kotlin.Array"); + Assert.assertEquals(property.datatype, "kotlin.collections.List"); Assert.assertEquals(property.name, "examples"); Assert.assertEquals(property.defaultValue, "null"); - Assert.assertEquals(property.baseType, "kotlin.Array"); + Assert.assertEquals(property.baseType, "kotlin.collections.List"); Assert.assertEquals(property.containerType, "array"); Assert.assertFalse(property.required); Assert.assertTrue(property.isContainer); diff --git a/new.sh b/new.sh index 8c71230d50a..cace3efcad3 100755 --- a/new.sh +++ b/new.sh @@ -160,7 +160,7 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="\${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="\$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l ${gen_name} -o samples/${gen_type}/${gen_name}" +ags="\$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l ${gen_name} -o samples/${gen_type}/petstore/${gen_name}" java \${JAVA_OPTS} -jar \${executable} \${ags} EOF diff --git a/samples/client/kotlin/build.gradle b/samples/client/kotlin/build.gradle deleted file mode 100644 index 1ae1ae99322..00000000000 --- a/samples/client/kotlin/build.gradle +++ /dev/null @@ -1,32 +0,0 @@ -group 'io.swagger' -version '1.0.0' - -task wrapper(type: Wrapper) { - gradleVersion = '3.3' - distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip" -} - -buildscript { - ext.kotlin_version = '1.1.2' - - repositories { - mavenCentral() - } - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - -apply plugin: 'kotlin' - -repositories { - mavenCentral() -} - -dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version" - compile "com.squareup.moshi:moshi-kotlin:1.5.0" - compile "com.squareup.moshi:moshi-adapters:1.5.0" - compile "com.squareup.okhttp3:okhttp:3.8.0" - testCompile "io.kotlintest:kotlintest:2.0.2" -} \ No newline at end of file diff --git a/samples/client/kotlin/settings.gradle b/samples/client/kotlin/settings.gradle deleted file mode 100644 index 50b05bef95e..00000000000 --- a/samples/client/kotlin/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'kotlin-client' \ No newline at end of file diff --git a/samples/client/kotlin/.gitignore b/samples/client/petstore/kotlin/.gitignore similarity index 99% rename from samples/client/kotlin/.gitignore rename to samples/client/petstore/kotlin/.gitignore index fe1b206d040..2983e3c1db3 100644 --- a/samples/client/kotlin/.gitignore +++ b/samples/client/petstore/kotlin/.gitignore @@ -1,4 +1,4 @@ - +./bin/ # Created by https://www.gitignore.io/api/java,intellij,gradle ### Intellij ### diff --git a/samples/client/kotlin/.swagger-codegen-ignore b/samples/client/petstore/kotlin/.swagger-codegen-ignore similarity index 100% rename from samples/client/kotlin/.swagger-codegen-ignore rename to samples/client/petstore/kotlin/.swagger-codegen-ignore diff --git a/samples/client/kotlin/.swagger-codegen/VERSION b/samples/client/petstore/kotlin/.swagger-codegen/VERSION similarity index 100% rename from samples/client/kotlin/.swagger-codegen/VERSION rename to samples/client/petstore/kotlin/.swagger-codegen/VERSION diff --git a/samples/client/kotlin/README.md b/samples/client/petstore/kotlin/README.md similarity index 100% rename from samples/client/kotlin/README.md rename to samples/client/petstore/kotlin/README.md diff --git a/samples/client/kotlin/bin/build.gradle b/samples/client/petstore/kotlin/build.gradle similarity index 100% rename from samples/client/kotlin/bin/build.gradle rename to samples/client/petstore/kotlin/build.gradle diff --git a/samples/client/kotlin/gradle/wrapper/gradle-wrapper.jar b/samples/client/petstore/kotlin/gradle/wrapper/gradle-wrapper.jar similarity index 99% rename from samples/client/kotlin/gradle/wrapper/gradle-wrapper.jar rename to samples/client/petstore/kotlin/gradle/wrapper/gradle-wrapper.jar index 45ac8213b78add5980ffe40fadbe9564ea7a4e68..f1a1584ef4a765de06bd01c8bb0cc5c2d8ef3ce8 100644 GIT binary patch delta 24 fcmX@GocX|V<_*z@m>$(^jy)tS2&5+$UG@V2k~a%} delta 24 fcmX@GocX|V<_*z@n4-fs#~uF8cuhg%JuS diff --git a/samples/client/kotlin/gradle/wrapper/gradle-wrapper.properties b/samples/client/petstore/kotlin/gradle/wrapper/gradle-wrapper.properties similarity index 86% rename from samples/client/kotlin/gradle/wrapper/gradle-wrapper.properties rename to samples/client/petstore/kotlin/gradle/wrapper/gradle-wrapper.properties index 1d03d7af2f3..09c0ff530a8 100644 --- a/samples/client/kotlin/gradle/wrapper/gradle-wrapper.properties +++ b/samples/client/petstore/kotlin/gradle/wrapper/gradle-wrapper.properties @@ -1,4 +1,4 @@ -#Mon May 29 10:58:54 EDT 2017 +#Mon May 29 15:39:04 EDT 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/samples/client/kotlin/gradlew b/samples/client/petstore/kotlin/gradlew similarity index 100% rename from samples/client/kotlin/gradlew rename to samples/client/petstore/kotlin/gradlew diff --git a/samples/client/kotlin/gradlew.bat b/samples/client/petstore/kotlin/gradlew.bat similarity index 100% rename from samples/client/kotlin/gradlew.bat rename to samples/client/petstore/kotlin/gradlew.bat diff --git a/samples/client/kotlin/bin/settings.gradle b/samples/client/petstore/kotlin/settings.gradle similarity index 100% rename from samples/client/kotlin/bin/settings.gradle rename to samples/client/petstore/kotlin/settings.gradle diff --git a/samples/client/kotlin/src/main/kotlin/io/swagger/client/apis/PetApi.kt b/samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/apis/PetApi.kt similarity index 96% rename from samples/client/kotlin/src/main/kotlin/io/swagger/client/apis/PetApi.kt rename to samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/apis/PetApi.kt index 336843fceec..a01400aa9d9 100644 --- a/samples/client/kotlin/src/main/kotlin/io/swagger/client/apis/PetApi.kt +++ b/samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/apis/PetApi.kt @@ -85,10 +85,10 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli * Finds Pets by status * Multiple status values can be provided with comma separated strings * @param status Status values that need to be considered for filter - * @return kotlin.Array + * @return kotlin.collections.List */ @Suppress("UNCHECKED_CAST") - fun findPetsByStatus(status: kotlin.Array) : kotlin.Array { + fun findPetsByStatus(status: kotlin.collections.List) : kotlin.collections.List { val localVariableBody: kotlin.Any? = null val localVariableQuery: kotlin.collections.Map = mapOf("status" to status.joinToString(separator = collectionDelimiter("csv"))) val localVariableHeaders: kotlin.collections.Map = mapOf() @@ -98,13 +98,13 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request>( + val response = request>( localVariableConfig, localVariableBody ) return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.Array + ResponseType.Success -> (response as Success<*>).data as kotlin.collections.List ResponseType.Informational -> TODO() ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") @@ -117,10 +117,10 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli * Finds Pets by tags * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by - * @return kotlin.Array + * @return kotlin.collections.List */ @Suppress("UNCHECKED_CAST") - fun findPetsByTags(tags: kotlin.Array) : kotlin.Array { + fun findPetsByTags(tags: kotlin.collections.List) : kotlin.collections.List { val localVariableBody: kotlin.Any? = null val localVariableQuery: kotlin.collections.Map = mapOf("tags" to tags.joinToString(separator = collectionDelimiter("csv"))) val localVariableHeaders: kotlin.collections.Map = mapOf() @@ -130,13 +130,13 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli query = localVariableQuery, headers = localVariableHeaders ) - val response = request>( + val response = request>( localVariableConfig, localVariableBody ) return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.Array + ResponseType.Success -> (response as Success<*>).data as kotlin.collections.List ResponseType.Informational -> TODO() ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") diff --git a/samples/client/kotlin/src/main/kotlin/io/swagger/client/apis/StoreApi.kt b/samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/apis/StoreApi.kt similarity index 100% rename from samples/client/kotlin/src/main/kotlin/io/swagger/client/apis/StoreApi.kt rename to samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/apis/StoreApi.kt diff --git a/samples/client/kotlin/src/main/kotlin/io/swagger/client/apis/UserApi.kt b/samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/apis/UserApi.kt similarity index 98% rename from samples/client/kotlin/src/main/kotlin/io/swagger/client/apis/UserApi.kt rename to samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/apis/UserApi.kt index b61953eaa61..e703c71bcdd 100644 --- a/samples/client/kotlin/src/main/kotlin/io/swagger/client/apis/UserApi.kt +++ b/samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/apis/UserApi.kt @@ -54,7 +54,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl * @param body List of user object * @return void */ - fun createUsersWithArrayInput(body: kotlin.Array) : Unit { + fun createUsersWithArrayInput(body: kotlin.collections.List) : Unit { val localVariableBody: kotlin.Any? = body val localVariableQuery: kotlin.collections.Map = mapOf() val localVariableHeaders: kotlin.collections.Map = mapOf() @@ -85,7 +85,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl * @param body List of user object * @return void */ - fun createUsersWithListInput(body: kotlin.Array) : Unit { + fun createUsersWithListInput(body: kotlin.collections.List) : Unit { val localVariableBody: kotlin.Any? = body val localVariableQuery: kotlin.collections.Map = mapOf() val localVariableHeaders: kotlin.collections.Map = mapOf() diff --git a/samples/client/kotlin/src/main/kotlin/io/swagger/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/infrastructure/ApiClient.kt similarity index 100% rename from samples/client/kotlin/src/main/kotlin/io/swagger/client/infrastructure/ApiClient.kt rename to samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/infrastructure/ApiClient.kt diff --git a/samples/client/kotlin/src/main/kotlin/io/swagger/client/infrastructure/ApiInfrastructureResponse.kt b/samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/infrastructure/ApiInfrastructureResponse.kt similarity index 100% rename from samples/client/kotlin/src/main/kotlin/io/swagger/client/infrastructure/ApiInfrastructureResponse.kt rename to samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/infrastructure/ApiInfrastructureResponse.kt diff --git a/samples/client/kotlin/src/main/kotlin/io/swagger/client/infrastructure/ApplicationDelegates.kt b/samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/infrastructure/ApplicationDelegates.kt similarity index 100% rename from samples/client/kotlin/src/main/kotlin/io/swagger/client/infrastructure/ApplicationDelegates.kt rename to samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/infrastructure/ApplicationDelegates.kt diff --git a/samples/client/kotlin/src/main/kotlin/io/swagger/client/infrastructure/Errors.kt b/samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/infrastructure/Errors.kt similarity index 100% rename from samples/client/kotlin/src/main/kotlin/io/swagger/client/infrastructure/Errors.kt rename to samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/infrastructure/Errors.kt diff --git a/samples/client/kotlin/src/main/kotlin/io/swagger/client/infrastructure/RequestConfig.kt b/samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/infrastructure/RequestConfig.kt similarity index 100% rename from samples/client/kotlin/src/main/kotlin/io/swagger/client/infrastructure/RequestConfig.kt rename to samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/infrastructure/RequestConfig.kt diff --git a/samples/client/kotlin/src/main/kotlin/io/swagger/client/infrastructure/RequestMethod.kt b/samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/infrastructure/RequestMethod.kt similarity index 100% rename from samples/client/kotlin/src/main/kotlin/io/swagger/client/infrastructure/RequestMethod.kt rename to samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/infrastructure/RequestMethod.kt diff --git a/samples/client/kotlin/src/main/kotlin/io/swagger/client/infrastructure/ResponseExtensions.kt b/samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/infrastructure/ResponseExtensions.kt similarity index 100% rename from samples/client/kotlin/src/main/kotlin/io/swagger/client/infrastructure/ResponseExtensions.kt rename to samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/infrastructure/ResponseExtensions.kt diff --git a/samples/client/kotlin/src/main/kotlin/io/swagger/client/infrastructure/Serializer.kt b/samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/infrastructure/Serializer.kt similarity index 100% rename from samples/client/kotlin/src/main/kotlin/io/swagger/client/infrastructure/Serializer.kt rename to samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/infrastructure/Serializer.kt diff --git a/samples/client/kotlin/src/main/kotlin/io/swagger/client/models/ApiResponse.kt b/samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/models/ApiResponse.kt similarity index 100% rename from samples/client/kotlin/src/main/kotlin/io/swagger/client/models/ApiResponse.kt rename to samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/models/ApiResponse.kt diff --git a/samples/client/kotlin/src/main/kotlin/io/swagger/client/models/Category.kt b/samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/models/Category.kt similarity index 100% rename from samples/client/kotlin/src/main/kotlin/io/swagger/client/models/Category.kt rename to samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/models/Category.kt diff --git a/samples/client/kotlin/src/main/kotlin/io/swagger/client/models/Order.kt b/samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/models/Order.kt similarity index 100% rename from samples/client/kotlin/src/main/kotlin/io/swagger/client/models/Order.kt rename to samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/models/Order.kt diff --git a/samples/client/kotlin/src/main/kotlin/io/swagger/client/models/Pet.kt b/samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/models/Pet.kt similarity index 90% rename from samples/client/kotlin/src/main/kotlin/io/swagger/client/models/Pet.kt rename to samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/models/Pet.kt index 210d6258545..31842fa7499 100644 --- a/samples/client/kotlin/src/main/kotlin/io/swagger/client/models/Pet.kt +++ b/samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/models/Pet.kt @@ -27,8 +27,8 @@ data class Pet ( val id: kotlin.Long?, val category: Category?, val name: kotlin.String, - val photoUrls: kotlin.Array, - val tags: kotlin.Array?, + val photoUrls: kotlin.collections.List, + val tags: kotlin.collections.List?, /* pet status in the store */ val status: kotlin.String? ) diff --git a/samples/client/kotlin/src/main/kotlin/io/swagger/client/models/Tag.kt b/samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/models/Tag.kt similarity index 100% rename from samples/client/kotlin/src/main/kotlin/io/swagger/client/models/Tag.kt rename to samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/models/Tag.kt diff --git a/samples/client/kotlin/src/main/kotlin/io/swagger/client/models/User.kt b/samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/models/User.kt similarity index 100% rename from samples/client/kotlin/src/main/kotlin/io/swagger/client/models/User.kt rename to samples/client/petstore/kotlin/src/main/kotlin/io/swagger/client/models/User.kt diff --git a/samples/client/petstore/kotlin/src/test/kotlin/io/swagger/client/functional/EvaluateTest.kt b/samples/client/petstore/kotlin/src/test/kotlin/io/swagger/client/functional/EvaluateTest.kt new file mode 100644 index 00000000000..8983641ce38 --- /dev/null +++ b/samples/client/petstore/kotlin/src/test/kotlin/io/swagger/client/functional/EvaluateTest.kt @@ -0,0 +1,35 @@ +package io.swagger.client.functional + +import io.kotlintest.matchers.should +import io.kotlintest.matchers.beGreaterThan +import io.kotlintest.specs.ShouldSpec +import io.swagger.client.apis.PetApi + +class EvaluateTest : ShouldSpec() { + init { + should("query against pet statuses") { + val api = PetApi() + val results = api.findPetsByStatus(listOf("available", "pending")) + + results.size should beGreaterThan(1) + } + +// TODO: Handle default (200) response +/* + should("post data (new pet)") { + val api = PetApi() + val pet = Pet( + id = 0, + name = "kotlin client test", + category = Category(0, "string"), + tags = listOf(Tag(0, "string")) + ) + val result = api.addPet(pet) + + result.name shouldBe(pet.name) + result.category shouldBe(pet.category) + result.tags shouldBe(pet.tags) + } +*/ + } +} \ No newline at end of file From 31a8ac6987c3b39a92d619d7e498dfddae60d29c Mon Sep 17 00:00:00 2001 From: Casey Fulton Date: Wed, 31 May 2017 17:47:42 +0930 Subject: [PATCH 4/4] [docker] Run as non-root user, fixes permissions. (#5702) --- docker-entrypoint.sh | 2 +- run-in-docker.sh | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 7faa46aba34..556b6ff2f63 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -14,7 +14,7 @@ pattern="@Command(name = \"$1\"" if expr "x$1" : 'x[a-z][a-z-]*$' > /dev/null && fgrep -qe "$pattern" "$cmdsrc"/*.java; then # If ${GEN_DIR} has been mapped elsewhere from default, and that location has not been built if [[ ! -f "${codegen}" ]]; then - (cd "${GEN_DIR}" && exec mvn -am -pl "modules/swagger-codegen-cli" package) + (cd "${GEN_DIR}" && exec mvn -am -pl "modules/swagger-codegen-cli" -Duser.home=$(dirname MAVEN_CONFIG) package) fi command=$1 shift diff --git a/run-in-docker.sh b/run-in-docker.sh index 99581115871..8cf6cc64de2 100755 --- a/run-in-docker.sh +++ b/run-in-docker.sh @@ -10,7 +10,9 @@ mkdir -p "${maven_cache_repo}" docker run --rm -it \ -w /gen \ -e GEN_DIR=/gen \ + -e MAVEN_CONFIG=/var/maven/.m2 \ + -u "$(id -u):$(id -u)" \ -v "${PWD}:/gen" \ - -v "${maven_cache_repo}:/root/.m2/repository" \ + -v "${maven_cache_repo}:/var/maven/.m2/repository" \ --entrypoint /gen/docker-entrypoint.sh \ maven:3-jdk-7 "$@"