From 3a63c2f7d2abb21c66c5605ade18b850bb9b6895 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Fri, 19 Sep 2025 17:10:31 +0800 Subject: [PATCH] Migrate Go petstore tests from circleci to github workflow (#21997) * migrate go tests from circleci to github workflow * update samples * update samples * update workflow * update samples * update samples * update test * update tests * update tests * fix * fix * update host table * update tests * update spec * new spec --- .../workflows/samples-go-client-petstore.yaml | 45 + .github/workflows/samples-go-client.yaml | 10 +- CI/circle_parallel.sh | 5 - bin/configs/go-petstore-oas2.yaml | 2 +- ...ndpoints-models-for-testing-localhost.yaml | 2014 +++++++++++++++++ ...odels-for-testing-with-http-signature.yaml | 8 +- .../others/go/oneof-required/.gitignore | 24 - .../oneof-required/.openapi-generator-ignore | 23 - .../oneof-required/.openapi-generator/FILES | 21 - .../oneof-required/.openapi-generator/VERSION | 1 - .../others/go/oneof-required/.travis.yml | 8 - .../client/others/go/oneof-required/README.md | 114 - .../others/go/oneof-required/api/openapi.yaml | 37 - .../client/others/go/oneof-required/client.go | 657 ------ .../others/go/oneof-required/configuration.go | 215 -- .../go/oneof-required/docs/NestedObject1.md | 51 - .../go/oneof-required/docs/NestedObject2.md | 51 - .../others/go/oneof-required/docs/Object.md | 72 - .../others/go/oneof-required/docs/Object2.md | 72 - .../others/go/oneof-required/docs/Object3.md | 72 - .../others/go/oneof-required/git_push.sh | 57 - .../client/others/go/oneof-required/go.mod | 6 - .../client/others/go/oneof-required/go.sum | 11 - .../go/oneof-required/model_nested_object1.go | 159 -- .../go/oneof-required/model_nested_object2.go | 159 -- .../others/go/oneof-required/model_object.go | 149 -- .../others/go/oneof-required/model_object2.go | 106 - .../others/go/oneof-required/model_object3.go | 188 -- .../others/go/oneof-required/response.go | 47 - .../client/others/go/oneof-required/utils.go | 347 --- .../client/petstore/go/go-petstore/README.md | 4 +- .../petstore/go/go-petstore/api/openapi.yaml | 4 +- .../petstore/go/go-petstore/configuration.go | 2 +- .../go/go-petstore/docs/AnotherFakeAPI.md | 2 +- .../petstore/go/go-petstore/docs/FakeAPI.md | 2 +- .../docs/FakeClassnameTags123API.md | 2 +- .../petstore/go/go-petstore/docs/PetAPI.md | 2 +- .../petstore/go/go-petstore/docs/StoreAPI.md | 2 +- .../petstore/go/go-petstore/docs/UserAPI.md | 2 +- samples/client/petstore/go/pet_api_test.go | 2 +- .../.openapi-generator-ignore | 3 + .../go/go-petstore/.openapi-generator-ignore | 2 + .../client/petstore/go/go-petstore/README.md | 4 +- .../petstore/go/go-petstore/api/openapi.yaml | 8 +- .../petstore/go/go-petstore/configuration.go | 16 +- .../go/go-petstore/docs/AnotherFakeAPI.md | 2 +- .../go/go-petstore/docs/DefaultAPI.md | 2 +- .../petstore/go/go-petstore/docs/FakeAPI.md | 2 +- .../docs/FakeClassnameTags123API.md | 2 +- .../petstore/go/go-petstore/docs/PetAPI.md | 2 +- .../petstore/go/go-petstore/docs/StoreAPI.md | 2 +- .../petstore/go/go-petstore/docs/UserAPI.md | 2 +- .../client/petstore/go/http_signature_test.go | 9 +- .../client/petstore/go/pet_api_test.go | 2 +- 54 files changed, 2126 insertions(+), 2687 deletions(-) create mode 100644 .github/workflows/samples-go-client-petstore.yaml create mode 100644 modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing-localhost.yaml delete mode 100644 samples/client/others/go/oneof-required/.gitignore delete mode 100644 samples/client/others/go/oneof-required/.openapi-generator-ignore delete mode 100644 samples/client/others/go/oneof-required/.openapi-generator/FILES delete mode 100644 samples/client/others/go/oneof-required/.openapi-generator/VERSION delete mode 100644 samples/client/others/go/oneof-required/.travis.yml delete mode 100644 samples/client/others/go/oneof-required/README.md delete mode 100644 samples/client/others/go/oneof-required/api/openapi.yaml delete mode 100644 samples/client/others/go/oneof-required/client.go delete mode 100644 samples/client/others/go/oneof-required/configuration.go delete mode 100644 samples/client/others/go/oneof-required/docs/NestedObject1.md delete mode 100644 samples/client/others/go/oneof-required/docs/NestedObject2.md delete mode 100644 samples/client/others/go/oneof-required/docs/Object.md delete mode 100644 samples/client/others/go/oneof-required/docs/Object2.md delete mode 100644 samples/client/others/go/oneof-required/docs/Object3.md delete mode 100644 samples/client/others/go/oneof-required/git_push.sh delete mode 100644 samples/client/others/go/oneof-required/go.mod delete mode 100644 samples/client/others/go/oneof-required/go.sum delete mode 100644 samples/client/others/go/oneof-required/model_nested_object1.go delete mode 100644 samples/client/others/go/oneof-required/model_nested_object2.go delete mode 100644 samples/client/others/go/oneof-required/model_object.go delete mode 100644 samples/client/others/go/oneof-required/model_object2.go delete mode 100644 samples/client/others/go/oneof-required/model_object3.go delete mode 100644 samples/client/others/go/oneof-required/response.go delete mode 100644 samples/client/others/go/oneof-required/utils.go diff --git a/.github/workflows/samples-go-client-petstore.yaml b/.github/workflows/samples-go-client-petstore.yaml new file mode 100644 index 00000000000..581a7a5bd28 --- /dev/null +++ b/.github/workflows/samples-go-client-petstore.yaml @@ -0,0 +1,45 @@ +name: Samples Go Clients (Petstore) + +on: + push: + paths: + - samples/client/petstore/go/** + - samples/openapi3/client/petstore/go/** + pull_request: + paths: + - samples/client/petstore/go/** + - samples/openapi3/client/petstore/go/** + +jobs: + build: + name: Build Go + runs-on: ubuntu-latest + services: + petstore-api: + image: swaggerapi/petstore + ports: + - 80:8080 + env: + SWAGGER_HOST: http://petstore.swagger.io + SWAGGER_BASE_PATH: /v2 + strategy: + fail-fast: false + matrix: + sample: + - samples/client/petstore/go/ + - samples/openapi3/client/petstore/go/ + steps: + - uses: actions/checkout@v5 + - name: Add hosts to /etc/hosts + run: | + sudo echo "127.0.0.1 petstore.swagger.io" | sudo tee -a /etc/hosts + - uses: actions/setup-go@v6 + - run: go version + - name: Install Dependencies + working-directory: ${{ matrix.sample }} + run: | + go mod tidy + - name: Run test + working-directory: ${{ matrix.sample }} + run: go test -mod=mod -v + diff --git a/.github/workflows/samples-go-client.yaml b/.github/workflows/samples-go-client.yaml index 5fcbf08d63f..198c9597c8d 100644 --- a/.github/workflows/samples-go-client.yaml +++ b/.github/workflows/samples-go-client.yaml @@ -6,12 +6,17 @@ on: - 'samples/openapi3/client/petstore/go/go-petstore-aws-signature/**' - 'samples/openapi3/client/petstore/go-petstore-withXml/**' - samples/openapi3/client/petstore/go-petstore-generateMarshalJSON-false/** + - samples/client/others/go/allof_multiple_ref_and_discriminator/** + - samples/client/others/go/oneof-anyof-required/** + - samples/client/others/go/oneof-discriminator-lookup/** pull_request: paths: - 'samples/openapi3/client/petstore/go/go-petstore-aws-signature/**' - 'samples/openapi3/client/petstore/go-petstore-withXml/**' - samples/openapi3/client/petstore/go-petstore-generateMarshalJSON-false/** - + - samples/client/others/go/allof_multiple_ref_and_discriminator/** + - samples/client/others/go/oneof-anyof-required/** + - samples/client/others/go/oneof-discriminator-lookup/** jobs: build: name: Build Go @@ -23,6 +28,9 @@ jobs: - 'samples/openapi3/client/petstore/go/go-petstore-aws-signature/' - 'samples/openapi3/client/petstore/go-petstore-withXml/' - samples/openapi3/client/petstore/go-petstore-generateMarshalJSON-false/ + - samples/client/others/go/allof_multiple_ref_and_discriminator/ + - samples/client/others/go/oneof-anyof-required/ + - samples/client/others/go/oneof-discriminator-lookup/ steps: - uses: actions/checkout@v5 - uses: actions/setup-go@v6 diff --git a/CI/circle_parallel.sh b/CI/circle_parallel.sh index 6ab5ed3927c..1dc32c6e963 100755 --- a/CI/circle_parallel.sh +++ b/CI/circle_parallel.sh @@ -56,11 +56,6 @@ elif [ "$NODE_INDEX" = "2" ]; then sudo ./setup-cpp-x64-linux --compiler llvm --cmake true --ninja true source ~/.cpprc # activate cpp environment variables - # run go integration tests - (cd samples/client/petstore/go && mvn integration-test) - (cd samples/openapi3/client/petstore/go && mvn integration-test) - (cd samples/openapi3/client/petstore/go-petstore-generateMarshalJSON-false && mvn integration-test) - (cd samples/client/others/go/allof_multiple_ref_and_discriminator && mvn integration-test) (cd samples/client/petstore/cpp-restsdk/client && mvn integration-test) elif [ "$NODE_INDEX" = "3" ]; then diff --git a/bin/configs/go-petstore-oas2.yaml b/bin/configs/go-petstore-oas2.yaml index 18cb77a9c25..31f3436cf27 100644 --- a/bin/configs/go-petstore-oas2.yaml +++ b/bin/configs/go-petstore-oas2.yaml @@ -1,6 +1,6 @@ generatorName: go outputDir: samples/client/petstore/go/go-petstore -inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml +inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing-localhost.yaml templateDir: modules/openapi-generator/src/main/resources/go additionalProperties: packageName: petstore diff --git a/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing-localhost.yaml b/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing-localhost.yaml new file mode 100644 index 00000000000..b1399c43750 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing-localhost.yaml @@ -0,0 +1,2014 @@ +swagger: '2.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' +host: localhost +basePath: /v2 +tags: + - name: pet + description: Everything about your Pets + - name: store + description: Access to Petstore orders + - name: user + description: Operations about user +schemes: + - http +paths: + /pet: + post: + tags: + - pet + summary: Add a new pet to the store + description: '' + operationId: addPet + consumes: + - application/json + - application/xml + produces: + - application/xml + - application/json + parameters: + - in: body + name: body + description: Pet object that needs to be added to the store + required: true + schema: + $ref: '#/definitions/Pet' + responses: + '200': + description: successful operation + '405': + description: Invalid input + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + put: + tags: + - pet + summary: Update an existing pet + description: '' + operationId: updatePet + consumes: + - application/json + - application/xml + produces: + - application/xml + - application/json + parameters: + - in: body + name: body + description: Pet object that needs to be added to the store + required: true + schema: + $ref: '#/definitions/Pet' + 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' + /pet/findByStatus: + get: + tags: + - pet + summary: Finds Pets by status + description: Multiple status values can be provided with comma separated strings + operationId: findPetsByStatus + produces: + - application/xml + - application/json + parameters: + - name: status + in: query + description: Status values that need to be considered for filter + required: true + type: array + items: + type: string + enum: + - available + - pending + - sold + default: available + collectionFormat: csv + responses: + '200': + description: successful operation + schema: + type: array + items: + $ref: '#/definitions/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 + produces: + - application/xml + - application/json + parameters: + - name: tags + in: query + description: Tags to filter by + required: true + type: array + uniqueItems: true + items: + type: string + collectionFormat: csv + responses: + '200': + description: successful operation + schema: + type: array + uniqueItems: true + items: + $ref: '#/definitions/Pet' + '400': + description: Invalid tag value + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + deprecated: true + '/pet/{petId}': + get: + tags: + - pet + summary: Find pet by ID + description: Returns a single pet + operationId: getPetById + produces: + - application/xml + - application/json + parameters: + - name: petId + in: path + description: ID of pet to return + required: true + type: integer + format: int64 + responses: + '200': + description: successful operation + schema: + $ref: '#/definitions/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 + consumes: + - application/x-www-form-urlencoded + produces: + - application/xml + - application/json + parameters: + - name: petId + in: path + description: ID of pet that needs to be updated + required: true + type: integer + format: int64 + - name: name + in: formData + description: Updated name of the pet + required: false + type: string + - name: status + in: formData + description: Updated status of the pet + required: false + type: string + responses: + '405': + description: Invalid input + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + delete: + tags: + - pet + summary: Deletes a pet + description: '' + operationId: deletePet + produces: + - application/xml + - application/json + parameters: + - name: api_key + in: header + required: false + type: string + - name: petId + in: path + description: Pet id to delete + required: true + 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 + consumes: + - multipart/form-data + produces: + - application/json + parameters: + - name: petId + in: path + description: ID of pet to update + required: true + type: integer + format: int64 + - name: additionalMetadata + in: formData + description: Additional data to pass to server + required: false + type: string + - name: file + in: formData + description: file to upload + required: false + type: file + responses: + '200': + description: successful operation + schema: + $ref: '#/definitions/ApiResponse' + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + /store/inventory: + get: + tags: + - store + summary: Returns pet inventories by status + description: Returns a map of status codes to quantities + operationId: getInventory + produces: + - application/json + parameters: [] + responses: + '200': + description: successful operation + 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 + produces: + - application/xml + - application/json + parameters: + - in: body + name: body + description: order placed for purchasing the pet + required: true + schema: + $ref: '#/definitions/Order' + responses: + '200': + description: successful operation + schema: + $ref: '#/definitions/Order' + '400': + description: Invalid Order + '/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 + produces: + - application/xml + - application/json + parameters: + - name: order_id + in: path + description: ID of pet that needs to be fetched + required: true + type: integer + maximum: 5 + minimum: 1 + format: int64 + responses: + '200': + description: successful operation + schema: + $ref: '#/definitions/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 + produces: + - application/xml + - application/json + parameters: + - name: order_id + in: path + description: ID of the order that needs to be deleted + required: true + 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 + produces: + - application/xml + - application/json + parameters: + - in: body + name: body + description: Created user object + required: true + schema: + $ref: '#/definitions/User' + responses: + default: + description: successful operation + /user/createWithArray: + post: + tags: + - user + summary: Creates list of users with given input array + description: '' + operationId: createUsersWithArrayInput + produces: + - application/xml + - application/json + parameters: + - in: body + name: body + description: List of user object + required: true + schema: + type: array + items: + $ref: '#/definitions/User' + responses: + default: + description: successful operation + /user/createWithList: + post: + tags: + - user + summary: Creates list of users with given input array + description: '' + operationId: createUsersWithListInput + produces: + - application/xml + - application/json + parameters: + - in: body + name: body + description: List of user object + required: true + schema: + type: array + items: + $ref: '#/definitions/User' + responses: + default: + description: successful operation + /user/login: + get: + tags: + - user + summary: Logs user into the system + description: '' + operationId: loginUser + produces: + - application/xml + - application/json + parameters: + - name: username + in: query + description: The user name for login + required: true + type: string + - name: password + in: query + description: The password for login in clear text + required: true + type: string + responses: + '200': + description: successful operation + schema: + type: string + headers: + X-Rate-Limit: + type: integer + format: int32 + description: calls per hour allowed by the user + X-Expires-After: + type: string + format: date-time + description: date in UTC when token expires + '400': + description: Invalid username/password supplied + /user/logout: + get: + tags: + - user + summary: Logs out current logged in user session + description: '' + operationId: logoutUser + produces: + - application/xml + - application/json + parameters: [] + responses: + default: + description: successful operation + '/user/{username}': + get: + tags: + - user + summary: Get user by user name + description: '' + operationId: getUserByName + produces: + - application/xml + - application/json + parameters: + - name: username + in: path + description: 'The name that needs to be fetched. Use user1 for testing.' + required: true + type: string + responses: + '200': + description: successful operation + schema: + $ref: '#/definitions/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 + produces: + - application/xml + - application/json + parameters: + - name: username + in: path + description: name that need to be deleted + required: true + type: string + - in: body + name: body + description: Updated user object + required: true + schema: + $ref: '#/definitions/User' + responses: + '400': + description: Invalid user supplied + '404': + description: User not found + delete: + tags: + - user + summary: Delete user + description: This can only be done by the logged in user. + operationId: deleteUser + produces: + - application/xml + - application/json + parameters: + - name: username + in: path + description: The name that needs to be deleted + required: true + 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 + consumes: + - application/json + produces: + - application/json + parameters: + - in: body + name: body + description: client model + required: true + schema: + $ref: '#/definitions/Client' + responses: + '200': + description: successful operation + schema: + $ref: '#/definitions/Client' + security: + - api_key_query: [] + /fake: + patch: + tags: + - fake + summary: To test "client" model + description: To test "client" model + operationId: testClientModel + consumes: + - application/json + produces: + - application/json + parameters: + - in: body + name: body + description: client model + required: true + schema: + $ref: '#/definitions/Client' + responses: + '200': + description: successful operation + schema: + $ref: '#/definitions/Client' + get: + tags: + - fake + summary: To test enum parameters + description: To test enum parameters + operationId: testEnumParameters + consumes: + - "application/x-www-form-urlencoded" + parameters: + - name: enum_form_string_array + type: array + items: + type: string + default: '$' + enum: + - '>' + - '$' + in: formData + description: Form parameter enum test (string array) + - name: enum_form_string + type: string + default: '-efg' + enum: + - _abc + - '-efg' + - (xyz) + in: formData + description: Form parameter enum test (string) + - name: enum_header_string_array + type: array + items: + type: string + default: '$' + enum: + - '>' + - '$' + in: header + description: Header parameter enum test (string array) + - name: enum_header_string + type: string + default: '-efg' + enum: + - _abc + - '-efg' + - (xyz) + in: header + description: Header parameter enum test (string) + - name: enum_query_string_array + type: array + items: + type: string + default: '$' + enum: + - '>' + - '$' + in: query + description: Query parameter enum test (string array) + - name: enum_query_string + type: string + default: '-efg' + enum: + - _abc + - '-efg' + - (xyz) + in: query + description: Query parameter enum test (string) + - name: enum_query_integer + type: integer + format: int32 + enum: + - 1 + - -2 + in: query + description: Query parameter enum test (double) + - name: enum_query_double + type: number + format: double + enum: + - 1.1 + - -1.2 + in: query + description: Query parameter enum test (double) + responses: + '400': + description: Invalid request + '404': + description: Not found + post: + tags: + - fake + summary: "Fake endpoint for testing various parameters\n + 假端點\n + 偽のエンドポイント\n + 가짜 엔드 포인트" + description: "Fake endpoint for testing various parameters\n + 假端點\n + 偽のエンドポイント\n + 가짜 엔드 포인트" + operationId: testEndpointParameters + consumes: + - application/x-www-form-urlencoded + parameters: + - name: integer + type: integer + maximum: 100 + minimum: 10 + in: formData + description: None + - name: int32 + type: integer + format: int32 + maximum: 200 + minimum: 20 + in: formData + description: None + - name: int64 + type: integer + format: int64 + in: formData + description: None + - name: number + type: number + maximum: 543.2 + minimum: 32.1 + in: formData + description: None + required: true + - name: float + type: number + format: float + maximum: 987.6 + in: formData + description: None + - name: double + type: number + in: formData + format: double + maximum: 123.4 + minimum: 67.8 + required: true + description: None + - name: string + type: string + pattern: /[a-z]/i + in: formData + description: None + - name: pattern_without_delimiter + type: string + pattern: "^[A-Z].*" + in: formData + description: None + required: true + - name: byte + type: string + format: byte + in: formData + description: None + required: true + - name: binary + type: string + format: binary + in: formData + description: None + - name: date + type: string + format: date + in: formData + description: None + - name: dateTime + type: string + format: date-time + in: formData + description: None + - name: password + type: string + format: password + maxLength: 64 + minLength: 10 + in: formData + description: None + - name: callback + type: string + in: formData + description: None + responses: + '400': + description: Invalid username supplied + '404': + description: User not found + security: + - http_basic_test: [] + delete: + tags: + - fake + summary: Fake endpoint to test group parameters (optional) + description: Fake endpoint to test group parameters (optional) + operationId: testGroupParameters + x-group-parameters: true + parameters: + - name: required_string_group + type: integer + in: query + description: Required String in group parameters + required: true + - name: required_boolean_group + type: boolean + in: header + description: Required Boolean in group parameters + required: true + - name: required_int64_group + type: integer + format: int64 + in: query + description: Required Integer in group parameters + required: true + - name: string_group + type: integer + in: query + description: String in group parameters + - name: boolean_group + type: boolean + in: header + description: Boolean in group parameters + - name: int64_group + type: integer + format: int64 + in: query + description: Integer in group parameters + responses: + '400': + description: Something wrong + /fake/outer/number: + post: + tags: + - fake + description: Test serialization of outer number types + operationId: fakeOuterNumberSerialize + parameters: + - name: body + in: body + description: Input number as post body + schema: + $ref: '#/definitions/OuterNumber' + responses: + '200': + description: Output number + schema: + $ref: '#/definitions/OuterNumber' + /fake/outer/string: + post: + tags: + - fake + description: Test serialization of outer string types + operationId: fakeOuterStringSerialize + parameters: + - name: body + in: body + description: Input string as post body + schema: + $ref: '#/definitions/OuterString' + responses: + '200': + description: Output string + schema: + $ref: '#/definitions/OuterString' + /fake/outer/boolean: + post: + tags: + - fake + description: Test serialization of outer boolean types + operationId: fakeOuterBooleanSerialize + parameters: + - name: body + in: body + description: Input boolean as post body + schema: + $ref: '#/definitions/OuterBoolean' + responses: + '200': + description: Output boolean + schema: + $ref: '#/definitions/OuterBoolean' + /fake/outer/composite: + post: + tags: + - fake + description: Test serialization of object with outer number type + operationId: fakeOuterCompositeSerialize + parameters: + - name: body + in: body + description: Input composite as post body + schema: + $ref: '#/definitions/OuterComposite' + responses: + '200': + description: Output composite + schema: + $ref: '#/definitions/OuterComposite' + /fake/jsonFormData: + get: + tags: + - fake + summary: test json serialization of form data + description: '' + operationId: testJsonFormData + consumes: + - application/x-www-form-urlencoded + parameters: + - name: param + in: formData + description: field1 + required: true + type: string + - name: param2 + in: formData + description: field2 + required: true + type: string + responses: + '200': + description: successful operation + /fake/inline-additionalProperties: + post: + tags: + - fake + summary: test inline additionalProperties + description: '' + operationId: testInlineAdditionalProperties + consumes: + - application/json + parameters: + - name: param + in: body + description: request body + required: true + schema: + type: object + additionalProperties: + type: string + responses: + '200': + description: successful operation + /fake/body-with-query-params: + put: + tags: + - fake + operationId: testBodyWithQueryParams + parameters: + - name: body + in: body + required: true + schema: + $ref: '#/definitions/User' + - name: query + in: query + required: true + type: string + consumes: + - application/json + responses: + '200': + description: Success + /fake/create_xml_item: + post: + tags: + - fake + operationId: createXmlItem + summary: creates an XmlItem + description: this route creates an XmlItem + consumes: + - 'application/xml' + - 'application/xml; charset=utf-8' + - 'application/xml; charset=utf-16' + - 'text/xml' + - 'text/xml; charset=utf-8' + - 'text/xml; charset=utf-16' + produces: + - 'application/xml' + - 'application/xml; charset=utf-8' + - 'application/xml; charset=utf-16' + - 'text/xml' + - 'text/xml; charset=utf-8' + - 'text/xml; charset=utf-16' + parameters: + - in: body + name: XmlItem + description: XmlItem Body + required: true + schema: + $ref: '#/definitions/XmlItem' + responses: + 200: + description: successful operation + /another-fake/dummy: + patch: + tags: + - "$another-fake?" + summary: To test special tags + description: To test special tags and operation ID starting with number + operationId: 123_test_@#$%_special_tags + consumes: + - application/json + produces: + - application/json + parameters: + - in: body + name: body + description: client model + required: true + schema: + $ref: '#/definitions/Client' + - in: header + name: uuid_test + description: to test uuid example value + required: true + default: 1111-2222-3333-4444 + type: string + format: uuid + responses: + '200': + description: successful operation + schema: + $ref: '#/definitions/Client' + /fake/body-with-file-schema: + put: + tags: + - fake + description: 'For this test, the body for this request much reference a schema named `File`.' + operationId: testBodyWithFileSchema + parameters: + - name: body + in: body + required: true + schema: + $ref: '#/definitions/FileSchemaTestClass' + consumes: + - application/json + responses: + '200': + description: Success + /fake/test-query-parameters: + put: + tags: + - fake + description: 'To test the collection format in query parameters' + operationId: testQueryParameterCollectionFormat + parameters: + - name: pipe + in: query + required: true + type: array + items: + type: string + collectionFormat: pipe + - name: ioutil + in: query + required: true + type: array + items: + type: string + collectionFormat: tsv + - name: http + in: query + required: true + type: array + items: + type: string + collectionFormat: ssv + - name: url + in: query + required: true + type: array + items: + type: string + collectionFormat: csv + - name: context + in: query + required: true + type: array + items: + type: string + collectionFormat: multi + consumes: + - application/json + responses: + '200': + description: Success + '/fake/{petId}/uploadImageWithRequiredFile': + post: + tags: + - pet + summary: uploads an image (required) + description: '' + operationId: uploadFileWithRequiredFile + consumes: + - multipart/form-data + produces: + - application/json + parameters: + - name: petId + in: path + description: ID of pet to update + required: true + type: integer + format: int64 + - name: additionalMetadata + in: formData + description: Additional data to pass to server + required: false + type: string + - name: requiredFile + in: formData + description: file to upload + required: true + type: file + responses: + '200': + description: successful operation + schema: + $ref: '#/definitions/ApiResponse' + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' +securityDefinitions: + petstore_auth: + type: oauth2 + authorizationUrl: 'http://localhost/api/oauth/dialog' + flow: implicit + 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: basic +definitions: + 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: '#/definitions/Category' + name: + type: string + example: doggie + photoUrls: + type: array + uniqueItems: true + xml: + name: photoUrl + wrapped: true + items: + type: string + tags: + type: array + xml: + name: tag + wrapped: true + items: + $ref: '#/definitions/Tag' + status: + type: string + description: pet status in the store + deprecated: true + enum: + - available + - pending + - sold + xml: + name: Pet + ApiResponse: + type: object + properties: + code: + type: integer + format: int32 + type: + type: string + message: + type: string + '$special[model.name]': + properties: + '$special[property.name]': + type: integer + format: int64 + xml: + name: '$special[model.name]' + Return: + description: Model for testing reserved words + properties: + return: + type: integer + format: int32 + xml: + name: Return + Name: + description: Model for testing model name same as property name + required: + - name + properties: + name: + type: integer + format: int32 + snake_case: + readOnly: true + type: integer + format: int32 + property: + type: string + 123Number: + type: integer + readOnly: true + xml: + name: Name + 200_response: + description: Model for testing model name starting with number + properties: + name: + type: integer + format: int32 + class: + type: string + xml: + name: Name + ClassModel: + description: Model for testing model with "_class" property + properties: + _class: + type: string + Dog: + allOf: + - $ref: '#/definitions/Animal' + - type: object + properties: + breed: + type: string + Cat: + allOf: + - $ref: '#/definitions/Animal' + - type: object + properties: + declawed: + type: boolean + BigCat: + allOf: + - $ref: '#/definitions/Cat' + - type: object + properties: + kind: + type: string + enum: [lions, tigers, leopards, jaguars] + Animal: + type: object + discriminator: className + required: + - className + properties: + className: + type: string + color: + type: string + default: 'red' + AnimalFarm: + type: array + items: + $ref: '#/definitions/Animal' + format_test: + type: object + required: + - number + - byte + - date + - password + properties: + integer: + type: integer + maximum: 100 + minimum: 10 + int32: + type: integer + format: int32 + maximum: 200 + minimum: 20 + int64: + type: integer + format: int64 + number: + maximum: 543.2 + minimum: 32.1 + type: number + float: + type: number + format: float + maximum: 987.6 + minimum: 54.3 + double: + type: number + format: double + maximum: 123.4 + minimum: 67.8 + string: + type: string + pattern: /[a-z]/i + byte: + type: string + format: byte + binary: + type: string + format: binary + date: + type: string + format: date + dateTime: + type: string + format: date-time + uuid: + type: string + format: uuid + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + password: + type: string + format: password + maxLength: 64 + minLength: 10 + BigDecimal: + type: string + format: number + EnumClass: + type: string + default: '-efg' + enum: + - _abc + - '-efg' + - (xyz) + Enum_Test: + type: object + required: + - enum_string_required + properties: + enum_string: + type: string + enum: + - UPPER + - lower + - '' + enum_string_required: + type: string + enum: + - UPPER + - lower + - '' + enum_integer: + type: integer + format: int32 + enum: + - 1 + - -1 + enum_number: + type: number + format: double + enum: + - 1.1 + - -1.2 + outerEnum: + $ref: '#/definitions/OuterEnum' + AdditionalPropertiesClass: + type: object + properties: + map_string: + type: object + additionalProperties: + type: string + map_number: + type: object + additionalProperties: + type: number + map_integer: + type: object + additionalProperties: + type: integer + map_boolean: + type: object + additionalProperties: + type: boolean + map_array_integer: + type: object + additionalProperties: + type: array + items: + type: integer + map_array_anytype: + type: object + additionalProperties: + type: array + items: + type: object + map_map_string: + type: object + additionalProperties: + type: object + additionalProperties: + type: string + map_map_anytype: + type: object + additionalProperties: + type: object + additionalProperties: + type: object + anytype_1: + type: object + anytype_2: {} + anytype_3: + type: object + properties: {} + AdditionalPropertiesString: + type: object + properties: + name: + type: string + additionalProperties: + type: string + AdditionalPropertiesInteger: + type: object + properties: + name: + type: string + additionalProperties: + type: integer + AdditionalPropertiesNumber: + type: object + properties: + name: + type: string + additionalProperties: + type: number + AdditionalPropertiesBoolean: + type: object + properties: + name: + type: string + additionalProperties: + type: boolean + AdditionalPropertiesArray: + type: object + properties: + name: + type: string + additionalProperties: + type: array + items: + type: object + AdditionalPropertiesObject: + type: object + properties: + name: + type: string + additionalProperties: + type: object + additionalProperties: + type: object + AdditionalPropertiesAnyType: + type: object + properties: + name: + type: string + additionalProperties: + type: object + MixedPropertiesAndAdditionalPropertiesClass: + type: object + properties: + uuid: + type: string + format: uuid + dateTime: + type: string + format: date-time + map: + type: object + additionalProperties: + $ref: '#/definitions/Animal' + List: + type: object + properties: + 123-list: + type: string + Client: + type: object + properties: + client: + type: string + ReadOnlyFirst: + type: object + properties: + bar: + type: string + readOnly: true + baz: + type: string + hasOnlyReadOnly: + type: object + properties: + bar: + type: string + readOnly: true + foo: + type: string + readOnly: true + Capitalization: + type: object + properties: + smallCamel: + type: string + CapitalCamel: + type: string + small_Snake: + type: string + Capital_Snake: + type: string + SCA_ETH_Flow_Points: + type: string + ATT_NAME: + description: > + Name of the pet + type: string + MapTest: + type: object + properties: + map_map_of_string: + type: object + additionalProperties: + type: object + additionalProperties: + type: string + # comment out the following (map of map of enum) as many language not yet support this + #map_map_of_enum: + # type: object + # additionalProperties: + # type: object + # additionalProperties: + # type: string + # enum: + # - UPPER + # - lower + map_of_enum_string: + type: object + additionalProperties: + type: string + enum: + - UPPER + - lower + direct_map: + type: object + additionalProperties: + type: boolean + indirect_map: + $ref: "#/definitions/StringBooleanMap" + ArrayTest: + type: object + properties: + array_of_string: + type: array + items: + type: string + array_array_of_integer: + type: array + items: + type: array + items: + type: integer + format: int64 + array_array_of_model: + type: array + items: + type: array + items: + $ref: '#/definitions/ReadOnlyFirst' + # commented out the below test case for array of enum for the time being + # as not all language can handle it + #array_of_enum: + # type: array + # items: + # type: string + # enum: + # - UPPER + # - lower + NumberOnly: + type: object + properties: + JustNumber: + type: number + ArrayOfNumberOnly: + type: object + properties: + ArrayNumber: + type: array + items: + type: number + ArrayOfArrayOfNumberOnly: + type: object + properties: + ArrayArrayNumber: + type: array + items: + type: array + items: + type: number + EnumArrays: + type: object + properties: + just_symbol: + type: string + enum: + - ">=" + - "$" + array_enum: + type: array + items: + type: string + enum: + - fish + - crab + # comment out the following as 2d array of enum is not supported at the moment + #array_array_enum: + # type: array + # items: + # type: array + # items: + # type: string + # enum: + # - Cat + # - Dog + OuterEnum: + type: string + enum: + - "placed" + - "approved" + - "delivered" + OuterComposite: + type: object + properties: + my_number: + $ref: '#/definitions/OuterNumber' + my_string: + $ref: '#/definitions/OuterString' + my_boolean: + $ref: '#/definitions/OuterBoolean' + OuterNumber: + type: number + OuterString: + type: string + OuterBoolean: + type: boolean + x-codegen-body-parameter-name: boolean_post_body + StringBooleanMap: + additionalProperties: + type: boolean + FileSchemaTestClass: + type: object + properties: + file: + $ref: "#/definitions/File" + files: + type: array + items: + $ref: "#/definitions/File" + File: + type: object + description: 'Must be named `File` for test.' + properties: + sourceURI: + description: 'Test capitalization' + type: string + TypeHolderDefault: + type: object + required: + - string_item + - number_item + - integer_item + - bool_item + - array_item + properties: + string_item: + type: string + default: what + number_item: + type: number + default: 1.234 + integer_item: + type: integer + default: -2 + bool_item: + type: boolean + default: true + array_item: + type: array + items: + type: integer + default: + - 0 + - 1 + - 2 + - 3 + TypeHolderExample: + type: object + required: + - string_item + - number_item + - float_item + - integer_item + - bool_item + - array_item + properties: + string_item: + type: string + example: what + number_item: + type: number + example: 1.234 + float_item: + type: number + example: 1.234 + format: float + integer_item: + type: integer + example: -2 + bool_item: + type: boolean + example: true + array_item: + type: array + items: + type: integer + example: + - 0 + - 1 + - 2 + - 3 + XmlItem: + type: object + xml: + namespace: http://a.com/schema + prefix: pre + properties: + attribute_string: + type: string + example: string + xml: + attribute: true + attribute_number: + type: number + example: 1.234 + xml: + attribute: true + attribute_integer: + type: integer + example: -2 + xml: + attribute: true + attribute_boolean: + type: boolean + example: true + xml: + attribute: true + wrapped_array: + type: array + xml: + wrapped: true + items: + type: integer + name_string: + type: string + example: string + xml: + name: xml_name_string + name_number: + type: number + example: 1.234 + xml: + name: xml_name_number + name_integer: + type: integer + example: -2 + xml: + name: xml_name_integer + name_boolean: + type: boolean + example: true + xml: + name: xml_name_boolean + name_array: + type: array + items: + type: integer + xml: + name: xml_name_array_item + name_wrapped_array: + type: array + xml: + wrapped: true + name: xml_name_wrapped_array + items: + type: integer + xml: + name: xml_name_wrapped_array_item + prefix_string: + type: string + example: string + xml: + prefix: ab + prefix_number: + type: number + example: 1.234 + xml: + prefix: cd + prefix_integer: + type: integer + example: -2 + xml: + prefix: ef + prefix_boolean: + type: boolean + example: true + xml: + prefix: gh + prefix_array: + type: array + items: + type: integer + xml: + prefix: ij + prefix_wrapped_array: + type: array + xml: + wrapped: true + prefix: kl + items: + type: integer + xml: + prefix: mn + namespace_string: + type: string + example: string + xml: + namespace: http://a.com/schema + namespace_number: + type: number + example: 1.234 + xml: + namespace: http://b.com/schema + namespace_integer: + type: integer + example: -2 + xml: + namespace: http://c.com/schema + namespace_boolean: + type: boolean + example: true + xml: + namespace: http://d.com/schema + namespace_array: + type: array + items: + type: integer + xml: + namespace: http://e.com/schema + namespace_wrapped_array: + type: array + xml: + wrapped: true + namespace: http://f.com/schema + items: + type: integer + xml: + namespace: http://g.com/schema + prefix_ns_string: + type: string + example: string + xml: + namespace: http://a.com/schema + prefix: a + prefix_ns_number: + type: number + example: 1.234 + xml: + namespace: http://b.com/schema + prefix: b + prefix_ns_integer: + type: integer + example: -2 + xml: + namespace: http://c.com/schema + prefix: c + prefix_ns_boolean: + type: boolean + example: true + xml: + namespace: http://d.com/schema + prefix: d + prefix_ns_array: + type: array + items: + type: integer + xml: + namespace: http://e.com/schema + prefix: e + prefix_ns_wrapped_array: + type: array + xml: + wrapped: true + namespace: http://f.com/schema + prefix: f + items: + type: integer + xml: + namespace: http://g.com/schema + prefix: g diff --git a/modules/openapi-generator/src/test/resources/3_0/go/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/go/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml index 515efb805b7..a7d9bf4139b 100644 --- a/modules/openapi-generator/src/test/resources/3_0/go/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/go/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml @@ -49,6 +49,7 @@ paths: $ref: '#/components/schemas/Foo' /pet: servers: + - url: 'http://localhost/v2' - url: 'http://petstore.swagger.io/v2' - url: 'http://path-server-test.petstore.local/v2' post: @@ -1308,6 +1309,7 @@ paths: schema: type: object servers: + - url: 'http://localhost/v2' - url: 'http://{server}.swagger.io:{port}/v2' description: petstore server variables: @@ -1322,7 +1324,7 @@ servers: - 80 - 8080 default: 80 - - url: https://localhost:8080/{version} + - url: http://localhost:8080/{version} description: The local server variables: version: @@ -1330,7 +1332,7 @@ servers: - 'v1' - 'v2' default: 'v2' - - url: https://127.0.0.1/no_variable + - url: http://127.0.0.1/no_variable description: The local server without variables components: requestBodies: @@ -1365,7 +1367,7 @@ components: type: oauth2 flows: implicit: - authorizationUrl: 'http://petstore.swagger.io/api/oauth/dialog' + authorizationUrl: 'http://localhost/api/oauth/dialog' scopes: 'write:pets': modify pets in your account 'read:pets': read your pets diff --git a/samples/client/others/go/oneof-required/.gitignore b/samples/client/others/go/oneof-required/.gitignore deleted file mode 100644 index daf913b1b34..00000000000 --- a/samples/client/others/go/oneof-required/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe -*.test -*.prof diff --git a/samples/client/others/go/oneof-required/.openapi-generator-ignore b/samples/client/others/go/oneof-required/.openapi-generator-ignore deleted file mode 100644 index 7484ee590a3..00000000000 --- a/samples/client/others/go/oneof-required/.openapi-generator-ignore +++ /dev/null @@ -1,23 +0,0 @@ -# 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/client/others/go/oneof-required/.openapi-generator/FILES b/samples/client/others/go/oneof-required/.openapi-generator/FILES deleted file mode 100644 index aaf38bd62c0..00000000000 --- a/samples/client/others/go/oneof-required/.openapi-generator/FILES +++ /dev/null @@ -1,21 +0,0 @@ -.gitignore -.travis.yml -README.md -api/openapi.yaml -client.go -configuration.go -docs/NestedObject1.md -docs/NestedObject2.md -docs/Object.md -docs/Object2.md -docs/Object3.md -git_push.sh -go.mod -go.sum -model_nested_object1.go -model_nested_object2.go -model_object.go -model_object2.go -model_object3.go -response.go -utils.go diff --git a/samples/client/others/go/oneof-required/.openapi-generator/VERSION b/samples/client/others/go/oneof-required/.openapi-generator/VERSION deleted file mode 100644 index fff4bdd7ab5..00000000000 --- a/samples/client/others/go/oneof-required/.openapi-generator/VERSION +++ /dev/null @@ -1 +0,0 @@ -7.3.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/others/go/oneof-required/.travis.yml b/samples/client/others/go/oneof-required/.travis.yml deleted file mode 100644 index f5cb2ce9a5a..00000000000 --- a/samples/client/others/go/oneof-required/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: go - -install: - - go get -d -v . - -script: - - go build -v ./ - diff --git a/samples/client/others/go/oneof-required/README.md b/samples/client/others/go/oneof-required/README.md deleted file mode 100644 index 0da5da58af8..00000000000 --- a/samples/client/others/go/oneof-required/README.md +++ /dev/null @@ -1,114 +0,0 @@ -# Go API client for openapi - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -## Overview -This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client. - -- API version: 1.0.0 -- Package version: 1.0.0 -- Build package: org.openapitools.codegen.languages.GoClientCodegen - -## Installation - -Install the following dependencies: - -```sh -go get github.com/stretchr/testify/assert -go get golang.org/x/net/context -``` - -Put the package under your project folder and add the following in import: - -```go -import openapi "github.com/GIT_USER_ID/GIT_REPO_ID" -``` - -To use a proxy, set the environment variable `HTTP_PROXY`: - -```go -os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port") -``` - -## Configuration of Server URL - -Default configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification. - -### Select Server Configuration - -For using other server than the one defined on index 0 set context value `openapi.ContextServerIndex` of type `int`. - -```go -ctx := context.WithValue(context.Background(), openapi.ContextServerIndex, 1) -``` - -### Templated Server URL - -Templated server URL is formatted using default variables from configuration or from context value `openapi.ContextServerVariables` of type `map[string]string`. - -```go -ctx := context.WithValue(context.Background(), openapi.ContextServerVariables, map[string]string{ - "basePath": "v2", -}) -``` - -Note, enum values are always validated and all unused variables are silently ignored. - -### URLs Configuration per Operation - -Each operation can use different server URL defined using `OperationServers` map in the `Configuration`. -An operation is uniquely identified by `"{classname}Service.{nickname}"` string. -Similar rules for overriding default operation server index and variables applies by using `openapi.ContextOperationServerIndices` and `openapi.ContextOperationServerVariables` context maps. - -```go -ctx := context.WithValue(context.Background(), openapi.ContextOperationServerIndices, map[string]int{ - "{classname}Service.{nickname}": 2, -}) -ctx = context.WithValue(context.Background(), openapi.ContextOperationServerVariables, map[string]map[string]string{ - "{classname}Service.{nickname}": { - "port": "8443", - }, -}) -``` - -## Documentation for API Endpoints - -All URIs are relative to *http://localhost* - -Class | Method | HTTP request | Description ------------- | ------------- | ------------- | ------------- - - -## Documentation For Models - - - [NestedObject1](docs/NestedObject1.md) - - [NestedObject2](docs/NestedObject2.md) - - [Object](docs/Object.md) - - [Object2](docs/Object2.md) - - [Object3](docs/Object3.md) - - -## Documentation For Authorization - -Endpoints do not require authorization. - - -## Documentation for Utility Methods - -Due to the fact that model structure members are all pointers, this package contains -a number of utility functions to easily obtain pointers to values of basic types. -Each of these functions takes a value of the given basic type and returns a pointer to it: - -* `PtrBool` -* `PtrInt` -* `PtrInt32` -* `PtrInt64` -* `PtrFloat` -* `PtrFloat32` -* `PtrFloat64` -* `PtrString` -* `PtrTime` - -## Author - - diff --git a/samples/client/others/go/oneof-required/api/openapi.yaml b/samples/client/others/go/oneof-required/api/openapi.yaml deleted file mode 100644 index 04946860f06..00000000000 --- a/samples/client/others/go/oneof-required/api/openapi.yaml +++ /dev/null @@ -1,37 +0,0 @@ -openapi: 3.0.0 -info: - title: Test - version: 1.0.0 -servers: -- url: / -paths: {} -components: - schemas: - NestedObject1: - properties: - field1: - description: Specifies an action name to be used with the Android Intent - class. - type: string - required: - - field1 - NestedObject2: - properties: - field2: - description: Specifies an action name to be used with the Android Intent - class. - type: string - required: - - field2 - Object: - oneOf: - - $ref: '#/components/schemas/NestedObject1' - - $ref: '#/components/schemas/NestedObject2' - Object2: - anyOf: - - $ref: '#/components/schemas/NestedObject1' - - $ref: '#/components/schemas/NestedObject2' - Object3: - allOf: - - $ref: '#/components/schemas/NestedObject1' - - $ref: '#/components/schemas/NestedObject2' diff --git a/samples/client/others/go/oneof-required/client.go b/samples/client/others/go/oneof-required/client.go deleted file mode 100644 index f745e46a426..00000000000 --- a/samples/client/others/go/oneof-required/client.go +++ /dev/null @@ -1,657 +0,0 @@ -/* -Test - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 1.0.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package openapi - -import ( - "bytes" - "context" - "encoding/json" - "encoding/xml" - "errors" - "fmt" - "io" - "log" - "mime/multipart" - "net/http" - "net/http/httputil" - "net/url" - "os" - "path/filepath" - "reflect" - "regexp" - "strconv" - "strings" - "time" - "unicode/utf8" - -) - -var ( - JsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:[^;]+\+)?json)`) - XmlCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:[^;]+\+)?xml)`) - queryParamSplit = regexp.MustCompile(`(^|&)([^&]+)`) - queryDescape = strings.NewReplacer( "%5B", "[", "%5D", "]" ) -) - -// APIClient manages communication with the Test API v1.0.0 -// In most cases there should be only one, shared, APIClient. -type APIClient struct { - cfg *Configuration - common service // Reuse a single struct instead of allocating one for each service on the heap. - - // API Services -} - -type service struct { - client *APIClient -} - -// NewAPIClient creates a new API client. Requires a userAgent string describing your application. -// optionally a custom http.Client to allow for advanced features such as caching. -func NewAPIClient(cfg *Configuration) *APIClient { - if cfg.HTTPClient == nil { - cfg.HTTPClient = http.DefaultClient - } - - c := &APIClient{} - c.cfg = cfg - c.common.client = c - - // API Services - - return c -} - -func atoi(in string) (int, error) { - return strconv.Atoi(in) -} - -// selectHeaderContentType select a content type from the available list. -func selectHeaderContentType(contentTypes []string) string { - if len(contentTypes) == 0 { - return "" - } - if contains(contentTypes, "application/json") { - return "application/json" - } - return contentTypes[0] // use the first content type specified in 'consumes' -} - -// selectHeaderAccept join all accept types and return -func selectHeaderAccept(accepts []string) string { - if len(accepts) == 0 { - return "" - } - - if contains(accepts, "application/json") { - return "application/json" - } - - return strings.Join(accepts, ",") -} - -// contains is a case insensitive match, finding needle in a haystack -func contains(haystack []string, needle string) bool { - for _, a := range haystack { - if strings.EqualFold(a, needle) { - return true - } - } - return false -} - -// Verify optional parameters are of the correct type. -func typeCheckParameter(obj interface{}, expected string, name string) error { - // Make sure there is an object. - if obj == nil { - return nil - } - - // Check the type is as expected. - if reflect.TypeOf(obj).String() != expected { - return fmt.Errorf("expected %s to be of type %s but received %s", name, expected, reflect.TypeOf(obj).String()) - } - return nil -} - -func parameterValueToString( obj interface{}, key string ) string { - if reflect.TypeOf(obj).Kind() != reflect.Ptr { - return fmt.Sprintf("%v", obj) - } - var param,ok = obj.(MappedNullable) - if !ok { - return "" - } - dataMap,err := param.ToMap() - if err != nil { - return "" - } - return fmt.Sprintf("%v", dataMap[key]) -} - -// parameterAddToHeaderOrQuery adds the provided object to the request header or url query -// supporting deep object syntax -func parameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix string, obj interface{}, collectionType string) { - var v = reflect.ValueOf(obj) - var value = "" - if v == reflect.ValueOf(nil) { - value = "null" - } else { - switch v.Kind() { - case reflect.Invalid: - value = "invalid" - - case reflect.Struct: - if t,ok := obj.(MappedNullable); ok { - dataMap,err := t.ToMap() - if err != nil { - return - } - parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, dataMap, collectionType) - return - } - if t, ok := obj.(time.Time); ok { - parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, t.Format(time.RFC3339), collectionType) - return - } - value = v.Type().String() + " value" - case reflect.Slice: - var indValue = reflect.ValueOf(obj) - if indValue == reflect.ValueOf(nil) { - return - } - var lenIndValue = indValue.Len() - for i:=0;i 0 || (len(formFiles) > 0) { - if body != nil { - return nil, errors.New("Cannot specify postBody and multipart form at the same time.") - } - body = &bytes.Buffer{} - w := multipart.NewWriter(body) - - for k, v := range formParams { - for _, iv := range v { - if strings.HasPrefix(k, "@") { // file - err = addFile(w, k[1:], iv) - if err != nil { - return nil, err - } - } else { // form value - w.WriteField(k, iv) - } - } - } - for _, formFile := range formFiles { - if len(formFile.fileBytes) > 0 && formFile.fileName != "" { - w.Boundary() - part, err := w.CreateFormFile(formFile.formFileName, filepath.Base(formFile.fileName)) - if err != nil { - return nil, err - } - _, err = part.Write(formFile.fileBytes) - if err != nil { - return nil, err - } - } - } - - // Set the Boundary in the Content-Type - headerParams["Content-Type"] = w.FormDataContentType() - - // Set Content-Length - headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) - w.Close() - } - - if strings.HasPrefix(headerParams["Content-Type"], "application/x-www-form-urlencoded") && len(formParams) > 0 { - if body != nil { - return nil, errors.New("Cannot specify postBody and x-www-form-urlencoded form at the same time.") - } - body = &bytes.Buffer{} - body.WriteString(formParams.Encode()) - // Set Content-Length - headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) - } - - // Setup path and query parameters - url, err := url.Parse(path) - if err != nil { - return nil, err - } - - // Override request host, if applicable - if c.cfg.Host != "" { - url.Host = c.cfg.Host - } - - // Override request scheme, if applicable - if c.cfg.Scheme != "" { - url.Scheme = c.cfg.Scheme - } - - // Adding Query Param - query := url.Query() - for k, v := range queryParams { - for _, iv := range v { - query.Add(k, iv) - } - } - - // Encode the parameters. - url.RawQuery = queryParamSplit.ReplaceAllStringFunc(query.Encode(), func(s string) string { - pieces := strings.Split(s, "=") - pieces[0] = queryDescape.Replace(pieces[0]) - return strings.Join(pieces, "=") - }) - - // Generate a new request - if body != nil { - localVarRequest, err = http.NewRequest(method, url.String(), body) - } else { - localVarRequest, err = http.NewRequest(method, url.String(), nil) - } - if err != nil { - return nil, err - } - - // add header parameters, if any - if len(headerParams) > 0 { - headers := http.Header{} - for h, v := range headerParams { - headers[h] = []string{v} - } - localVarRequest.Header = headers - } - - // Add the user agent to the request. - localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) - - if ctx != nil { - // add context to the request - localVarRequest = localVarRequest.WithContext(ctx) - - // Walk through any authentication. - - } - - for header, value := range c.cfg.DefaultHeader { - localVarRequest.Header.Add(header, value) - } - return localVarRequest, nil -} - -func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) { - if len(b) == 0 { - return nil - } - if s, ok := v.(*string); ok { - *s = string(b) - return nil - } - if f, ok := v.(*os.File); ok { - f, err = os.CreateTemp("", "HttpClientFile") - if err != nil { - return - } - _, err = f.Write(b) - if err != nil { - return - } - _, err = f.Seek(0, io.SeekStart) - return - } - if f, ok := v.(**os.File); ok { - *f, err = os.CreateTemp("", "HttpClientFile") - if err != nil { - return - } - _, err = (*f).Write(b) - if err != nil { - return - } - _, err = (*f).Seek(0, io.SeekStart) - return - } - if XmlCheck.MatchString(contentType) { - if err = xml.Unmarshal(b, v); err != nil { - return err - } - return nil - } - if JsonCheck.MatchString(contentType) { - if actualObj, ok := v.(interface{ GetActualInstance() interface{} }); ok { // oneOf, anyOf schemas - if unmarshalObj, ok := actualObj.(interface{ UnmarshalJSON([]byte) error }); ok { // make sure it has UnmarshalJSON defined - if err = unmarshalObj.UnmarshalJSON(b); err != nil { - return err - } - } else { - return errors.New("Unknown type with GetActualInstance but no unmarshalObj.UnmarshalJSON defined") - } - } else if err = json.Unmarshal(b, v); err != nil { // simple model - return err - } - return nil - } - return errors.New("undefined response type") -} - -// Add a file to the multipart request -func addFile(w *multipart.Writer, fieldName, path string) error { - file, err := os.Open(filepath.Clean(path)) - if err != nil { - return err - } - err = file.Close() - if err != nil { - return err - } - - part, err := w.CreateFormFile(fieldName, filepath.Base(path)) - if err != nil { - return err - } - _, err = io.Copy(part, file) - - return err -} - -// Prevent trying to import "fmt" -func reportError(format string, a ...interface{}) error { - return fmt.Errorf(format, a...) -} - -// A wrapper for strict JSON decoding -func newStrictDecoder(data []byte) *json.Decoder { - dec := json.NewDecoder(bytes.NewBuffer(data)) - dec.DisallowUnknownFields() - return dec -} - -// Set request body from an interface{} -func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) { - if bodyBuf == nil { - bodyBuf = &bytes.Buffer{} - } - - if reader, ok := body.(io.Reader); ok { - _, err = bodyBuf.ReadFrom(reader) - } else if fp, ok := body.(*os.File); ok { - _, err = bodyBuf.ReadFrom(fp) - } else if b, ok := body.([]byte); ok { - _, err = bodyBuf.Write(b) - } else if s, ok := body.(string); ok { - _, err = bodyBuf.WriteString(s) - } else if s, ok := body.(*string); ok { - _, err = bodyBuf.WriteString(*s) - } else if JsonCheck.MatchString(contentType) { - err = json.NewEncoder(bodyBuf).Encode(body) - } else if XmlCheck.MatchString(contentType) { - var bs []byte - bs, err = xml.Marshal(body) - if err == nil { - bodyBuf.Write(bs) - } - } - - if err != nil { - return nil, err - } - - if bodyBuf.Len() == 0 { - err = fmt.Errorf("invalid body type %s\n", contentType) - return nil, err - } - return bodyBuf, nil -} - -// detectContentType method is used to figure out `Request.Body` content type for request header -func detectContentType(body interface{}) string { - contentType := "text/plain; charset=utf-8" - kind := reflect.TypeOf(body).Kind() - - switch kind { - case reflect.Struct, reflect.Map, reflect.Ptr: - contentType = "application/json; charset=utf-8" - case reflect.String: - contentType = "text/plain; charset=utf-8" - default: - if b, ok := body.([]byte); ok { - contentType = http.DetectContentType(b) - } else if kind == reflect.Slice { - contentType = "application/json; charset=utf-8" - } - } - - return contentType -} - -// Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go -type cacheControl map[string]string - -func parseCacheControl(headers http.Header) cacheControl { - cc := cacheControl{} - ccHeader := headers.Get("Cache-Control") - for _, part := range strings.Split(ccHeader, ",") { - part = strings.Trim(part, " ") - if part == "" { - continue - } - if strings.ContainsRune(part, '=') { - keyval := strings.Split(part, "=") - cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",") - } else { - cc[part] = "" - } - } - return cc -} - -// CacheExpires helper function to determine remaining time before repeating a request. -func CacheExpires(r *http.Response) time.Time { - // Figure out when the cache expires. - var expires time.Time - now, err := time.Parse(time.RFC1123, r.Header.Get("date")) - if err != nil { - return time.Now() - } - respCacheControl := parseCacheControl(r.Header) - - if maxAge, ok := respCacheControl["max-age"]; ok { - lifetime, err := time.ParseDuration(maxAge + "s") - if err != nil { - expires = now - } else { - expires = now.Add(lifetime) - } - } else { - expiresHeader := r.Header.Get("Expires") - if expiresHeader != "" { - expires, err = time.Parse(time.RFC1123, expiresHeader) - if err != nil { - expires = now - } - } - } - return expires -} - -func strlen(s string) int { - return utf8.RuneCountInString(s) -} - -// GenericOpenAPIError Provides access to the body, error and model on returned errors. -type GenericOpenAPIError struct { - body []byte - error string - model interface{} -} - -// Error returns non-empty string if there was an error. -func (e GenericOpenAPIError) Error() string { - return e.error -} - -// Body returns the raw bytes of the response -func (e GenericOpenAPIError) Body() []byte { - return e.body -} - -// Model returns the unpacked model of the error -func (e GenericOpenAPIError) Model() interface{} { - return e.model -} - -// format error message using title and detail when model implements rfc7807 -func formatErrorMessage(status string, v interface{}) string { - str := "" - metaValue := reflect.ValueOf(v).Elem() - - if metaValue.Kind() == reflect.Struct { - field := metaValue.FieldByName("Title") - if field != (reflect.Value{}) { - str = fmt.Sprintf("%s", field.Interface()) - } - - field = metaValue.FieldByName("Detail") - if field != (reflect.Value{}) { - str = fmt.Sprintf("%s (%s)", str, field.Interface()) - } - } - - return strings.TrimSpace(fmt.Sprintf("%s %s", status, str)) -} diff --git a/samples/client/others/go/oneof-required/configuration.go b/samples/client/others/go/oneof-required/configuration.go deleted file mode 100644 index c3b676ba005..00000000000 --- a/samples/client/others/go/oneof-required/configuration.go +++ /dev/null @@ -1,215 +0,0 @@ -/* -Test - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 1.0.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package openapi - -import ( - "context" - "fmt" - "net/http" - "strings" -) - -// contextKeys are used to identify the type of value in the context. -// Since these are string, it is possible to get a short description of the -// context key for logging and debugging using key.String(). - -type contextKey string - -func (c contextKey) String() string { - return "auth " + string(c) -} - -var ( - // ContextServerIndex uses a server configuration from the index. - ContextServerIndex = contextKey("serverIndex") - - // ContextOperationServerIndices uses a server configuration from the index mapping. - ContextOperationServerIndices = contextKey("serverOperationIndices") - - // ContextServerVariables overrides a server configuration variables. - ContextServerVariables = contextKey("serverVariables") - - // ContextOperationServerVariables overrides a server configuration variables using operation specific values. - ContextOperationServerVariables = contextKey("serverOperationVariables") -) - -// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth -type BasicAuth struct { - UserName string `json:"userName,omitempty"` - Password string `json:"password,omitempty"` -} - -// APIKey provides API key based authentication to a request passed via context using ContextAPIKey -type APIKey struct { - Key string - Prefix string -} - -// ServerVariable stores the information about a server variable -type ServerVariable struct { - Description string - DefaultValue string - EnumValues []string -} - -// ServerConfiguration stores the information about a server -type ServerConfiguration struct { - URL string - Description string - Variables map[string]ServerVariable -} - -// ServerConfigurations stores multiple ServerConfiguration items -type ServerConfigurations []ServerConfiguration - -// Configuration stores the configuration of the API client -type Configuration struct { - Host string `json:"host,omitempty"` - Scheme string `json:"scheme,omitempty"` - DefaultHeader map[string]string `json:"defaultHeader,omitempty"` - UserAgent string `json:"userAgent,omitempty"` - Debug bool `json:"debug,omitempty"` - Servers ServerConfigurations - OperationServers map[string]ServerConfigurations - HTTPClient *http.Client -} - -// NewConfiguration returns a new Configuration object -func NewConfiguration() *Configuration { - cfg := &Configuration{ - DefaultHeader: make(map[string]string), - UserAgent: "OpenAPI-Generator/1.0.0/go", - Debug: false, - Servers: ServerConfigurations{ - { - URL: "", - Description: "No description provided", - }, - }, - OperationServers: map[string]ServerConfigurations{ - }, - } - return cfg -} - -// AddDefaultHeader adds a new HTTP header to the default header in the request -func (c *Configuration) AddDefaultHeader(key string, value string) { - c.DefaultHeader[key] = value -} - -// URL formats template on a index using given variables -func (sc ServerConfigurations) URL(index int, variables map[string]string) (string, error) { - if index < 0 || len(sc) <= index { - return "", fmt.Errorf("index %v out of range %v", index, len(sc)-1) - } - server := sc[index] - url := server.URL - - // go through variables and replace placeholders - for name, variable := range server.Variables { - if value, ok := variables[name]; ok { - found := bool(len(variable.EnumValues) == 0) - for _, enumValue := range variable.EnumValues { - if value == enumValue { - found = true - } - } - if !found { - return "", fmt.Errorf("the variable %s in the server URL has invalid value %v. Must be %v", name, value, variable.EnumValues) - } - url = strings.Replace(url, "{"+name+"}", value, -1) - } else { - url = strings.Replace(url, "{"+name+"}", variable.DefaultValue, -1) - } - } - return url, nil -} - -// ServerURL returns URL based on server settings -func (c *Configuration) ServerURL(index int, variables map[string]string) (string, error) { - return c.Servers.URL(index, variables) -} - -func getServerIndex(ctx context.Context) (int, error) { - si := ctx.Value(ContextServerIndex) - if si != nil { - if index, ok := si.(int); ok { - return index, nil - } - return 0, reportError("Invalid type %T should be int", si) - } - return 0, nil -} - -func getServerOperationIndex(ctx context.Context, endpoint string) (int, error) { - osi := ctx.Value(ContextOperationServerIndices) - if osi != nil { - if operationIndices, ok := osi.(map[string]int); !ok { - return 0, reportError("Invalid type %T should be map[string]int", osi) - } else { - index, ok := operationIndices[endpoint] - if ok { - return index, nil - } - } - } - return getServerIndex(ctx) -} - -func getServerVariables(ctx context.Context) (map[string]string, error) { - sv := ctx.Value(ContextServerVariables) - if sv != nil { - if variables, ok := sv.(map[string]string); ok { - return variables, nil - } - return nil, reportError("ctx value of ContextServerVariables has invalid type %T should be map[string]string", sv) - } - return nil, nil -} - -func getServerOperationVariables(ctx context.Context, endpoint string) (map[string]string, error) { - osv := ctx.Value(ContextOperationServerVariables) - if osv != nil { - if operationVariables, ok := osv.(map[string]map[string]string); !ok { - return nil, reportError("ctx value of ContextOperationServerVariables has invalid type %T should be map[string]map[string]string", osv) - } else { - variables, ok := operationVariables[endpoint] - if ok { - return variables, nil - } - } - } - return getServerVariables(ctx) -} - -// ServerURLWithContext returns a new server URL given an endpoint -func (c *Configuration) ServerURLWithContext(ctx context.Context, endpoint string) (string, error) { - sc, ok := c.OperationServers[endpoint] - if !ok { - sc = c.Servers - } - - if ctx == nil { - return sc.URL(0, nil) - } - - index, err := getServerOperationIndex(ctx, endpoint) - if err != nil { - return "", err - } - - variables, err := getServerOperationVariables(ctx, endpoint) - if err != nil { - return "", err - } - - return sc.URL(index, variables) -} diff --git a/samples/client/others/go/oneof-required/docs/NestedObject1.md b/samples/client/others/go/oneof-required/docs/NestedObject1.md deleted file mode 100644 index 769a34837fb..00000000000 --- a/samples/client/others/go/oneof-required/docs/NestedObject1.md +++ /dev/null @@ -1,51 +0,0 @@ -# NestedObject1 - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**Field1** | **string** | Specifies an action name to be used with the Android Intent class. | - -## Methods - -### NewNestedObject1 - -`func NewNestedObject1(field1 string, ) *NestedObject1` - -NewNestedObject1 instantiates a new NestedObject1 object -This constructor will assign default values to properties that have it defined, -and makes sure properties required by API are set, but the set of arguments -will change when the set of required properties is changed - -### NewNestedObject1WithDefaults - -`func NewNestedObject1WithDefaults() *NestedObject1` - -NewNestedObject1WithDefaults instantiates a new NestedObject1 object -This constructor will only assign default values to properties that have it defined, -but it doesn't guarantee that properties required by API are set - -### GetField1 - -`func (o *NestedObject1) GetField1() string` - -GetField1 returns the Field1 field if non-nil, zero value otherwise. - -### GetField1Ok - -`func (o *NestedObject1) GetField1Ok() (*string, bool)` - -GetField1Ok returns a tuple with the Field1 field if it's non-nil, zero value otherwise -and a boolean to check if the value has been set. - -### SetField1 - -`func (o *NestedObject1) SetField1(v string)` - -SetField1 sets Field1 field to given value. - - - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/samples/client/others/go/oneof-required/docs/NestedObject2.md b/samples/client/others/go/oneof-required/docs/NestedObject2.md deleted file mode 100644 index 98e1c865ed8..00000000000 --- a/samples/client/others/go/oneof-required/docs/NestedObject2.md +++ /dev/null @@ -1,51 +0,0 @@ -# NestedObject2 - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**Field2** | **string** | Specifies an action name to be used with the Android Intent class. | - -## Methods - -### NewNestedObject2 - -`func NewNestedObject2(field2 string, ) *NestedObject2` - -NewNestedObject2 instantiates a new NestedObject2 object -This constructor will assign default values to properties that have it defined, -and makes sure properties required by API are set, but the set of arguments -will change when the set of required properties is changed - -### NewNestedObject2WithDefaults - -`func NewNestedObject2WithDefaults() *NestedObject2` - -NewNestedObject2WithDefaults instantiates a new NestedObject2 object -This constructor will only assign default values to properties that have it defined, -but it doesn't guarantee that properties required by API are set - -### GetField2 - -`func (o *NestedObject2) GetField2() string` - -GetField2 returns the Field2 field if non-nil, zero value otherwise. - -### GetField2Ok - -`func (o *NestedObject2) GetField2Ok() (*string, bool)` - -GetField2Ok returns a tuple with the Field2 field if it's non-nil, zero value otherwise -and a boolean to check if the value has been set. - -### SetField2 - -`func (o *NestedObject2) SetField2(v string)` - -SetField2 sets Field2 field to given value. - - - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/samples/client/others/go/oneof-required/docs/Object.md b/samples/client/others/go/oneof-required/docs/Object.md deleted file mode 100644 index 28dd77444cf..00000000000 --- a/samples/client/others/go/oneof-required/docs/Object.md +++ /dev/null @@ -1,72 +0,0 @@ -# Object - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**Field1** | **string** | Specifies an action name to be used with the Android Intent class. | -**Field2** | **string** | Specifies an action name to be used with the Android Intent class. | - -## Methods - -### NewObject - -`func NewObject(field1 string, field2 string, ) *Object` - -NewObject instantiates a new Object object -This constructor will assign default values to properties that have it defined, -and makes sure properties required by API are set, but the set of arguments -will change when the set of required properties is changed - -### NewObjectWithDefaults - -`func NewObjectWithDefaults() *Object` - -NewObjectWithDefaults instantiates a new Object object -This constructor will only assign default values to properties that have it defined, -but it doesn't guarantee that properties required by API are set - -### GetField1 - -`func (o *Object) GetField1() string` - -GetField1 returns the Field1 field if non-nil, zero value otherwise. - -### GetField1Ok - -`func (o *Object) GetField1Ok() (*string, bool)` - -GetField1Ok returns a tuple with the Field1 field if it's non-nil, zero value otherwise -and a boolean to check if the value has been set. - -### SetField1 - -`func (o *Object) SetField1(v string)` - -SetField1 sets Field1 field to given value. - - -### GetField2 - -`func (o *Object) GetField2() string` - -GetField2 returns the Field2 field if non-nil, zero value otherwise. - -### GetField2Ok - -`func (o *Object) GetField2Ok() (*string, bool)` - -GetField2Ok returns a tuple with the Field2 field if it's non-nil, zero value otherwise -and a boolean to check if the value has been set. - -### SetField2 - -`func (o *Object) SetField2(v string)` - -SetField2 sets Field2 field to given value. - - - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/samples/client/others/go/oneof-required/docs/Object2.md b/samples/client/others/go/oneof-required/docs/Object2.md deleted file mode 100644 index b9c9aee6728..00000000000 --- a/samples/client/others/go/oneof-required/docs/Object2.md +++ /dev/null @@ -1,72 +0,0 @@ -# Object2 - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**Field1** | **string** | Specifies an action name to be used with the Android Intent class. | -**Field2** | **string** | Specifies an action name to be used with the Android Intent class. | - -## Methods - -### NewObject2 - -`func NewObject2(field1 string, field2 string, ) *Object2` - -NewObject2 instantiates a new Object2 object -This constructor will assign default values to properties that have it defined, -and makes sure properties required by API are set, but the set of arguments -will change when the set of required properties is changed - -### NewObject2WithDefaults - -`func NewObject2WithDefaults() *Object2` - -NewObject2WithDefaults instantiates a new Object2 object -This constructor will only assign default values to properties that have it defined, -but it doesn't guarantee that properties required by API are set - -### GetField1 - -`func (o *Object2) GetField1() string` - -GetField1 returns the Field1 field if non-nil, zero value otherwise. - -### GetField1Ok - -`func (o *Object2) GetField1Ok() (*string, bool)` - -GetField1Ok returns a tuple with the Field1 field if it's non-nil, zero value otherwise -and a boolean to check if the value has been set. - -### SetField1 - -`func (o *Object2) SetField1(v string)` - -SetField1 sets Field1 field to given value. - - -### GetField2 - -`func (o *Object2) GetField2() string` - -GetField2 returns the Field2 field if non-nil, zero value otherwise. - -### GetField2Ok - -`func (o *Object2) GetField2Ok() (*string, bool)` - -GetField2Ok returns a tuple with the Field2 field if it's non-nil, zero value otherwise -and a boolean to check if the value has been set. - -### SetField2 - -`func (o *Object2) SetField2(v string)` - -SetField2 sets Field2 field to given value. - - - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/samples/client/others/go/oneof-required/docs/Object3.md b/samples/client/others/go/oneof-required/docs/Object3.md deleted file mode 100644 index 0a27fe17278..00000000000 --- a/samples/client/others/go/oneof-required/docs/Object3.md +++ /dev/null @@ -1,72 +0,0 @@ -# Object3 - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**Field1** | **string** | Specifies an action name to be used with the Android Intent class. | -**Field2** | **string** | Specifies an action name to be used with the Android Intent class. | - -## Methods - -### NewObject3 - -`func NewObject3(field1 string, field2 string, ) *Object3` - -NewObject3 instantiates a new Object3 object -This constructor will assign default values to properties that have it defined, -and makes sure properties required by API are set, but the set of arguments -will change when the set of required properties is changed - -### NewObject3WithDefaults - -`func NewObject3WithDefaults() *Object3` - -NewObject3WithDefaults instantiates a new Object3 object -This constructor will only assign default values to properties that have it defined, -but it doesn't guarantee that properties required by API are set - -### GetField1 - -`func (o *Object3) GetField1() string` - -GetField1 returns the Field1 field if non-nil, zero value otherwise. - -### GetField1Ok - -`func (o *Object3) GetField1Ok() (*string, bool)` - -GetField1Ok returns a tuple with the Field1 field if it's non-nil, zero value otherwise -and a boolean to check if the value has been set. - -### SetField1 - -`func (o *Object3) SetField1(v string)` - -SetField1 sets Field1 field to given value. - - -### GetField2 - -`func (o *Object3) GetField2() string` - -GetField2 returns the Field2 field if non-nil, zero value otherwise. - -### GetField2Ok - -`func (o *Object3) GetField2Ok() (*string, bool)` - -GetField2Ok returns a tuple with the Field2 field if it's non-nil, zero value otherwise -and a boolean to check if the value has been set. - -### SetField2 - -`func (o *Object3) SetField2(v string)` - -SetField2 sets Field2 field to given value. - - - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/samples/client/others/go/oneof-required/git_push.sh b/samples/client/others/go/oneof-required/git_push.sh deleted file mode 100644 index f53a75d4fab..00000000000 --- a/samples/client/others/go/oneof-required/git_push.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/sh -# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ -# -# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" - -git_user_id=$1 -git_repo_id=$2 -release_note=$3 -git_host=$4 - -if [ "$git_host" = "" ]; then - git_host="github.com" - echo "[INFO] No command line input provided. Set \$git_host to $git_host" -fi - -if [ "$git_user_id" = "" ]; then - git_user_id="GIT_USER_ID" - echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" -fi - -if [ "$git_repo_id" = "" ]; then - git_repo_id="GIT_REPO_ID" - echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" -fi - -if [ "$release_note" = "" ]; then - release_note="Minor update" - echo "[INFO] No command line input provided. Set \$release_note to $release_note" -fi - -# Initialize the local directory as a Git repository -git init - -# Adds the files in the local repository and stages them for commit. -git add . - -# Commits the tracked changes and prepares them to be pushed to a remote repository. -git commit -m "$release_note" - -# Sets the new remote -git_remote=$(git remote) -if [ "$git_remote" = "" ]; then # git remote not defined - - if [ "$GIT_TOKEN" = "" ]; then - echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." - git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git - else - git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git - fi - -fi - -git pull origin master - -# Pushes (Forces) the changes in the local repository up to the remote repository -echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" -git push origin master 2>&1 | grep -v 'To https' diff --git a/samples/client/others/go/oneof-required/go.mod b/samples/client/others/go/oneof-required/go.mod deleted file mode 100644 index 7fca7eee925..00000000000 --- a/samples/client/others/go/oneof-required/go.mod +++ /dev/null @@ -1,6 +0,0 @@ -module github.com/GIT_USER_ID/GIT_REPO_ID - -go 1.18 - -require ( -) diff --git a/samples/client/others/go/oneof-required/go.sum b/samples/client/others/go/oneof-required/go.sum deleted file mode 100644 index c966c8ddfd0..00000000000 --- a/samples/client/others/go/oneof-required/go.sum +++ /dev/null @@ -1,11 +0,0 @@ -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= diff --git a/samples/client/others/go/oneof-required/model_nested_object1.go b/samples/client/others/go/oneof-required/model_nested_object1.go deleted file mode 100644 index f403748a896..00000000000 --- a/samples/client/others/go/oneof-required/model_nested_object1.go +++ /dev/null @@ -1,159 +0,0 @@ -/* -Test - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 1.0.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package openapi - -import ( - "encoding/json" - "bytes" - "fmt" -) - -// checks if the NestedObject1 type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &NestedObject1{} - -// NestedObject1 struct for NestedObject1 -type NestedObject1 struct { - // Specifies an action name to be used with the Android Intent class. - Field1 string `json:"field1"` -} - -type _NestedObject1 NestedObject1 - -// NewNestedObject1 instantiates a new NestedObject1 object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewNestedObject1(field1 string) *NestedObject1 { - this := NestedObject1{} - this.Field1 = field1 - return &this -} - -// NewNestedObject1WithDefaults instantiates a new NestedObject1 object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewNestedObject1WithDefaults() *NestedObject1 { - this := NestedObject1{} - return &this -} - -// GetField1 returns the Field1 field value -func (o *NestedObject1) GetField1() string { - if o == nil { - var ret string - return ret - } - - return o.Field1 -} - -// GetField1Ok returns a tuple with the Field1 field value -// and a boolean to check if the value has been set. -func (o *NestedObject1) GetField1Ok() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Field1, true -} - -// SetField1 sets field value -func (o *NestedObject1) SetField1(v string) { - o.Field1 = v -} - -func (o NestedObject1) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o NestedObject1) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["field1"] = o.Field1 - return toSerialize, nil -} - -func (o *NestedObject1) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "field1", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varNestedObject1 := _NestedObject1{} - - decoder := json.NewDecoder(bytes.NewReader(data)) - decoder.DisallowUnknownFields() - err = decoder.Decode(&varNestedObject1) - - if err != nil { - return err - } - - *o = NestedObject1(varNestedObject1) - - return err -} - -type NullableNestedObject1 struct { - value *NestedObject1 - isSet bool -} - -func (v NullableNestedObject1) Get() *NestedObject1 { - return v.value -} - -func (v *NullableNestedObject1) Set(val *NestedObject1) { - v.value = val - v.isSet = true -} - -func (v NullableNestedObject1) IsSet() bool { - return v.isSet -} - -func (v *NullableNestedObject1) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableNestedObject1(val *NestedObject1) *NullableNestedObject1 { - return &NullableNestedObject1{value: val, isSet: true} -} - -func (v NullableNestedObject1) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableNestedObject1) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/samples/client/others/go/oneof-required/model_nested_object2.go b/samples/client/others/go/oneof-required/model_nested_object2.go deleted file mode 100644 index c3f9468bc15..00000000000 --- a/samples/client/others/go/oneof-required/model_nested_object2.go +++ /dev/null @@ -1,159 +0,0 @@ -/* -Test - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 1.0.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package openapi - -import ( - "encoding/json" - "bytes" - "fmt" -) - -// checks if the NestedObject2 type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &NestedObject2{} - -// NestedObject2 struct for NestedObject2 -type NestedObject2 struct { - // Specifies an action name to be used with the Android Intent class. - Field2 string `json:"field2"` -} - -type _NestedObject2 NestedObject2 - -// NewNestedObject2 instantiates a new NestedObject2 object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewNestedObject2(field2 string) *NestedObject2 { - this := NestedObject2{} - this.Field2 = field2 - return &this -} - -// NewNestedObject2WithDefaults instantiates a new NestedObject2 object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewNestedObject2WithDefaults() *NestedObject2 { - this := NestedObject2{} - return &this -} - -// GetField2 returns the Field2 field value -func (o *NestedObject2) GetField2() string { - if o == nil { - var ret string - return ret - } - - return o.Field2 -} - -// GetField2Ok returns a tuple with the Field2 field value -// and a boolean to check if the value has been set. -func (o *NestedObject2) GetField2Ok() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Field2, true -} - -// SetField2 sets field value -func (o *NestedObject2) SetField2(v string) { - o.Field2 = v -} - -func (o NestedObject2) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o NestedObject2) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["field2"] = o.Field2 - return toSerialize, nil -} - -func (o *NestedObject2) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "field2", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varNestedObject2 := _NestedObject2{} - - decoder := json.NewDecoder(bytes.NewReader(data)) - decoder.DisallowUnknownFields() - err = decoder.Decode(&varNestedObject2) - - if err != nil { - return err - } - - *o = NestedObject2(varNestedObject2) - - return err -} - -type NullableNestedObject2 struct { - value *NestedObject2 - isSet bool -} - -func (v NullableNestedObject2) Get() *NestedObject2 { - return v.value -} - -func (v *NullableNestedObject2) Set(val *NestedObject2) { - v.value = val - v.isSet = true -} - -func (v NullableNestedObject2) IsSet() bool { - return v.isSet -} - -func (v *NullableNestedObject2) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableNestedObject2(val *NestedObject2) *NullableNestedObject2 { - return &NullableNestedObject2{value: val, isSet: true} -} - -func (v NullableNestedObject2) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableNestedObject2) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/samples/client/others/go/oneof-required/model_object.go b/samples/client/others/go/oneof-required/model_object.go deleted file mode 100644 index d12d700666f..00000000000 --- a/samples/client/others/go/oneof-required/model_object.go +++ /dev/null @@ -1,149 +0,0 @@ -/* -Test - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 1.0.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package openapi - -import ( - "encoding/json" - "fmt" - "bytes" -) - -// Object - struct for Object -type Object struct { - NestedObject1 *NestedObject1 - NestedObject2 *NestedObject2 -} - -// NestedObject1AsObject is a convenience function that returns NestedObject1 wrapped in Object -func NestedObject1AsObject(v *NestedObject1) Object { - return Object{ - NestedObject1: v, - } -} - -// NestedObject2AsObject is a convenience function that returns NestedObject2 wrapped in Object -func NestedObject2AsObject(v *NestedObject2) Object { - return Object{ - NestedObject2: v, - } -} - - -// Unmarshal JSON data into one of the pointers in the struct -func (dst *Object) UnmarshalJSON(data []byte) error { - var err error - match := 0 - // try to unmarshal data into NestedObject1 - err = newStrictDecoder(data).Decode(&dst.NestedObject1) - if err == nil { - jsonNestedObject1, _ := json.Marshal(dst.NestedObject1) - if string(jsonNestedObject1) == "{}" { // empty struct - dst.NestedObject1 = nil - } else { - match++ - } - } else { - dst.NestedObject1 = nil - } - - // try to unmarshal data into NestedObject2 - err = newStrictDecoder(data).Decode(&dst.NestedObject2) - if err == nil { - jsonNestedObject2, _ := json.Marshal(dst.NestedObject2) - if string(jsonNestedObject2) == "{}" { // empty struct - dst.NestedObject2 = nil - } else { - match++ - } - } else { - dst.NestedObject2 = nil - } - - if match > 1 { // more than 1 match - // reset to nil - dst.NestedObject1 = nil - dst.NestedObject2 = nil - - return fmt.Errorf("data matches more than one schema in oneOf(Object)") - } else if match == 1 { - return nil // exactly one match - } else { // no match - return fmt.Errorf("data failed to match schemas in oneOf(Object)") - } -} - -// Marshal data from the first non-nil pointers in the struct to JSON -func (src Object) MarshalJSON() ([]byte, error) { - if src.NestedObject1 != nil { - return json.Marshal(&src.NestedObject1) - } - - if src.NestedObject2 != nil { - return json.Marshal(&src.NestedObject2) - } - - return nil, nil // no data in oneOf schemas -} - -// Get the actual instance -func (obj *Object) GetActualInstance() (interface{}) { - if obj == nil { - return nil - } - if obj.NestedObject1 != nil { - return obj.NestedObject1 - } - - if obj.NestedObject2 != nil { - return obj.NestedObject2 - } - - // all schemas are nil - return nil -} - -type NullableObject struct { - value *Object - isSet bool -} - -func (v NullableObject) Get() *Object { - return v.value -} - -func (v *NullableObject) Set(val *Object) { - v.value = val - v.isSet = true -} - -func (v NullableObject) IsSet() bool { - return v.isSet -} - -func (v *NullableObject) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableObject(val *Object) *NullableObject { - return &NullableObject{value: val, isSet: true} -} - -func (v NullableObject) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableObject) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/samples/client/others/go/oneof-required/model_object2.go b/samples/client/others/go/oneof-required/model_object2.go deleted file mode 100644 index 02b2e1cada6..00000000000 --- a/samples/client/others/go/oneof-required/model_object2.go +++ /dev/null @@ -1,106 +0,0 @@ -/* -Test - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 1.0.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package openapi - -import ( - "encoding/json" - "fmt" - "bytes" -) - -// Object2 struct for Object2 -type Object2 struct { - NestedObject1 *NestedObject1 - NestedObject2 *NestedObject2 -} - -// Unmarshal JSON data into any of the pointers in the struct -func (dst *Object2) UnmarshalJSON(data []byte) error { - var err error - // try to unmarshal JSON data into NestedObject1 - err = json.Unmarshal(data, &dst.NestedObject1); - if err == nil { - jsonNestedObject1, _ := json.Marshal(dst.NestedObject1) - if string(jsonNestedObject1) == "{}" { // empty struct - dst.NestedObject1 = nil - } else { - return nil // data stored in dst.NestedObject1, return on the first match - } - } else { - dst.NestedObject1 = nil - } - - // try to unmarshal JSON data into NestedObject2 - err = json.Unmarshal(data, &dst.NestedObject2); - if err == nil { - jsonNestedObject2, _ := json.Marshal(dst.NestedObject2) - if string(jsonNestedObject2) == "{}" { // empty struct - dst.NestedObject2 = nil - } else { - return nil // data stored in dst.NestedObject2, return on the first match - } - } else { - dst.NestedObject2 = nil - } - - return fmt.Errorf("data failed to match schemas in anyOf(Object2)") -} - -// Marshal data from the first non-nil pointers in the struct to JSON -func (src *Object2) MarshalJSON() ([]byte, error) { - if src.NestedObject1 != nil { - return json.Marshal(&src.NestedObject1) - } - - if src.NestedObject2 != nil { - return json.Marshal(&src.NestedObject2) - } - - return nil, nil // no data in anyOf schemas -} - -type NullableObject2 struct { - value *Object2 - isSet bool -} - -func (v NullableObject2) Get() *Object2 { - return v.value -} - -func (v *NullableObject2) Set(val *Object2) { - v.value = val - v.isSet = true -} - -func (v NullableObject2) IsSet() bool { - return v.isSet -} - -func (v *NullableObject2) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableObject2(val *Object2) *NullableObject2 { - return &NullableObject2{value: val, isSet: true} -} - -func (v NullableObject2) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableObject2) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/samples/client/others/go/oneof-required/model_object3.go b/samples/client/others/go/oneof-required/model_object3.go deleted file mode 100644 index 2ce8d712e69..00000000000 --- a/samples/client/others/go/oneof-required/model_object3.go +++ /dev/null @@ -1,188 +0,0 @@ -/* -Test - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 1.0.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package openapi - -import ( - "encoding/json" - "bytes" - "fmt" -) - -// checks if the Object3 type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &Object3{} - -// Object3 struct for Object3 -type Object3 struct { - // Specifies an action name to be used with the Android Intent class. - Field1 string `json:"field1"` - // Specifies an action name to be used with the Android Intent class. - Field2 string `json:"field2"` -} - -type _Object3 Object3 - -// NewObject3 instantiates a new Object3 object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewObject3(field1 string, field2 string) *Object3 { - this := Object3{} - this.Field1 = field1 - this.Field2 = field2 - return &this -} - -// NewObject3WithDefaults instantiates a new Object3 object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewObject3WithDefaults() *Object3 { - this := Object3{} - return &this -} - -// GetField1 returns the Field1 field value -func (o *Object3) GetField1() string { - if o == nil { - var ret string - return ret - } - - return o.Field1 -} - -// GetField1Ok returns a tuple with the Field1 field value -// and a boolean to check if the value has been set. -func (o *Object3) GetField1Ok() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Field1, true -} - -// SetField1 sets field value -func (o *Object3) SetField1(v string) { - o.Field1 = v -} - -// GetField2 returns the Field2 field value -func (o *Object3) GetField2() string { - if o == nil { - var ret string - return ret - } - - return o.Field2 -} - -// GetField2Ok returns a tuple with the Field2 field value -// and a boolean to check if the value has been set. -func (o *Object3) GetField2Ok() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Field2, true -} - -// SetField2 sets field value -func (o *Object3) SetField2(v string) { - o.Field2 = v -} - -func (o Object3) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o Object3) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["field1"] = o.Field1 - toSerialize["field2"] = o.Field2 - return toSerialize, nil -} - -func (o *Object3) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "field1", - "field2", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varObject3 := _Object3{} - - decoder := json.NewDecoder(bytes.NewReader(data)) - decoder.DisallowUnknownFields() - err = decoder.Decode(&varObject3) - - if err != nil { - return err - } - - *o = Object3(varObject3) - - return err -} - -type NullableObject3 struct { - value *Object3 - isSet bool -} - -func (v NullableObject3) Get() *Object3 { - return v.value -} - -func (v *NullableObject3) Set(val *Object3) { - v.value = val - v.isSet = true -} - -func (v NullableObject3) IsSet() bool { - return v.isSet -} - -func (v *NullableObject3) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableObject3(val *Object3) *NullableObject3 { - return &NullableObject3{value: val, isSet: true} -} - -func (v NullableObject3) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableObject3) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/samples/client/others/go/oneof-required/response.go b/samples/client/others/go/oneof-required/response.go deleted file mode 100644 index 7498f33f6fc..00000000000 --- a/samples/client/others/go/oneof-required/response.go +++ /dev/null @@ -1,47 +0,0 @@ -/* -Test - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 1.0.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package openapi - -import ( - "net/http" -) - -// APIResponse stores the API response returned by the server. -type APIResponse struct { - *http.Response `json:"-"` - Message string `json:"message,omitempty"` - // Operation is the name of the OpenAPI operation. - Operation string `json:"operation,omitempty"` - // RequestURL is the request URL. This value is always available, even if the - // embedded *http.Response is nil. - RequestURL string `json:"url,omitempty"` - // Method is the HTTP method used for the request. This value is always - // available, even if the embedded *http.Response is nil. - Method string `json:"method,omitempty"` - // Payload holds the contents of the response body (which may be nil or empty). - // This is provided here as the raw response.Body() reader will have already - // been drained. - Payload []byte `json:"-"` -} - -// NewAPIResponse returns a new APIResponse object. -func NewAPIResponse(r *http.Response) *APIResponse { - - response := &APIResponse{Response: r} - return response -} - -// NewAPIResponseWithError returns a new APIResponse object with the provided error message. -func NewAPIResponseWithError(errorMessage string) *APIResponse { - - response := &APIResponse{Message: errorMessage} - return response -} diff --git a/samples/client/others/go/oneof-required/utils.go b/samples/client/others/go/oneof-required/utils.go deleted file mode 100644 index 4b6303690a5..00000000000 --- a/samples/client/others/go/oneof-required/utils.go +++ /dev/null @@ -1,347 +0,0 @@ -/* -Test - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 1.0.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package openapi - -import ( - "encoding/json" - "reflect" - "time" -) - -// PtrBool is a helper routine that returns a pointer to given boolean value. -func PtrBool(v bool) *bool { return &v } - -// PtrInt is a helper routine that returns a pointer to given integer value. -func PtrInt(v int) *int { return &v } - -// PtrInt32 is a helper routine that returns a pointer to given integer value. -func PtrInt32(v int32) *int32 { return &v } - -// PtrInt64 is a helper routine that returns a pointer to given integer value. -func PtrInt64(v int64) *int64 { return &v } - -// PtrFloat32 is a helper routine that returns a pointer to given float value. -func PtrFloat32(v float32) *float32 { return &v } - -// PtrFloat64 is a helper routine that returns a pointer to given float value. -func PtrFloat64(v float64) *float64 { return &v } - -// PtrString is a helper routine that returns a pointer to given string value. -func PtrString(v string) *string { return &v } - -// PtrTime is helper routine that returns a pointer to given Time value. -func PtrTime(v time.Time) *time.Time { return &v } - -type NullableBool struct { - value *bool - isSet bool -} - -func (v NullableBool) Get() *bool { - return v.value -} - -func (v *NullableBool) Set(val *bool) { - v.value = val - v.isSet = true -} - -func (v NullableBool) IsSet() bool { - return v.isSet -} - -func (v *NullableBool) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableBool(val *bool) *NullableBool { - return &NullableBool{value: val, isSet: true} -} - -func (v NullableBool) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableBool) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - -type NullableInt struct { - value *int - isSet bool -} - -func (v NullableInt) Get() *int { - return v.value -} - -func (v *NullableInt) Set(val *int) { - v.value = val - v.isSet = true -} - -func (v NullableInt) IsSet() bool { - return v.isSet -} - -func (v *NullableInt) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableInt(val *int) *NullableInt { - return &NullableInt{value: val, isSet: true} -} - -func (v NullableInt) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableInt) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - -type NullableInt32 struct { - value *int32 - isSet bool -} - -func (v NullableInt32) Get() *int32 { - return v.value -} - -func (v *NullableInt32) Set(val *int32) { - v.value = val - v.isSet = true -} - -func (v NullableInt32) IsSet() bool { - return v.isSet -} - -func (v *NullableInt32) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableInt32(val *int32) *NullableInt32 { - return &NullableInt32{value: val, isSet: true} -} - -func (v NullableInt32) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableInt32) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - -type NullableInt64 struct { - value *int64 - isSet bool -} - -func (v NullableInt64) Get() *int64 { - return v.value -} - -func (v *NullableInt64) Set(val *int64) { - v.value = val - v.isSet = true -} - -func (v NullableInt64) IsSet() bool { - return v.isSet -} - -func (v *NullableInt64) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableInt64(val *int64) *NullableInt64 { - return &NullableInt64{value: val, isSet: true} -} - -func (v NullableInt64) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableInt64) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - -type NullableFloat32 struct { - value *float32 - isSet bool -} - -func (v NullableFloat32) Get() *float32 { - return v.value -} - -func (v *NullableFloat32) Set(val *float32) { - v.value = val - v.isSet = true -} - -func (v NullableFloat32) IsSet() bool { - return v.isSet -} - -func (v *NullableFloat32) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableFloat32(val *float32) *NullableFloat32 { - return &NullableFloat32{value: val, isSet: true} -} - -func (v NullableFloat32) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableFloat32) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - -type NullableFloat64 struct { - value *float64 - isSet bool -} - -func (v NullableFloat64) Get() *float64 { - return v.value -} - -func (v *NullableFloat64) Set(val *float64) { - v.value = val - v.isSet = true -} - -func (v NullableFloat64) IsSet() bool { - return v.isSet -} - -func (v *NullableFloat64) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableFloat64(val *float64) *NullableFloat64 { - return &NullableFloat64{value: val, isSet: true} -} - -func (v NullableFloat64) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableFloat64) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - -type NullableString struct { - value *string - isSet bool -} - -func (v NullableString) Get() *string { - return v.value -} - -func (v *NullableString) Set(val *string) { - v.value = val - v.isSet = true -} - -func (v NullableString) IsSet() bool { - return v.isSet -} - -func (v *NullableString) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableString(val *string) *NullableString { - return &NullableString{value: val, isSet: true} -} - -func (v NullableString) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableString) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - -type NullableTime struct { - value *time.Time - isSet bool -} - -func (v NullableTime) Get() *time.Time { - return v.value -} - -func (v *NullableTime) Set(val *time.Time) { - v.value = val - v.isSet = true -} - -func (v NullableTime) IsSet() bool { - return v.isSet -} - -func (v *NullableTime) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableTime(val *time.Time) *NullableTime { - return &NullableTime{value: val, isSet: true} -} - -func (v NullableTime) MarshalJSON() ([]byte, error) { - return v.value.MarshalJSON() -} - -func (v *NullableTime) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - -// IsNil checks if an input is nil -func IsNil(i interface{}) bool { - if i == nil { - return true - } - switch reflect.TypeOf(i).Kind() { - case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.UnsafePointer, reflect.Interface, reflect.Slice: - return reflect.ValueOf(i).IsNil() - case reflect.Array: - return reflect.ValueOf(i).IsZero() - } - return false -} - -type MappedNullable interface { - ToMap() (map[string]interface{}, error) -} diff --git a/samples/client/petstore/go/go-petstore/README.md b/samples/client/petstore/go/go-petstore/README.md index 58a8b363329..938c5a517bd 100644 --- a/samples/client/petstore/go/go-petstore/README.md +++ b/samples/client/petstore/go/go-petstore/README.md @@ -75,7 +75,7 @@ ctx = context.WithValue(context.Background(), petstore.ContextOperationServerVar ## Documentation for API Endpoints -All URIs are relative to *http://petstore.swagger.io:80/v2* +All URIs are relative to *http://localhost/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- @@ -176,7 +176,7 @@ Authentication schemes defined for the API: - **Type**: OAuth - **Flow**: implicit -- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog +- **Authorization URL**: http://localhost/api/oauth/dialog - **Scopes**: - **write:pets**: modify pets in your account - **read:pets**: read your pets diff --git a/samples/client/petstore/go/go-petstore/api/openapi.yaml b/samples/client/petstore/go/go-petstore/api/openapi.yaml index 55bdb39966d..0e71a56691e 100644 --- a/samples/client/petstore/go/go-petstore/api/openapi.yaml +++ b/samples/client/petstore/go/go-petstore/api/openapi.yaml @@ -9,7 +9,7 @@ info: title: OpenAPI Petstore version: 1.0.0 servers: -- url: http://petstore.swagger.io:80/v2 +- url: http://localhost/v2 tags: - description: Everything about your Pets name: pet @@ -2130,7 +2130,7 @@ components: petstore_auth: flows: implicit: - authorizationUrl: http://petstore.swagger.io/api/oauth/dialog + authorizationUrl: http://localhost/api/oauth/dialog scopes: write:pets: modify pets in your account read:pets: read your pets diff --git a/samples/client/petstore/go/go-petstore/configuration.go b/samples/client/petstore/go/go-petstore/configuration.go index ad220e607f4..a8803645bb9 100644 --- a/samples/client/petstore/go/go-petstore/configuration.go +++ b/samples/client/petstore/go/go-petstore/configuration.go @@ -99,7 +99,7 @@ func NewConfiguration() *Configuration { Debug: false, Servers: ServerConfigurations{ { - URL: "http://petstore.swagger.io:80/v2", + URL: "http://localhost/v2", Description: "No description provided", }, }, diff --git a/samples/client/petstore/go/go-petstore/docs/AnotherFakeAPI.md b/samples/client/petstore/go/go-petstore/docs/AnotherFakeAPI.md index 87709d90591..4a09b5f09d6 100644 --- a/samples/client/petstore/go/go-petstore/docs/AnotherFakeAPI.md +++ b/samples/client/petstore/go/go-petstore/docs/AnotherFakeAPI.md @@ -1,6 +1,6 @@ # \AnotherFakeAPI -All URIs are relative to *http://petstore.swagger.io:80/v2* +All URIs are relative to *http://localhost/v2* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/samples/client/petstore/go/go-petstore/docs/FakeAPI.md b/samples/client/petstore/go/go-petstore/docs/FakeAPI.md index 34a895493c6..a64980f5897 100644 --- a/samples/client/petstore/go/go-petstore/docs/FakeAPI.md +++ b/samples/client/petstore/go/go-petstore/docs/FakeAPI.md @@ -1,6 +1,6 @@ # \FakeAPI -All URIs are relative to *http://petstore.swagger.io:80/v2* +All URIs are relative to *http://localhost/v2* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/samples/client/petstore/go/go-petstore/docs/FakeClassnameTags123API.md b/samples/client/petstore/go/go-petstore/docs/FakeClassnameTags123API.md index 340a5751ba3..b0b8d3fe3ec 100644 --- a/samples/client/petstore/go/go-petstore/docs/FakeClassnameTags123API.md +++ b/samples/client/petstore/go/go-petstore/docs/FakeClassnameTags123API.md @@ -1,6 +1,6 @@ # \FakeClassnameTags123API -All URIs are relative to *http://petstore.swagger.io:80/v2* +All URIs are relative to *http://localhost/v2* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/samples/client/petstore/go/go-petstore/docs/PetAPI.md b/samples/client/petstore/go/go-petstore/docs/PetAPI.md index adaec60d055..a6e1da3a277 100644 --- a/samples/client/petstore/go/go-petstore/docs/PetAPI.md +++ b/samples/client/petstore/go/go-petstore/docs/PetAPI.md @@ -1,6 +1,6 @@ # \PetAPI -All URIs are relative to *http://petstore.swagger.io:80/v2* +All URIs are relative to *http://localhost/v2* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/samples/client/petstore/go/go-petstore/docs/StoreAPI.md b/samples/client/petstore/go/go-petstore/docs/StoreAPI.md index e78d6a9db37..3cbeb225ae7 100644 --- a/samples/client/petstore/go/go-petstore/docs/StoreAPI.md +++ b/samples/client/petstore/go/go-petstore/docs/StoreAPI.md @@ -1,6 +1,6 @@ # \StoreAPI -All URIs are relative to *http://petstore.swagger.io:80/v2* +All URIs are relative to *http://localhost/v2* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/samples/client/petstore/go/go-petstore/docs/UserAPI.md b/samples/client/petstore/go/go-petstore/docs/UserAPI.md index 480ea53a65a..f1cbc79a916 100644 --- a/samples/client/petstore/go/go-petstore/docs/UserAPI.md +++ b/samples/client/petstore/go/go-petstore/docs/UserAPI.md @@ -1,6 +1,6 @@ # \UserAPI -All URIs are relative to *http://petstore.swagger.io:80/v2* +All URIs are relative to *http://localhost/v2* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/samples/client/petstore/go/pet_api_test.go b/samples/client/petstore/go/pet_api_test.go index 7b77809939c..450220d8281 100644 --- a/samples/client/petstore/go/pet_api_test.go +++ b/samples/client/petstore/go/pet_api_test.go @@ -14,7 +14,7 @@ import ( var client *sw.APIClient -const testHost = "petstore.swagger.io:80" +const testHost = "localhost" const testScheme = "http" func TestMain(m *testing.M) { diff --git a/samples/openapi3/client/petstore/go/go-petstore-aws-signature/.openapi-generator-ignore b/samples/openapi3/client/petstore/go/go-petstore-aws-signature/.openapi-generator-ignore index 7484ee590a3..c5b04829c20 100644 --- a/samples/openapi3/client/petstore/go/go-petstore-aws-signature/.openapi-generator-ignore +++ b/samples/openapi3/client/petstore/go/go-petstore-aws-signature/.openapi-generator-ignore @@ -21,3 +21,6 @@ #docs/*.md # Then explicitly reverse the ignore rule for a single file: #!docs/README.md +# +# +# diff --git a/samples/openapi3/client/petstore/go/go-petstore/.openapi-generator-ignore b/samples/openapi3/client/petstore/go/go-petstore/.openapi-generator-ignore index 7484ee590a3..82e4e79984b 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/.openapi-generator-ignore +++ b/samples/openapi3/client/petstore/go/go-petstore/.openapi-generator-ignore @@ -21,3 +21,5 @@ #docs/*.md # Then explicitly reverse the ignore rule for a single file: #!docs/README.md +# +# diff --git a/samples/openapi3/client/petstore/go/go-petstore/README.md b/samples/openapi3/client/petstore/go/go-petstore/README.md index 6a7b01c678b..292437faeeb 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/README.md +++ b/samples/openapi3/client/petstore/go/go-petstore/README.md @@ -75,7 +75,7 @@ ctx = context.WithValue(context.Background(), petstore.ContextOperationServerVar ## Documentation for API Endpoints -All URIs are relative to *http://petstore.swagger.io:80/v2* +All URIs are relative to *http://localhost/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- @@ -214,7 +214,7 @@ Authentication schemes defined for the API: - **Type**: OAuth - **Flow**: implicit -- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog +- **Authorization URL**: http://localhost/api/oauth/dialog - **Scopes**: - **write:pets**: modify pets in your account - **read:pets**: read your pets diff --git a/samples/openapi3/client/petstore/go/go-petstore/api/openapi.yaml b/samples/openapi3/client/petstore/go/go-petstore/api/openapi.yaml index 5fff70d93fd..c07c000f2c0 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/api/openapi.yaml +++ b/samples/openapi3/client/petstore/go/go-petstore/api/openapi.yaml @@ -9,6 +9,7 @@ info: title: OpenAPI Petstore version: 1.0.0 servers: +- url: http://localhost/v2 - description: petstore server url: "http://{server}.swagger.io:{port}/v2" variables: @@ -24,7 +25,7 @@ servers: - "80" - "8080" - description: The local server - url: "https://localhost:8080/{version}" + url: "http://localhost:8080/{version}" variables: version: default: v2 @@ -32,7 +33,7 @@ servers: - v1 - v2 - description: The local server without variables - url: https://127.0.0.1/no_variable + url: http://127.0.0.1/no_variable tags: - description: Everything about your Pets name: pet @@ -100,6 +101,7 @@ paths: tags: - pet servers: + - url: http://localhost/v2 - url: http://petstore.swagger.io/v2 - url: http://path-server-test.petstore.local/v2 /pet/findByStatus: @@ -2450,7 +2452,7 @@ components: petstore_auth: flows: implicit: - authorizationUrl: http://petstore.swagger.io/api/oauth/dialog + authorizationUrl: http://localhost/api/oauth/dialog scopes: write:pets: modify pets in your account read:pets: read your pets diff --git a/samples/openapi3/client/petstore/go/go-petstore/configuration.go b/samples/openapi3/client/petstore/go/go-petstore/configuration.go index 1e15aa44679..15c2d1993d8 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/configuration.go +++ b/samples/openapi3/client/petstore/go/go-petstore/configuration.go @@ -104,6 +104,10 @@ func NewConfiguration() *Configuration { UserAgent: "OpenAPI-Generator/1.0.0/go", Debug: false, Servers: ServerConfigurations{ + { + URL: "http://localhost/v2", + Description: "No description provided", + }, { URL: "http://{server}.swagger.io:{port}/v2", Description: "petstore server", @@ -128,7 +132,7 @@ func NewConfiguration() *Configuration { }, }, { - URL: "https://localhost:8080/{version}", + URL: "http://localhost:8080/{version}", Description: "The local server", Variables: map[string]ServerVariable{ "version": ServerVariable{ @@ -142,12 +146,16 @@ func NewConfiguration() *Configuration { }, }, { - URL: "https://127.0.0.1/no_variable", + URL: "http://127.0.0.1/no_variable", Description: "The local server without variables", }, }, OperationServers: map[string]ServerConfigurations{ "PetAPIService.AddPet": { + { + URL: "http://localhost/v2", + Description: "No description provided", + }, { URL: "http://petstore.swagger.io/v2", Description: "No description provided", @@ -158,6 +166,10 @@ func NewConfiguration() *Configuration { }, }, "PetAPIService.UpdatePet": { + { + URL: "http://localhost/v2", + Description: "No description provided", + }, { URL: "http://petstore.swagger.io/v2", Description: "No description provided", diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/AnotherFakeAPI.md b/samples/openapi3/client/petstore/go/go-petstore/docs/AnotherFakeAPI.md index 3f01ccff9ef..ba11497736b 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/docs/AnotherFakeAPI.md +++ b/samples/openapi3/client/petstore/go/go-petstore/docs/AnotherFakeAPI.md @@ -1,6 +1,6 @@ # \AnotherFakeAPI -All URIs are relative to *http://petstore.swagger.io:80/v2* +All URIs are relative to *http://localhost/v2* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/DefaultAPI.md b/samples/openapi3/client/petstore/go/go-petstore/docs/DefaultAPI.md index f0cf1824fb0..cc0912eeec6 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/docs/DefaultAPI.md +++ b/samples/openapi3/client/petstore/go/go-petstore/docs/DefaultAPI.md @@ -1,6 +1,6 @@ # \DefaultAPI -All URIs are relative to *http://petstore.swagger.io:80/v2* +All URIs are relative to *http://localhost/v2* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/FakeAPI.md b/samples/openapi3/client/petstore/go/go-petstore/docs/FakeAPI.md index f533a395e2f..fb380f21673 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/docs/FakeAPI.md +++ b/samples/openapi3/client/petstore/go/go-petstore/docs/FakeAPI.md @@ -1,6 +1,6 @@ # \FakeAPI -All URIs are relative to *http://petstore.swagger.io:80/v2* +All URIs are relative to *http://localhost/v2* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/FakeClassnameTags123API.md b/samples/openapi3/client/petstore/go/go-petstore/docs/FakeClassnameTags123API.md index ad04c336e9f..5941817f21d 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/docs/FakeClassnameTags123API.md +++ b/samples/openapi3/client/petstore/go/go-petstore/docs/FakeClassnameTags123API.md @@ -1,6 +1,6 @@ # \FakeClassnameTags123API -All URIs are relative to *http://petstore.swagger.io:80/v2* +All URIs are relative to *http://localhost/v2* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/PetAPI.md b/samples/openapi3/client/petstore/go/go-petstore/docs/PetAPI.md index f034e1b6c6f..fdbafeae986 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/docs/PetAPI.md +++ b/samples/openapi3/client/petstore/go/go-petstore/docs/PetAPI.md @@ -1,6 +1,6 @@ # \PetAPI -All URIs are relative to *http://petstore.swagger.io:80/v2* +All URIs are relative to *http://localhost/v2* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/StoreAPI.md b/samples/openapi3/client/petstore/go/go-petstore/docs/StoreAPI.md index 441c9dc8393..b83dabcb7a1 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/docs/StoreAPI.md +++ b/samples/openapi3/client/petstore/go/go-petstore/docs/StoreAPI.md @@ -1,6 +1,6 @@ # \StoreAPI -All URIs are relative to *http://petstore.swagger.io:80/v2* +All URIs are relative to *http://localhost/v2* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/samples/openapi3/client/petstore/go/go-petstore/docs/UserAPI.md b/samples/openapi3/client/petstore/go/go-petstore/docs/UserAPI.md index 62ee16ad020..892a5a043d7 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/docs/UserAPI.md +++ b/samples/openapi3/client/petstore/go/go-petstore/docs/UserAPI.md @@ -1,6 +1,6 @@ # \UserAPI -All URIs are relative to *http://petstore.swagger.io:80/v2* +All URIs are relative to *http://localhost/v2* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/samples/openapi3/client/petstore/go/http_signature_test.go b/samples/openapi3/client/petstore/go/http_signature_test.go index 8b2c8078608..23add8aa7f2 100644 --- a/samples/openapi3/client/petstore/go/http_signature_test.go +++ b/samples/openapi3/client/petstore/go/http_signature_test.go @@ -257,8 +257,10 @@ func executeHttpSignatureAuth(t *testing.T, authConfig *sw.HttpSignatureAuth, ex cfg := sw.NewConfiguration() cfg.AddDefaultHeader("testheader", "testvalue") cfg.AddDefaultHeader("Content-Type", "application/json") - cfg.Host = testHost - cfg.Scheme = testScheme + // cfg.Host = testHost + cfg.Host = "petstore.swagger.io" + //cfg.Scheme = testScheme + cfg.Scheme = "http" apiClient := sw.NewAPIClient(cfg) privateKeyPath := filepath.Join(dir, "rsa.pem") @@ -611,7 +613,8 @@ func TestHttpSignatureAuth(t *testing.T) { }, } authorizationHeaderValue := executeHttpSignatureAuth(t, &authConfig, true) - expectedSignature := "sXE2MDeW8os6ywv1oUWaFEPFcSPCEb/msQ/NZGKNA9Emm/e42axaAPojzfkZ9Hacyw/iS/5nH4YIkczMgXu3z5fAwFjumxtf3OxbqvUcQ80wvw2/7B5aQmsF6ZwrCFHZ+L/cj9/bg7L1EGUGtdyDzoRKti4zf9QF/03OsP7QljI=" + //expectedSignature := "sXE2MDeW8os6ywv1oUWaFEPFcSPCEb/msQ/NZGKNA9Emm/e42axaAPojzfkZ9Hacyw/iS/5nH4YIkczMgXu3z5fAwFjumxtf3OxbqvUcQ80wvw2/7B5aQmsF6ZwrCFHZ+L/cj9/bg7L1EGUGtdyDzoRKti4zf9QF/03OsP7QljI=" + expectedSignature := "OTzXHWXkl+9shhgPQ1Gs5rgw8Y2/2ibenontjWpvtX5vw+2Kj5t1q8B8IFYF/+sIAFIP9/meU8REII5yqtNb/RlG+hNIg10AngRBJr+Xa7GPBmvrTJvha+S8Zr7TlbneWcKSyZn0LkO3ohRPBd/CHKZd0APIlivzy+GU5I2HlWY=" expectedAuthorizationHeader := fmt.Sprintf( `Signature keyId="my-key-id",`+ `algorithm="hs2019",headers="(request-target) host content-type digest",`+ diff --git a/samples/openapi3/client/petstore/go/pet_api_test.go b/samples/openapi3/client/petstore/go/pet_api_test.go index 281c653115c..a2748c0efc0 100644 --- a/samples/openapi3/client/petstore/go/pet_api_test.go +++ b/samples/openapi3/client/petstore/go/pet_api_test.go @@ -13,7 +13,7 @@ import ( var client *sw.APIClient -const testHost = "petstore.swagger.io:80" +const testHost = "localhost" const testScheme = "http" func TestMain(m *testing.M) {