From 7d9f9d7e8180b8bee07fa9e13d242b3d0fbf220d Mon Sep 17 00:00:00 2001 From: Oscar Reyes Date: Sat, 9 Mar 2024 01:34:12 -0500 Subject: [PATCH] [kotlin-spring] Fix cookie parameter code generation in API (#17959) * + Cookie parameter generation fixed * Added cookie parameter mustache template for generating cookie related code * Adapted kotlin-spring api templates to include cookie parameters * Added tests for evaluating cookie parameter code generation * Added configuration sample for the new cookie use case * - Unused fake cases removed * Removed fake cases from openapi spec that were not related to cookie usage * Cleaned sample files --- .../kotlin-spring-boot-request-cookie.yaml | 9 + .../main/resources/kotlin-spring/api.mustache | 2 +- .../kotlin-spring/apiInterface.mustache | 2 +- .../kotlin-spring/cookieParams.mustache | 1 + .../spring/KotlinSpringServerCodegenTest.java | 42 + ...ake-endpoints-for-testing-with-cookie.yaml | 859 ++++++++++++++++++ .../.openapi-generator-ignore | 23 + .../.openapi-generator/FILES | 26 + .../.openapi-generator/VERSION | 1 + .../README.md | 21 + .../build.gradle.kts | 43 + .../kotlin-springboot-request-cookie/pom.xml | 138 +++ .../settings.gradle | 15 + .../openapitools/SpringDocConfiguration.kt | 60 ++ .../kotlin/org/openapitools/api/ApiUtil.kt | 19 + .../kotlin/org/openapitools/api/Exceptions.kt | 29 + .../kotlin/org/openapitools/api/FakeApi.kt | 58 ++ .../openapitools/api/FakeClassnameTestApi.kt | 60 ++ .../kotlin/org/openapitools/api/FooApi.kt | 58 ++ .../kotlin/org/openapitools/api/PetApi.kt | 203 +++++ .../kotlin/org/openapitools/api/StoreApi.kt | 117 +++ .../kotlin/org/openapitools/api/UserApi.kt | 187 ++++ .../kotlin/org/openapitools/model/Animal.kt | 39 + .../main/kotlin/org/openapitools/model/Cat.kt | 34 + .../kotlin/org/openapitools/model/Category.kt | 31 + .../kotlin/org/openapitools/model/Client.kt | 27 + .../main/kotlin/org/openapitools/model/Dog.kt | 34 + .../main/kotlin/org/openapitools/model/Foo.kt | 27 + .../model/FooGetDefaultResponse.kt | 29 + .../openapitools/model/ModelApiResponse.kt | 35 + .../kotlin/org/openapitools/model/Order.kt | 59 ++ .../main/kotlin/org/openapitools/model/Pet.kt | 63 ++ .../main/kotlin/org/openapitools/model/Tag.kt | 31 + .../kotlin/org/openapitools/model/User.kt | 55 ++ 34 files changed, 2435 insertions(+), 2 deletions(-) create mode 100644 bin/configs/kotlin-spring-boot-request-cookie.yaml create mode 100644 modules/openapi-generator/src/main/resources/kotlin-spring/cookieParams.mustache create mode 100644 modules/openapi-generator/src/test/resources/3_0/kotlin/petstore-with-fake-endpoints-for-testing-with-cookie.yaml create mode 100644 samples/server/petstore/kotlin-springboot-request-cookie/.openapi-generator-ignore create mode 100644 samples/server/petstore/kotlin-springboot-request-cookie/.openapi-generator/FILES create mode 100644 samples/server/petstore/kotlin-springboot-request-cookie/.openapi-generator/VERSION create mode 100644 samples/server/petstore/kotlin-springboot-request-cookie/README.md create mode 100644 samples/server/petstore/kotlin-springboot-request-cookie/build.gradle.kts create mode 100644 samples/server/petstore/kotlin-springboot-request-cookie/pom.xml create mode 100644 samples/server/petstore/kotlin-springboot-request-cookie/settings.gradle create mode 100644 samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/SpringDocConfiguration.kt create mode 100644 samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/ApiUtil.kt create mode 100644 samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/Exceptions.kt create mode 100644 samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/FakeApi.kt create mode 100644 samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/FakeClassnameTestApi.kt create mode 100644 samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/FooApi.kt create mode 100644 samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/PetApi.kt create mode 100644 samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/StoreApi.kt create mode 100644 samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/UserApi.kt create mode 100644 samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Animal.kt create mode 100644 samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Cat.kt create mode 100644 samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Category.kt create mode 100644 samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Client.kt create mode 100644 samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Dog.kt create mode 100644 samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Foo.kt create mode 100644 samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/FooGetDefaultResponse.kt create mode 100644 samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt create mode 100644 samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Order.kt create mode 100644 samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Pet.kt create mode 100644 samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Tag.kt create mode 100644 samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/User.kt diff --git a/bin/configs/kotlin-spring-boot-request-cookie.yaml b/bin/configs/kotlin-spring-boot-request-cookie.yaml new file mode 100644 index 00000000000..fdf613630ae --- /dev/null +++ b/bin/configs/kotlin-spring-boot-request-cookie.yaml @@ -0,0 +1,9 @@ +generatorName: kotlin-spring +outputDir: samples/server/petstore/kotlin-springboot-request-cookie +library: spring-boot +inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/petstore-with-fake-endpoints-for-testing-with-cookie.yaml +templateDir: modules/openapi-generator/src/main/resources/kotlin-spring +additionalProperties: + appendRequestToHandler: true + interfaceOnly: true + useSpringBoot3: true \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/api.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/api.mustache index 6c308d94482..e1356d7f3fd 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/api.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/api.mustache @@ -90,7 +90,7 @@ class {{classname}}Controller({{#serviceInterface}}@Autowired(required = true) v produces = [{{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}}]{{/hasProduces}}{{#hasConsumes}}, consumes = [{{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}}]{{/hasConsumes}}{{/singleContentTypes}} ) - {{#reactive}}{{^isArray}}suspend {{/isArray}}{{/reactive}}fun {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{>requesObject}}{{^-last}},{{/-last}}{{/allParams}}): ResponseEntity<{{>returnTypes}}> { + {{#reactive}}{{^isArray}}suspend {{/isArray}}{{/reactive}}fun {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>cookieParams}}{{>bodyParams}}{{>formParams}}{{>requesObject}}{{^-last}},{{/-last}}{{/allParams}}): ResponseEntity<{{>returnTypes}}> { return {{>returnValue}} } {{/operation}} diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/apiInterface.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/apiInterface.mustache index 3a831d30687..e1cec3e2549 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/apiInterface.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/apiInterface.mustache @@ -102,7 +102,7 @@ interface {{classname}} { produces = [{{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}}]{{/hasProduces}}{{#hasConsumes}}, consumes = [{{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}}]{{/hasConsumes}}{{/singleContentTypes}} ) - {{#reactive}}{{^isArray}}suspend {{/isArray}}{{/reactive}}fun {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{>requesObject}}{{^-last}},{{/-last}}{{/allParams}}): ResponseEntity<{{>returnTypes}}>{{^skipDefaultInterface}} { + {{#reactive}}{{^isArray}}suspend {{/isArray}}{{/reactive}}fun {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>cookieParams}}{{>bodyParams}}{{>formParams}}{{>requesObject}}{{^-last}},{{/-last}}{{/allParams}}): ResponseEntity<{{>returnTypes}}>{{^skipDefaultInterface}} { {{^isDelegate}} return {{>returnValue}} {{/isDelegate}} diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/cookieParams.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/cookieParams.mustache new file mode 100644 index 00000000000..deff1572afe --- /dev/null +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/cookieParams.mustache @@ -0,0 +1 @@ +{{#isCookieParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}@CookieValue(name = "{{baseName}}"{{^required}}, required = false{{/required}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}) {{paramName}}: {{>optionalDataType}}{{/isCookieParam}} \ No newline at end of file diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java index 35a92c66c5f..b7e23647cd6 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java @@ -435,6 +435,48 @@ public class KotlinSpringServerCodegenTest { ); } + @Test(description = "test cookie parameter generation on interface apis") + public void cookieParameterGenerationApis() throws Exception { + File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); + output.deleteOnExit(); + String outputPath = output.getAbsolutePath().replace('\\', '/'); + + KotlinSpringServerCodegen codegen = new KotlinSpringServerCodegen(); + codegen.setOutputDir(output.getAbsolutePath()); + codegen.additionalProperties().put(KotlinSpringServerCodegen.INTERFACE_ONLY, true); + codegen.additionalProperties().put(KotlinSpringServerCodegen.SKIP_DEFAULT_INTERFACE, true); + + new DefaultGenerator().opts(new ClientOptInput() + .openAPI(TestUtils.parseSpec("src/test/resources/3_0/kotlin/petstore-with-fake-endpoints-for-testing-with-cookie.yaml")) + .config(codegen)) + .generate(); + + assertFileContains( + Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/FakeApi.kt"), + "@CookieValue" + ); + } + + @Test(description = "test cookie parameter generation on controllers") + public void cookieParameterGenerationControllers() throws Exception { + File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); + output.deleteOnExit(); + String outputPath = output.getAbsolutePath().replace('\\', '/'); + + KotlinSpringServerCodegen codegen = new KotlinSpringServerCodegen(); + codegen.setOutputDir(output.getAbsolutePath()); + + new DefaultGenerator().opts(new ClientOptInput() + .openAPI(TestUtils.parseSpec("src/test/resources/3_0/kotlin/petstore-with-fake-endpoints-for-testing-with-cookie.yaml")) + .config(codegen)) + .generate(); + + assertFileContains( + Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/FakeApiController.kt"), + "@CookieValue" + ); + } + @Test(description = "use Spring boot 3 & jakarta extension") public void useSpringBoot3() throws Exception { File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); diff --git a/modules/openapi-generator/src/test/resources/3_0/kotlin/petstore-with-fake-endpoints-for-testing-with-cookie.yaml b/modules/openapi-generator/src/test/resources/3_0/kotlin/petstore-with-fake-endpoints-for-testing-with-cookie.yaml new file mode 100644 index 00000000000..883c3044f70 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/kotlin/petstore-with-fake-endpoints-for-testing-with-cookie.yaml @@ -0,0 +1,859 @@ +openapi: 3.0.0 +info: + description: >- + This spec is mainly for testing Petstore server and contains fake endpoints, + models. Please do not use this for any other purpose. Special characters: " + \ + version: 1.0.0 + title: OpenAPI Petstore + license: + name: Apache-2.0 + url: 'https://www.apache.org/licenses/LICENSE-2.0.html' +tags: + - name: pet + description: Everything about your Pets + - name: store + description: Access to Petstore orders + - name: user + description: Operations about user +paths: + /foo: + get: + responses: + default: + description: response + content: + application/json: + schema: + type: object + properties: + string: + $ref: '#/components/schemas/Foo' + /pet: + servers: + - url: 'http://petstore.swagger.io/v2' + - url: 'http://path-server-test.petstore.local/v2' + - url: 'http://{server}.swagger.io:{port}/v2' + description: test server with variables + variables: + server: + description: target server + enum: + - 'petstore' + - 'qa-petstore' + - 'dev-petstore' + default: 'petstore' + port: + enum: + - 80 + - 8080 + default: 80 + post: + tags: + - pet + summary: Add a new pet to the store + description: '' + operationId: addPet + responses: + '200': + description: Successful operation + '405': + description: Invalid input + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + $ref: '#/components/requestBodies/Pet' + put: + tags: + - pet + summary: Update an existing pet + description: '' + operationId: updatePet + x-webclient-blocking: true + responses: + '200': + description: Successful operation + '400': + description: Invalid ID supplied + '404': + description: Pet not found + '405': + description: Validation exception + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + $ref: '#/components/requestBodies/Pet' + /pet/findByStatus: + get: + tags: + - pet + summary: Finds Pets by status + description: Multiple status values can be provided with comma separated strings + operationId: findPetsByStatus + x-webclient-blocking: true + parameters: + - name: status + in: query + description: Status values that need to be considered for filter + required: true + style: form + explode: false + deprecated: true + schema: + type: array + items: + type: string + enum: + - available + - pending + - sold + default: available + responses: + '200': + description: successful operation + content: + application/xml: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + '400': + description: Invalid status value + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + /pet/findByTags: + get: + tags: + - pet + summary: Finds Pets by tags + description: >- + Multiple tags can be provided with comma separated strings. Use tag1, + tag2, tag3 for testing. + operationId: findPetsByTags + parameters: + - name: tags + in: query + description: Tags to filter by + required: true + style: form + explode: false + schema: + type: array + items: + type: string + responses: + '200': + description: successful operation + content: + application/xml: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + '400': + description: Invalid tag value + security: + - petstore_auth: + - 'read:pets' + deprecated: true + '/pet/{petId}': + get: + tags: + - pet + summary: Find pet by ID + description: Returns a single pet + operationId: getPetById + x-webclient-blocking: true + parameters: + - name: petId + in: path + description: ID of pet to return + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Pet' + application/json: + schema: + $ref: '#/components/schemas/Pet' + '400': + description: Invalid ID supplied + '404': + description: Pet not found + security: + - api_key: [] + post: + tags: + - pet + summary: Updates a pet in the store with form data + description: '' + operationId: updatePetWithForm + parameters: + - name: petId + in: path + description: ID of pet that needs to be updated + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: Successful operation + '405': + description: Invalid input + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string + delete: + tags: + - pet + summary: Deletes a pet + description: '' + operationId: deletePet + parameters: + - name: api_key + in: header + required: false + schema: + type: string + - name: petId + in: path + description: Pet id to delete + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: Successful operation + '400': + description: Invalid pet value + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + '/pet/{petId}/uploadImage': + post: + tags: + - pet + summary: uploads an image + description: '' + operationId: uploadFile + parameters: + - name: petId + in: path + description: ID of pet to update + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + content: + multipart/form-data: + schema: + type: object + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + type: string + format: binary + /store/inventory: + get: + tags: + - store + summary: Returns pet inventories by status + description: Returns a map of status codes to quantities + operationId: getInventory + x-webclient-blocking: false + responses: + '200': + description: successful operation + content: + application/json: + schema: + type: object + additionalProperties: + type: integer + format: int32 + security: + - api_key: [] + /store/order: + post: + tags: + - store + summary: Place an order for a pet + description: '' + operationId: placeOrder + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Order' + application/json: + schema: + $ref: '#/components/schemas/Order' + '400': + description: Invalid Order + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Order' + description: order placed for purchasing the pet + required: true + '/store/order/{order_id}': + get: + tags: + - store + summary: Find purchase order by ID + description: >- + For valid response try integer IDs with value <= 5 or > 10. Other values + will generate exceptions + operationId: getOrderById + parameters: + - name: order_id + in: path + description: ID of pet that needs to be fetched + required: true + schema: + type: integer + format: int64 + minimum: 1 + maximum: 5 + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Order' + application/json: + schema: + $ref: '#/components/schemas/Order' + '400': + description: Invalid ID supplied + '404': + description: Order not found + delete: + tags: + - store + summary: Delete purchase order by ID + description: >- + For valid response try integer IDs with value < 1000. Anything above + 1000 or nonintegers will generate API errors + operationId: deleteOrder + parameters: + - name: order_id + in: path + description: ID of the order that needs to be deleted + required: true + schema: + type: string + responses: + '400': + description: Invalid ID supplied + '404': + description: Order not found + /user: + post: + tags: + - user + summary: Create user + description: This can only be done by the logged in user. + operationId: createUser + responses: + default: + description: successful operation + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + description: Created user object + required: true + /user/createWithArray: + post: + tags: + - user + summary: Creates list of users with given input array + description: '' + operationId: createUsersWithArrayInput + responses: + default: + description: successful operation + requestBody: + $ref: '#/components/requestBodies/UserArray' + /user/createWithList: + post: + tags: + - user + summary: Creates list of users with given input array + description: '' + operationId: createUsersWithListInput + responses: + default: + description: successful operation + requestBody: + $ref: '#/components/requestBodies/UserArray' + /user/login: + get: + tags: + - user + summary: Logs user into the system + description: '' + operationId: loginUser + parameters: + - name: username + in: query + description: The user name for login + required: true + schema: + type: string + - name: password + in: query + description: The password for login in clear text + required: true + schema: + type: string + responses: + '200': + description: successful operation + headers: + X-Rate-Limit: + description: calls per hour allowed by the user + schema: + type: integer + format: int32 + X-Expires-After: + description: date in UTC when token expires + schema: + type: string + format: date-time + content: + application/xml: + schema: + type: string + application/json: + schema: + type: string + '400': + description: Invalid username/password supplied + /user/logout: + get: + tags: + - user + summary: Logs out current logged in user session + description: '' + operationId: logoutUser + responses: + default: + description: successful operation + '/user/{username}': + get: + tags: + - user + summary: Get user by user name + description: '' + operationId: getUserByName + parameters: + - name: username + in: path + description: The name that needs to be fetched. Use user1 for testing. + required: true + schema: + type: string + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/User' + application/json: + schema: + $ref: '#/components/schemas/User' + '400': + description: Invalid username supplied + '404': + description: User not found + put: + tags: + - user + summary: Updated user + description: This can only be done by the logged in user. + operationId: updateUser + parameters: + - name: username + in: path + description: name that need to be deleted + required: true + schema: + type: string + responses: + '400': + description: Invalid user supplied + '404': + description: User not found + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + description: Updated user object + required: true + delete: + tags: + - user + summary: Delete user + description: This can only be done by the logged in user. + operationId: deleteUser + parameters: + - name: username + in: path + description: The name that needs to be deleted + required: true + schema: + type: string + responses: + '400': + description: Invalid username supplied + '404': + description: User not found + /fake_classname_test: + patch: + tags: + - 'fake_classname_tags 123#$%^' + summary: To test class name in snake case + description: To test class name in snake case + operationId: testClassname + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + security: + - api_key_query: [] + requestBody: + $ref: '#/components/requestBodies/Client' + /fake/cookie-suggestion: + get: + tags: + - fake + description: Test list of objects with additional values matching data from cookie + operationId: fakeCookieSuggestion + parameters: + - in: cookie + name: category.history + description: History of categories that user has viewed + required: true + schema: + type: string + responses: + 200: + description: List of pets resolved from suggestion + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' +servers: + - url: 'http://{server}.swagger.io:{port}/v2' + description: petstore server + variables: + server: + enum: + - 'petstore' + - 'qa-petstore' + - 'dev-petstore' + default: 'petstore' + port: + enum: + - 80 + - 8080 + default: 80 + - url: https://localhost:8080/{version} + description: The local server + variables: + version: + enum: + - 'v1' + - 'v2' + default: 'v2' + - url: https://127.0.0.1/no_varaible + description: The local server without variables +components: + requestBodies: + UserArray: + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/User' + description: List of user object + required: true + Client: + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: client model + required: true + Pet: + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + application/xml: + schema: + $ref: '#/components/schemas/Pet' + description: Pet object that needs to be added to the store + required: true + securitySchemes: + petstore_auth: + type: oauth2 + flows: + implicit: + authorizationUrl: 'http://petstore.swagger.io/api/oauth/dialog' + scopes: + 'write:pets': modify pets in your account + 'read:pets': read your pets + api_key: + type: apiKey + name: api_key + in: header + api_key_query: + type: apiKey + name: api_key_query + in: query + http_basic_test: + type: http + scheme: basic + bearer_test: + type: http + scheme: bearer + bearerFormat: JWT + http_signature_test: + type: http + scheme: signature + schemas: + Foo: + type: object + properties: + bar: + $ref: '#/components/schemas/Bar' + Bar: + type: string + default: bar + Order: + type: object + properties: + id: + type: integer + format: int64 + petId: + type: integer + format: int64 + quantity: + type: integer + format: int32 + shipDate: + type: string + format: date-time + status: + type: string + description: Order Status + enum: + - placed + - approved + - delivered + complete: + type: boolean + default: false + xml: + name: Order + Category: + type: object + required: + - name + properties: + id: + type: integer + format: int64 + name: + type: string + default: default-name + xml: + name: Category + User: + type: object + properties: + id: + type: integer + format: int64 + x-is-unique: true + username: + type: string + firstName: + type: string + lastName: + type: string + email: + type: string + password: + type: string + phone: + type: string + userStatus: + type: integer + format: int32 + description: User Status + xml: + name: User + Tag: + type: object + properties: + id: + type: integer + format: int64 + name: + type: string + xml: + name: Tag + Pet: + type: object + required: + - name + - photoUrls + properties: + id: + type: integer + format: int64 + x-is-unique: true + category: + $ref: '#/components/schemas/Category' + name: + type: string + example: doggie + photoUrls: + type: array + xml: + name: photoUrl + wrapped: true + items: + type: string + uniqueItems: true + tags: + type: array + xml: + name: tag + wrapped: true + items: + $ref: '#/components/schemas/Tag' + status: + type: string + description: pet status in the store + enum: + - available + - pending + - sold + xml: + name: Pet + ApiResponse: + type: object + properties: + code: + type: integer + format: int32 + type: + type: string + message: + type: string + Dog: + allOf: + - $ref: '#/components/schemas/Animal' + - type: object + properties: + breed: + type: string + Cat: + allOf: + - $ref: '#/components/schemas/Animal' + - type: object + properties: + declawed: + type: boolean + Animal: + type: object + discriminator: + propertyName: className + mapping: + DOG: '#/components/schemas/Dog' + CAT: '#/components/schemas/Cat' + required: + - className + properties: + className: + type: string + color: + type: string + default: red + Client: + type: object + properties: + client: + type: string \ No newline at end of file diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/.openapi-generator-ignore b/samples/server/petstore/kotlin-springboot-request-cookie/.openapi-generator-ignore new file mode 100644 index 00000000000..7484ee590a3 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-request-cookie/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/.openapi-generator/FILES b/samples/server/petstore/kotlin-springboot-request-cookie/.openapi-generator/FILES new file mode 100644 index 00000000000..d7d6f05bb39 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-request-cookie/.openapi-generator/FILES @@ -0,0 +1,26 @@ +.openapi-generator-ignore +README.md +build.gradle.kts +pom.xml +settings.gradle +src/main/kotlin/org/openapitools/SpringDocConfiguration.kt +src/main/kotlin/org/openapitools/api/ApiUtil.kt +src/main/kotlin/org/openapitools/api/Exceptions.kt +src/main/kotlin/org/openapitools/api/FakeApi.kt +src/main/kotlin/org/openapitools/api/FakeClassnameTestApi.kt +src/main/kotlin/org/openapitools/api/FooApi.kt +src/main/kotlin/org/openapitools/api/PetApi.kt +src/main/kotlin/org/openapitools/api/StoreApi.kt +src/main/kotlin/org/openapitools/api/UserApi.kt +src/main/kotlin/org/openapitools/model/Animal.kt +src/main/kotlin/org/openapitools/model/Cat.kt +src/main/kotlin/org/openapitools/model/Category.kt +src/main/kotlin/org/openapitools/model/Client.kt +src/main/kotlin/org/openapitools/model/Dog.kt +src/main/kotlin/org/openapitools/model/Foo.kt +src/main/kotlin/org/openapitools/model/FooGetDefaultResponse.kt +src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +src/main/kotlin/org/openapitools/model/Order.kt +src/main/kotlin/org/openapitools/model/Pet.kt +src/main/kotlin/org/openapitools/model/Tag.kt +src/main/kotlin/org/openapitools/model/User.kt diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/.openapi-generator/VERSION b/samples/server/petstore/kotlin-springboot-request-cookie/.openapi-generator/VERSION new file mode 100644 index 00000000000..c9e125ba188 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-request-cookie/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.4.0-SNAPSHOT diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/README.md b/samples/server/petstore/kotlin-springboot-request-cookie/README.md new file mode 100644 index 00000000000..b6865a08113 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-request-cookie/README.md @@ -0,0 +1,21 @@ +# openAPIPetstore + +This Kotlin based [Spring Boot](https://spring.io/projects/spring-boot) application has been generated using the [OpenAPI Generator](https://github.com/OpenAPITools/openapi-generator). + +## Getting Started + +This document assumes you have either maven or gradle available, either via the wrapper or otherwise. This does not come with a gradle / maven wrapper checked in. + +By default a [`pom.xml`](pom.xml) file will be generated. If you specified `gradleBuildFile=true` when generating this project, a `build.gradle.kts` will also be generated. Note this uses [Gradle Kotlin DSL](https://github.com/gradle/kotlin-dsl). + +To build the project using maven, run: +```bash +mvn package && java -jar target/openapi-spring-1.0.0.jar +``` + +To build the project using gradle, run: +```bash +gradle build && java -jar build/libs/openapi-spring-1.0.0.jar +``` + +If all builds successfully, the server should run on [http://localhost:8080/](http://localhost:8080/) diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/build.gradle.kts b/samples/server/petstore/kotlin-springboot-request-cookie/build.gradle.kts new file mode 100644 index 00000000000..f8ef1123955 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-request-cookie/build.gradle.kts @@ -0,0 +1,43 @@ +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +group = "org.openapitools" +version = "1.0.0" +java.sourceCompatibility = JavaVersion.VERSION_17 + +repositories { + mavenCentral() + maven { url = uri("https://repo.spring.io/milestone") } +} + +tasks.withType { + kotlinOptions.jvmTarget = "17" +} + +plugins { + val kotlinVersion = "1.7.10" + id("org.jetbrains.kotlin.jvm") version kotlinVersion + id("org.jetbrains.kotlin.plugin.jpa") version kotlinVersion + id("org.jetbrains.kotlin.plugin.spring") version kotlinVersion + id("org.springframework.boot") version "3.0.2" + id("io.spring.dependency-management") version "1.0.14.RELEASE" +} + +dependencies { + implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") + implementation("org.jetbrains.kotlin:kotlin-reflect") + implementation("org.springframework.boot:spring-boot-starter-web") + implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.0-M5") + + implementation("com.google.code.findbugs:jsr305:3.0.2") + implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml") + implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml") + implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310") + implementation("com.fasterxml.jackson.module:jackson-module-kotlin") + implementation("jakarta.validation:jakarta.validation-api") + implementation("jakarta.annotation:jakarta.annotation-api:2.1.0") + + testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") + testImplementation("org.springframework.boot:spring-boot-starter-test") { + exclude(module = "junit") + } +} diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/pom.xml b/samples/server/petstore/kotlin-springboot-request-cookie/pom.xml new file mode 100644 index 00000000000..d3dd81b25a8 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-request-cookie/pom.xml @@ -0,0 +1,138 @@ + + 4.0.0 + org.openapitools + openapi-spring + jar + openapi-spring + 1.0.0 + + 2.2.0 + 3.0.2 + 2.1.0 + 1.7.10 + + 1.7.10 + UTF-8 + + + org.springframework.boot + spring-boot-starter-parent + 3.1.3 + + + + repository.spring.milestone + Spring Milestone Repository + https://repo.spring.io/milestone + + + + + spring-milestones + https://repo.spring.io/milestone + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/test/kotlin + + + kotlin-maven-plugin + org.jetbrains.kotlin + ${kotlin.version} + + + spring + + 17 + + + + compile + compile + + compile + + + + test-compile + test-compile + + test-compile + + + + + + org.jetbrains.kotlin + kotlin-maven-allopen + ${kotlin.version} + + + + + + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-reflect + ${kotlin.version} + + + org.springframework.boot + spring-boot-starter-web + + + + + org.springdoc + springdoc-openapi-starter-webmvc-ui + ${springdoc-openapi.version} + + + + + com.google.code.findbugs + jsr305 + ${findbugs-jsr305.version} + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + + + com.fasterxml.jackson.module + jackson-module-kotlin + + + + jakarta.validation + jakarta.validation-api + + + jakarta.annotation + jakarta.annotation-api + ${jakarta-annotation.version} + provided + + + org.jetbrains.kotlin + kotlin-test-junit5 + ${kotlin-test-junit5.version} + test + + + diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/settings.gradle b/samples/server/petstore/kotlin-springboot-request-cookie/settings.gradle new file mode 100644 index 00000000000..14844905cd4 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-request-cookie/settings.gradle @@ -0,0 +1,15 @@ +pluginManagement { + repositories { + maven { url = uri("https://repo.spring.io/snapshot") } + maven { url = uri("https://repo.spring.io/milestone") } + gradlePluginPortal() + } + resolutionStrategy { + eachPlugin { + if (requested.id.id == "org.springframework.boot") { + useModule("org.springframework.boot:spring-boot-gradle-plugin:${requested.version}") + } + } + } +} +rootProject.name = "openapi-spring" diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/SpringDocConfiguration.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/SpringDocConfiguration.kt new file mode 100644 index 00000000000..8cf0ddfec02 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/SpringDocConfiguration.kt @@ -0,0 +1,60 @@ +package org.openapitools + +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +import io.swagger.v3.oas.models.OpenAPI +import io.swagger.v3.oas.models.info.Info +import io.swagger.v3.oas.models.info.Contact +import io.swagger.v3.oas.models.info.License +import io.swagger.v3.oas.models.Components +import io.swagger.v3.oas.models.security.SecurityScheme + +@Configuration +class SpringDocConfiguration { + + @Bean + fun apiInfo(): OpenAPI { + return OpenAPI() + .info( + Info() + .title("OpenAPI Petstore") + .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") + .license( + License() + .name("Apache-2.0") + .url("https://www.apache.org/licenses/LICENSE-2.0.html") + ) + .version("1.0.0") + ) + .components( + Components() + .addSecuritySchemes("petstore_auth", SecurityScheme() + .type(SecurityScheme.Type.OAUTH2) + ) + .addSecuritySchemes("api_key", SecurityScheme() + .type(SecurityScheme.Type.APIKEY) + .`in`(SecurityScheme.In.HEADER) + .name("api_key") + ) + .addSecuritySchemes("api_key_query", SecurityScheme() + .type(SecurityScheme.Type.APIKEY) + .`in`(SecurityScheme.In.QUERY) + .name("api_key_query") + ) + .addSecuritySchemes("http_basic_test", SecurityScheme() + .type(SecurityScheme.Type.HTTP) + .scheme("basic") + ) + .addSecuritySchemes("bearer_test", SecurityScheme() + .type(SecurityScheme.Type.HTTP) + .scheme("bearer") + .bearerFormat("JWT") + ) + .addSecuritySchemes("http_signature_test", SecurityScheme() + .type(SecurityScheme.Type.HTTP) + .scheme("signature") + ) + ) + } +} diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/ApiUtil.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/ApiUtil.kt new file mode 100644 index 00000000000..03344e13b47 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/ApiUtil.kt @@ -0,0 +1,19 @@ +package org.openapitools.api + +import org.springframework.web.context.request.NativeWebRequest + +import jakarta.servlet.http.HttpServletResponse +import java.io.IOException + +object ApiUtil { + fun setExampleResponse(req: NativeWebRequest, contentType: String, example: String) { + try { + val res = req.getNativeResponse(HttpServletResponse::class.java) + res?.characterEncoding = "UTF-8" + res?.addHeader("Content-Type", contentType) + res?.writer?.print(example) + } catch (e: IOException) { + throw RuntimeException(e) + } + } +} diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/Exceptions.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/Exceptions.kt new file mode 100644 index 00000000000..117161bf65b --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/Exceptions.kt @@ -0,0 +1,29 @@ +package org.openapitools.api + +import org.springframework.http.HttpStatus +import org.springframework.web.bind.annotation.ControllerAdvice +import org.springframework.web.bind.annotation.ExceptionHandler +import jakarta.servlet.http.HttpServletResponse +import jakarta.validation.ConstraintViolationException + +// TODO Extend ApiException for custom exception handling, e.g. the below NotFound exception +sealed class ApiException(msg: String, val code: Int) : Exception(msg) + +class NotFoundException(msg: String, code: Int = HttpStatus.NOT_FOUND.value()) : ApiException(msg, code) + + +@ControllerAdvice +class DefaultExceptionHandler { + + @ExceptionHandler(value = [ApiException::class]) + fun onApiException(ex: ApiException, response: HttpServletResponse): Unit = + response.sendError(ex.code, ex.message) + + @ExceptionHandler(value = [NotImplementedError::class]) + fun onNotImplemented(ex: NotImplementedError, response: HttpServletResponse): Unit = + response.sendError(HttpStatus.NOT_IMPLEMENTED.value()) + + @ExceptionHandler(value = [ConstraintViolationException::class]) + fun onConstraintViolation(ex: ConstraintViolationException, response: HttpServletResponse): Unit = + response.sendError(HttpStatus.BAD_REQUEST.value(), ex.constraintViolations.joinToString(", ") { it.message }) +} diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/FakeApi.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/FakeApi.kt new file mode 100644 index 00000000000..840c055d2ac --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/FakeApi.kt @@ -0,0 +1,58 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. +*/ +package org.openapitools.api + +import org.openapitools.model.Pet +import io.swagger.v3.oas.annotations.* +import io.swagger.v3.oas.annotations.enums.* +import io.swagger.v3.oas.annotations.media.* +import io.swagger.v3.oas.annotations.responses.* +import io.swagger.v3.oas.annotations.security.* +import org.springframework.http.HttpStatus +import org.springframework.http.MediaType +import org.springframework.http.ResponseEntity +import org.springframework.http.server.reactive.ServerHttpRequest + +import org.springframework.web.bind.annotation.* +import org.springframework.validation.annotation.Validated +import org.springframework.web.context.request.NativeWebRequest +import org.springframework.beans.factory.annotation.Autowired + +import jakarta.validation.constraints.DecimalMax +import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.Email +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size +import jakarta.validation.Valid + +import kotlin.collections.List +import kotlin.collections.Map + +@Validated +@RequestMapping("\${api.base-path:/v2}") +interface FakeApi { + + @Operation( + tags = ["fake",], + summary = "", + operationId = "fakeCookieSuggestion", + description = """Test list of objects with additional values matching data from cookie""", + responses = [ + ApiResponse(responseCode = "200", description = "List of pets resolved from suggestion", content = [Content(array = ArraySchema(schema = Schema(implementation = Pet::class)))]) + ] + ) + @RequestMapping( + method = [RequestMethod.GET], + value = ["/fake/cookie-suggestion"], + produces = ["application/json"] + ) + fun fakeCookieSuggestion(@NotNull @CookieValue(name = "category.history") categoryHistory: kotlin.String,serverHttpRequest: ServerHttpRequest): ResponseEntity> { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } +} diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/FakeClassnameTestApi.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/FakeClassnameTestApi.kt new file mode 100644 index 00000000000..426f62838bf --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/FakeClassnameTestApi.kt @@ -0,0 +1,60 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. +*/ +package org.openapitools.api + +import org.openapitools.model.Client +import io.swagger.v3.oas.annotations.* +import io.swagger.v3.oas.annotations.enums.* +import io.swagger.v3.oas.annotations.media.* +import io.swagger.v3.oas.annotations.responses.* +import io.swagger.v3.oas.annotations.security.* +import org.springframework.http.HttpStatus +import org.springframework.http.MediaType +import org.springframework.http.ResponseEntity +import org.springframework.http.server.reactive.ServerHttpRequest + +import org.springframework.web.bind.annotation.* +import org.springframework.validation.annotation.Validated +import org.springframework.web.context.request.NativeWebRequest +import org.springframework.beans.factory.annotation.Autowired + +import jakarta.validation.constraints.DecimalMax +import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.Email +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size +import jakarta.validation.Valid + +import kotlin.collections.List +import kotlin.collections.Map + +@Validated +@RequestMapping("\${api.base-path:/v2}") +interface FakeClassnameTestApi { + + @Operation( + tags = ["fake_classname_tags 123#$%^",], + summary = "To test class name in snake case", + operationId = "testClassname", + description = """To test class name in snake case""", + responses = [ + ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Client::class))]) + ], + security = [ SecurityRequirement(name = "api_key_query") ] + ) + @RequestMapping( + method = [RequestMethod.PATCH], + value = ["/fake_classname_test"], + produces = ["application/json"], + consumes = ["application/json"] + ) + fun testClassname(@Parameter(description = "client model", required = true) @Valid @RequestBody client: Client,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } +} diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/FooApi.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/FooApi.kt new file mode 100644 index 00000000000..2fe6609d93c --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/FooApi.kt @@ -0,0 +1,58 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. +*/ +package org.openapitools.api + +import org.openapitools.model.FooGetDefaultResponse +import io.swagger.v3.oas.annotations.* +import io.swagger.v3.oas.annotations.enums.* +import io.swagger.v3.oas.annotations.media.* +import io.swagger.v3.oas.annotations.responses.* +import io.swagger.v3.oas.annotations.security.* +import org.springframework.http.HttpStatus +import org.springframework.http.MediaType +import org.springframework.http.ResponseEntity +import org.springframework.http.server.reactive.ServerHttpRequest + +import org.springframework.web.bind.annotation.* +import org.springframework.validation.annotation.Validated +import org.springframework.web.context.request.NativeWebRequest +import org.springframework.beans.factory.annotation.Autowired + +import jakarta.validation.constraints.DecimalMax +import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.Email +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size +import jakarta.validation.Valid + +import kotlin.collections.List +import kotlin.collections.Map + +@Validated +@RequestMapping("\${api.base-path:/v2}") +interface FooApi { + + @Operation( + tags = ["default",], + summary = "", + operationId = "fooGet", + description = """""", + responses = [ + ApiResponse(responseCode = "200", description = "response", content = [Content(schema = Schema(implementation = FooGetDefaultResponse::class))]) + ] + ) + @RequestMapping( + method = [RequestMethod.GET], + value = ["/foo"], + produces = ["application/json"] + ) + fun fooGet(serverHttpRequest: ServerHttpRequest): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } +} diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/PetApi.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/PetApi.kt new file mode 100644 index 00000000000..891fefc0a88 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/PetApi.kt @@ -0,0 +1,203 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. +*/ +package org.openapitools.api + +import org.openapitools.model.ModelApiResponse +import org.openapitools.model.Pet +import io.swagger.v3.oas.annotations.* +import io.swagger.v3.oas.annotations.enums.* +import io.swagger.v3.oas.annotations.media.* +import io.swagger.v3.oas.annotations.responses.* +import io.swagger.v3.oas.annotations.security.* +import org.springframework.http.HttpStatus +import org.springframework.http.MediaType +import org.springframework.http.ResponseEntity +import org.springframework.http.server.reactive.ServerHttpRequest + +import org.springframework.web.bind.annotation.* +import org.springframework.validation.annotation.Validated +import org.springframework.web.context.request.NativeWebRequest +import org.springframework.beans.factory.annotation.Autowired + +import jakarta.validation.constraints.DecimalMax +import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.Email +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size +import jakarta.validation.Valid + +import kotlin.collections.List +import kotlin.collections.Map + +@Validated +@RequestMapping("\${api.base-path:/v2}") +interface PetApi { + + @Operation( + tags = ["pet",], + summary = "Add a new pet to the store", + operationId = "addPet", + description = """""", + responses = [ + ApiResponse(responseCode = "200", description = "Successful operation"), + ApiResponse(responseCode = "405", description = "Invalid input") + ], + security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "write:pets", "read:pets" ]) ] + ) + @RequestMapping( + method = [RequestMethod.POST], + value = ["/pet"], + consumes = ["application/json", "application/xml"] + ) + fun addPet(@Parameter(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody pet: Pet,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + @Operation( + tags = ["pet",], + summary = "Deletes a pet", + operationId = "deletePet", + description = """""", + responses = [ + ApiResponse(responseCode = "200", description = "Successful operation"), + ApiResponse(responseCode = "400", description = "Invalid pet value") + ], + security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "write:pets", "read:pets" ]) ] + ) + @RequestMapping( + method = [RequestMethod.DELETE], + value = ["/pet/{petId}"] + ) + fun deletePet(@Parameter(description = "Pet id to delete", required = true) @PathVariable("petId") petId: kotlin.Long,@Parameter(description = "", `in` = ParameterIn.HEADER) @RequestHeader(value = "api_key", required = false) apiKey: kotlin.String?,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + @Operation( + tags = ["pet",], + summary = "Finds Pets by status", + operationId = "findPetsByStatus", + description = """Multiple status values can be provided with comma separated strings""", + responses = [ + ApiResponse(responseCode = "200", description = "successful operation", content = [Content(array = ArraySchema(schema = Schema(implementation = Pet::class)))]), + ApiResponse(responseCode = "400", description = "Invalid status value") + ], + security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "write:pets", "read:pets" ]) ] + ) + @RequestMapping( + method = [RequestMethod.GET], + value = ["/pet/findByStatus"], + produces = ["application/xml", "application/json"] + ) + fun findPetsByStatus(@NotNull @Parameter(description = "Status values that need to be considered for filter", required = true, schema = Schema(allowableValues = ["available", "pending", "sold"])) @Valid @RequestParam(value = "status", required = true) status: kotlin.collections.List,serverHttpRequest: ServerHttpRequest): ResponseEntity> { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + @Operation( + tags = ["pet",], + summary = "Finds Pets by tags", + operationId = "findPetsByTags", + description = """Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.""", + responses = [ + ApiResponse(responseCode = "200", description = "successful operation", content = [Content(array = ArraySchema(schema = Schema(implementation = Pet::class)))]), + ApiResponse(responseCode = "400", description = "Invalid tag value") + ], + security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "read:pets" ]) ] + ) + @RequestMapping( + method = [RequestMethod.GET], + value = ["/pet/findByTags"], + produces = ["application/xml", "application/json"] + ) + fun findPetsByTags(@NotNull @Parameter(description = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) tags: kotlin.collections.List,serverHttpRequest: ServerHttpRequest): ResponseEntity> { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + @Operation( + tags = ["pet",], + summary = "Find pet by ID", + operationId = "getPetById", + description = """Returns a single pet""", + responses = [ + ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Pet::class))]), + ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + ApiResponse(responseCode = "404", description = "Pet not found") + ], + security = [ SecurityRequirement(name = "api_key") ] + ) + @RequestMapping( + method = [RequestMethod.GET], + value = ["/pet/{petId}"], + produces = ["application/xml", "application/json"] + ) + fun getPetById(@Parameter(description = "ID of pet to return", required = true) @PathVariable("petId") petId: kotlin.Long,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + @Operation( + tags = ["pet",], + summary = "Update an existing pet", + operationId = "updatePet", + description = """""", + responses = [ + ApiResponse(responseCode = "200", description = "Successful operation"), + ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + ApiResponse(responseCode = "404", description = "Pet not found"), + ApiResponse(responseCode = "405", description = "Validation exception") + ], + security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "write:pets", "read:pets" ]) ] + ) + @RequestMapping( + method = [RequestMethod.PUT], + value = ["/pet"], + consumes = ["application/json", "application/xml"] + ) + fun updatePet(@Parameter(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody pet: Pet,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + @Operation( + tags = ["pet",], + summary = "Updates a pet in the store with form data", + operationId = "updatePetWithForm", + description = """""", + responses = [ + ApiResponse(responseCode = "200", description = "Successful operation"), + ApiResponse(responseCode = "405", description = "Invalid input") + ], + security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "write:pets", "read:pets" ]) ] + ) + @RequestMapping( + method = [RequestMethod.POST], + value = ["/pet/{petId}"], + consumes = ["application/x-www-form-urlencoded"] + ) + fun updatePetWithForm(@Parameter(description = "ID of pet that needs to be updated", required = true) @PathVariable("petId") petId: kotlin.Long,@Parameter(description = "Updated name of the pet") @RequestParam(value = "name", required = false) name: kotlin.String? ,@Parameter(description = "Updated status of the pet") @RequestParam(value = "status", required = false) status: kotlin.String? ,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + @Operation( + tags = ["pet",], + summary = "uploads an image", + operationId = "uploadFile", + description = """""", + responses = [ + ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = ModelApiResponse::class))]) + ], + security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "write:pets", "read:pets" ]) ] + ) + @RequestMapping( + method = [RequestMethod.POST], + value = ["/pet/{petId}/uploadImage"], + produces = ["application/json"], + consumes = ["multipart/form-data"] + ) + fun uploadFile(@Parameter(description = "ID of pet to update", required = true) @PathVariable("petId") petId: kotlin.Long,@Parameter(description = "Additional data to pass to server") @RequestParam(value = "additionalMetadata", required = false) additionalMetadata: kotlin.String? ,@Parameter(description = "file detail") @Valid @RequestPart("file") file: org.springframework.core.io.Resource?,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } +} diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/StoreApi.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/StoreApi.kt new file mode 100644 index 00000000000..ccbb6443c8a --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/StoreApi.kt @@ -0,0 +1,117 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. +*/ +package org.openapitools.api + +import org.openapitools.model.Order +import io.swagger.v3.oas.annotations.* +import io.swagger.v3.oas.annotations.enums.* +import io.swagger.v3.oas.annotations.media.* +import io.swagger.v3.oas.annotations.responses.* +import io.swagger.v3.oas.annotations.security.* +import org.springframework.http.HttpStatus +import org.springframework.http.MediaType +import org.springframework.http.ResponseEntity +import org.springframework.http.server.reactive.ServerHttpRequest + +import org.springframework.web.bind.annotation.* +import org.springframework.validation.annotation.Validated +import org.springframework.web.context.request.NativeWebRequest +import org.springframework.beans.factory.annotation.Autowired + +import jakarta.validation.constraints.DecimalMax +import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.Email +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size +import jakarta.validation.Valid + +import kotlin.collections.List +import kotlin.collections.Map + +@Validated +@RequestMapping("\${api.base-path:/v2}") +interface StoreApi { + + @Operation( + tags = ["store",], + summary = "Delete purchase order by ID", + operationId = "deleteOrder", + description = """For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors""", + responses = [ + ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + ApiResponse(responseCode = "404", description = "Order not found") + ] + ) + @RequestMapping( + method = [RequestMethod.DELETE], + value = ["/store/order/{order_id}"] + ) + fun deleteOrder(@Parameter(description = "ID of the order that needs to be deleted", required = true) @PathVariable("order_id") orderId: kotlin.String,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + @Operation( + tags = ["store",], + summary = "Returns pet inventories by status", + operationId = "getInventory", + description = """Returns a map of status codes to quantities""", + responses = [ + ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = kotlin.collections.Map::class))]) + ], + security = [ SecurityRequirement(name = "api_key") ] + ) + @RequestMapping( + method = [RequestMethod.GET], + value = ["/store/inventory"], + produces = ["application/json"] + ) + fun getInventory(serverHttpRequest: ServerHttpRequest): ResponseEntity> { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + @Operation( + tags = ["store",], + summary = "Find purchase order by ID", + operationId = "getOrderById", + description = """For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions""", + responses = [ + ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Order::class))]), + ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + ApiResponse(responseCode = "404", description = "Order not found") + ] + ) + @RequestMapping( + method = [RequestMethod.GET], + value = ["/store/order/{order_id}"], + produces = ["application/xml", "application/json"] + ) + fun getOrderById(@Min(1L) @Max(5L) @Parameter(description = "ID of pet that needs to be fetched", required = true) @PathVariable("order_id") orderId: kotlin.Long,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + @Operation( + tags = ["store",], + summary = "Place an order for a pet", + operationId = "placeOrder", + description = """""", + responses = [ + ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Order::class))]), + ApiResponse(responseCode = "400", description = "Invalid Order") + ] + ) + @RequestMapping( + method = [RequestMethod.POST], + value = ["/store/order"], + produces = ["application/xml", "application/json"], + consumes = ["application/json"] + ) + fun placeOrder(@Parameter(description = "order placed for purchasing the pet", required = true) @Valid @RequestBody order: Order,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } +} diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/UserApi.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/UserApi.kt new file mode 100644 index 00000000000..24280234b67 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/api/UserApi.kt @@ -0,0 +1,187 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.4.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. +*/ +package org.openapitools.api + +import org.openapitools.model.User +import io.swagger.v3.oas.annotations.* +import io.swagger.v3.oas.annotations.enums.* +import io.swagger.v3.oas.annotations.media.* +import io.swagger.v3.oas.annotations.responses.* +import io.swagger.v3.oas.annotations.security.* +import org.springframework.http.HttpStatus +import org.springframework.http.MediaType +import org.springframework.http.ResponseEntity +import org.springframework.http.server.reactive.ServerHttpRequest + +import org.springframework.web.bind.annotation.* +import org.springframework.validation.annotation.Validated +import org.springframework.web.context.request.NativeWebRequest +import org.springframework.beans.factory.annotation.Autowired + +import jakarta.validation.constraints.DecimalMax +import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.Email +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size +import jakarta.validation.Valid + +import kotlin.collections.List +import kotlin.collections.Map + +@Validated +@RequestMapping("\${api.base-path:/v2}") +interface UserApi { + + @Operation( + tags = ["user",], + summary = "Create user", + operationId = "createUser", + description = """This can only be done by the logged in user.""", + responses = [ + ApiResponse(responseCode = "200", description = "successful operation") + ] + ) + @RequestMapping( + method = [RequestMethod.POST], + value = ["/user"], + consumes = ["application/json"] + ) + fun createUser(@Parameter(description = "Created user object", required = true) @Valid @RequestBody user: User,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + @Operation( + tags = ["user",], + summary = "Creates list of users with given input array", + operationId = "createUsersWithArrayInput", + description = """""", + responses = [ + ApiResponse(responseCode = "200", description = "successful operation") + ] + ) + @RequestMapping( + method = [RequestMethod.POST], + value = ["/user/createWithArray"], + consumes = ["application/json"] + ) + fun createUsersWithArrayInput(@Parameter(description = "List of user object", required = true) @Valid @RequestBody user: kotlin.collections.List,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + @Operation( + tags = ["user",], + summary = "Creates list of users with given input array", + operationId = "createUsersWithListInput", + description = """""", + responses = [ + ApiResponse(responseCode = "200", description = "successful operation") + ] + ) + @RequestMapping( + method = [RequestMethod.POST], + value = ["/user/createWithList"], + consumes = ["application/json"] + ) + fun createUsersWithListInput(@Parameter(description = "List of user object", required = true) @Valid @RequestBody user: kotlin.collections.List,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + @Operation( + tags = ["user",], + summary = "Delete user", + operationId = "deleteUser", + description = """This can only be done by the logged in user.""", + responses = [ + ApiResponse(responseCode = "400", description = "Invalid username supplied"), + ApiResponse(responseCode = "404", description = "User not found") + ] + ) + @RequestMapping( + method = [RequestMethod.DELETE], + value = ["/user/{username}"] + ) + fun deleteUser(@Parameter(description = "The name that needs to be deleted", required = true) @PathVariable("username") username: kotlin.String,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + @Operation( + tags = ["user",], + summary = "Get user by user name", + operationId = "getUserByName", + description = """""", + responses = [ + ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = User::class))]), + ApiResponse(responseCode = "400", description = "Invalid username supplied"), + ApiResponse(responseCode = "404", description = "User not found") + ] + ) + @RequestMapping( + method = [RequestMethod.GET], + value = ["/user/{username}"], + produces = ["application/xml", "application/json"] + ) + fun getUserByName(@Parameter(description = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") username: kotlin.String,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + @Operation( + tags = ["user",], + summary = "Logs user into the system", + operationId = "loginUser", + description = """""", + responses = [ + ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = kotlin.String::class))]), + ApiResponse(responseCode = "400", description = "Invalid username/password supplied") + ] + ) + @RequestMapping( + method = [RequestMethod.GET], + value = ["/user/login"], + produces = ["application/xml", "application/json"] + ) + fun loginUser(@NotNull @Parameter(description = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) username: kotlin.String,@NotNull @Parameter(description = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) password: kotlin.String,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + @Operation( + tags = ["user",], + summary = "Logs out current logged in user session", + operationId = "logoutUser", + description = """""", + responses = [ + ApiResponse(responseCode = "200", description = "successful operation") + ] + ) + @RequestMapping( + method = [RequestMethod.GET], + value = ["/user/logout"] + ) + fun logoutUser(serverHttpRequest: ServerHttpRequest): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + @Operation( + tags = ["user",], + summary = "Updated user", + operationId = "updateUser", + description = """This can only be done by the logged in user.""", + responses = [ + ApiResponse(responseCode = "400", description = "Invalid user supplied"), + ApiResponse(responseCode = "404", description = "User not found") + ] + ) + @RequestMapping( + method = [RequestMethod.PUT], + value = ["/user/{username}"], + consumes = ["application/json"] + ) + fun updateUser(@Parameter(description = "name that need to be deleted", required = true) @PathVariable("username") username: kotlin.String,@Parameter(description = "Updated user object", required = true) @Valid @RequestBody user: User,serverHttpRequest: ServerHttpRequest): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } +} diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Animal.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Animal.kt new file mode 100644 index 00000000000..5f5cafa6291 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Animal.kt @@ -0,0 +1,39 @@ +package org.openapitools.model + +import java.util.Objects +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSubTypes +import com.fasterxml.jackson.annotation.JsonTypeInfo +import jakarta.validation.constraints.DecimalMax +import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.Email +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size +import jakarta.validation.Valid +import io.swagger.v3.oas.annotations.media.Schema + +/** + * + * @param className + * @param color + */ + +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "className", visible = true) +@JsonSubTypes( + JsonSubTypes.Type(value = Cat::class, name = "CAT"), + JsonSubTypes.Type(value = Dog::class, name = "DOG") +) + +interface Animal{ + @get:Schema(example = "null", requiredMode = Schema.RequiredMode.REQUIRED, description = "") + val className: kotlin.String + + @get:Schema(example = "null", description = "") + val color: kotlin.String? + + +} + diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Cat.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Cat.kt new file mode 100644 index 00000000000..463bfed1de8 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Cat.kt @@ -0,0 +1,34 @@ +package org.openapitools.model + +import java.util.Objects +import com.fasterxml.jackson.annotation.JsonProperty +import org.openapitools.model.Animal +import jakarta.validation.constraints.DecimalMax +import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.Email +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size +import jakarta.validation.Valid +import io.swagger.v3.oas.annotations.media.Schema + +/** + * + * @param declawed + */ +data class Cat( + + @Schema(example = "null", required = true, description = "") + @get:JsonProperty("className", required = true) override val className: kotlin.String, + + @Schema(example = "null", description = "") + @get:JsonProperty("declawed") val declawed: kotlin.Boolean? = null, + + @Schema(example = "null", description = "") + @get:JsonProperty("color") override val color: kotlin.String? = "red" +) : Animal{ + +} + diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Category.kt new file mode 100644 index 00000000000..161bd3a22eb --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Category.kt @@ -0,0 +1,31 @@ +package org.openapitools.model + +import java.util.Objects +import com.fasterxml.jackson.annotation.JsonProperty +import jakarta.validation.constraints.DecimalMax +import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.Email +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size +import jakarta.validation.Valid +import io.swagger.v3.oas.annotations.media.Schema + +/** + * + * @param name + * @param id + */ +data class Category( + + @Schema(example = "null", required = true, description = "") + @get:JsonProperty("name", required = true) val name: kotlin.String = "default-name", + + @Schema(example = "null", description = "") + @get:JsonProperty("id") val id: kotlin.Long? = null +) { + +} + diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Client.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Client.kt new file mode 100644 index 00000000000..cd3652ce6d4 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Client.kt @@ -0,0 +1,27 @@ +package org.openapitools.model + +import java.util.Objects +import com.fasterxml.jackson.annotation.JsonProperty +import jakarta.validation.constraints.DecimalMax +import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.Email +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size +import jakarta.validation.Valid +import io.swagger.v3.oas.annotations.media.Schema + +/** + * + * @param client + */ +data class Client( + + @Schema(example = "null", description = "") + @get:JsonProperty("client") val client: kotlin.String? = null +) { + +} + diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Dog.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Dog.kt new file mode 100644 index 00000000000..705ac958334 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Dog.kt @@ -0,0 +1,34 @@ +package org.openapitools.model + +import java.util.Objects +import com.fasterxml.jackson.annotation.JsonProperty +import org.openapitools.model.Animal +import jakarta.validation.constraints.DecimalMax +import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.Email +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size +import jakarta.validation.Valid +import io.swagger.v3.oas.annotations.media.Schema + +/** + * + * @param breed + */ +data class Dog( + + @Schema(example = "null", required = true, description = "") + @get:JsonProperty("className", required = true) override val className: kotlin.String, + + @Schema(example = "null", description = "") + @get:JsonProperty("breed") val breed: kotlin.String? = null, + + @Schema(example = "null", description = "") + @get:JsonProperty("color") override val color: kotlin.String? = "red" +) : Animal{ + +} + diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Foo.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Foo.kt new file mode 100644 index 00000000000..6139b810551 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Foo.kt @@ -0,0 +1,27 @@ +package org.openapitools.model + +import java.util.Objects +import com.fasterxml.jackson.annotation.JsonProperty +import jakarta.validation.constraints.DecimalMax +import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.Email +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size +import jakarta.validation.Valid +import io.swagger.v3.oas.annotations.media.Schema + +/** + * + * @param bar + */ +data class Foo( + + @Schema(example = "null", description = "") + @get:JsonProperty("bar") val bar: kotlin.String? = "bar" +) { + +} + diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/FooGetDefaultResponse.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/FooGetDefaultResponse.kt new file mode 100644 index 00000000000..0a0b15e5bcc --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/FooGetDefaultResponse.kt @@ -0,0 +1,29 @@ +package org.openapitools.model + +import java.util.Objects +import com.fasterxml.jackson.annotation.JsonProperty +import org.openapitools.model.Foo +import jakarta.validation.constraints.DecimalMax +import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.Email +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size +import jakarta.validation.Valid +import io.swagger.v3.oas.annotations.media.Schema + +/** + * + * @param string + */ +data class FooGetDefaultResponse( + + @field:Valid + @Schema(example = "null", description = "") + @get:JsonProperty("string") val string: Foo? = null +) { + +} + diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt new file mode 100644 index 00000000000..d4a1ed7c31f --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -0,0 +1,35 @@ +package org.openapitools.model + +import java.util.Objects +import com.fasterxml.jackson.annotation.JsonProperty +import jakarta.validation.constraints.DecimalMax +import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.Email +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size +import jakarta.validation.Valid +import io.swagger.v3.oas.annotations.media.Schema + +/** + * + * @param code + * @param type + * @param message + */ +data class ModelApiResponse( + + @Schema(example = "null", description = "") + @get:JsonProperty("code") val code: kotlin.Int? = null, + + @Schema(example = "null", description = "") + @get:JsonProperty("type") val type: kotlin.String? = null, + + @Schema(example = "null", description = "") + @get:JsonProperty("message") val message: kotlin.String? = null +) { + +} + diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Order.kt new file mode 100644 index 00000000000..14135c9174a --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Order.kt @@ -0,0 +1,59 @@ +package org.openapitools.model + +import java.util.Objects +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonValue +import jakarta.validation.constraints.DecimalMax +import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.Email +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size +import jakarta.validation.Valid +import io.swagger.v3.oas.annotations.media.Schema + +/** + * + * @param id + * @param petId + * @param quantity + * @param shipDate + * @param status Order Status + * @param complete + */ +data class Order( + + @Schema(example = "null", description = "") + @get:JsonProperty("id") val id: kotlin.Long? = null, + + @Schema(example = "null", description = "") + @get:JsonProperty("petId") val petId: kotlin.Long? = null, + + @Schema(example = "null", description = "") + @get:JsonProperty("quantity") val quantity: kotlin.Int? = null, + + @Schema(example = "null", description = "") + @get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, + + @Schema(example = "null", description = "Order Status") + @get:JsonProperty("status") val status: Order.Status? = null, + + @Schema(example = "null", description = "") + @get:JsonProperty("complete") val complete: kotlin.Boolean? = false +) { + + /** + * Order Status + * Values: placed,approved,delivered + */ + enum class Status(val value: kotlin.String) { + + @JsonProperty("placed") placed("placed"), + @JsonProperty("approved") approved("approved"), + @JsonProperty("delivered") delivered("delivered") + } + +} + diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Pet.kt new file mode 100644 index 00000000000..4c2dbad8ccd --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Pet.kt @@ -0,0 +1,63 @@ +package org.openapitools.model + +import java.util.Objects +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonValue +import org.openapitools.model.Category +import org.openapitools.model.Tag +import jakarta.validation.constraints.DecimalMax +import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.Email +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size +import jakarta.validation.Valid +import io.swagger.v3.oas.annotations.media.Schema + +/** + * + * @param name + * @param photoUrls + * @param id + * @param category + * @param tags + * @param status pet status in the store + */ +data class Pet( + + @Schema(example = "doggie", required = true, description = "") + @get:JsonProperty("name", required = true) val name: kotlin.String, + + @Schema(example = "null", required = true, description = "") + @get:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.Set, + + @Schema(example = "null", description = "") + @get:JsonProperty("id") val id: kotlin.Long? = null, + + @field:Valid + @Schema(example = "null", description = "") + @get:JsonProperty("category") val category: Category? = null, + + @field:Valid + @Schema(example = "null", description = "") + @get:JsonProperty("tags") val tags: kotlin.collections.List? = null, + + @Schema(example = "null", description = "pet status in the store") + @get:JsonProperty("status") val status: Pet.Status? = null +) { + + /** + * pet status in the store + * Values: available,pending,sold + */ + enum class Status(val value: kotlin.String) { + + @JsonProperty("available") available("available"), + @JsonProperty("pending") pending("pending"), + @JsonProperty("sold") sold("sold") + } + +} + diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Tag.kt new file mode 100644 index 00000000000..6f2021de260 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Tag.kt @@ -0,0 +1,31 @@ +package org.openapitools.model + +import java.util.Objects +import com.fasterxml.jackson.annotation.JsonProperty +import jakarta.validation.constraints.DecimalMax +import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.Email +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size +import jakarta.validation.Valid +import io.swagger.v3.oas.annotations.media.Schema + +/** + * + * @param id + * @param name + */ +data class Tag( + + @Schema(example = "null", description = "") + @get:JsonProperty("id") val id: kotlin.Long? = null, + + @Schema(example = "null", description = "") + @get:JsonProperty("name") val name: kotlin.String? = null +) { + +} + diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/User.kt new file mode 100644 index 00000000000..7150e530817 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/User.kt @@ -0,0 +1,55 @@ +package org.openapitools.model + +import java.util.Objects +import com.fasterxml.jackson.annotation.JsonProperty +import jakarta.validation.constraints.DecimalMax +import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.Email +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size +import jakarta.validation.Valid +import io.swagger.v3.oas.annotations.media.Schema + +/** + * + * @param id + * @param username + * @param firstName + * @param lastName + * @param email + * @param password + * @param phone + * @param userStatus User Status + */ +data class User( + + @Schema(example = "null", description = "") + @get:JsonProperty("id") val id: kotlin.Long? = null, + + @Schema(example = "null", description = "") + @get:JsonProperty("username") val username: kotlin.String? = null, + + @Schema(example = "null", description = "") + @get:JsonProperty("firstName") val firstName: kotlin.String? = null, + + @Schema(example = "null", description = "") + @get:JsonProperty("lastName") val lastName: kotlin.String? = null, + + @Schema(example = "null", description = "") + @get:JsonProperty("email") val email: kotlin.String? = null, + + @Schema(example = "null", description = "") + @get:JsonProperty("password") val password: kotlin.String? = null, + + @Schema(example = "null", description = "") + @get:JsonProperty("phone") val phone: kotlin.String? = null, + + @Schema(example = "null", description = "User Status") + @get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null +) { + +} +