diff --git a/bin/configs/python-pydantic-v2.yaml b/bin/configs/python-pydantic-v2.yaml new file mode 100644 index 000000000000..709bfdd57078 --- /dev/null +++ b/bin/configs/python-pydantic-v2.yaml @@ -0,0 +1,13 @@ +generatorName: python +outputDir: samples/openapi3/client/petstore/python-pydantic-v2 +inputSpec: modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-pydantic-v2.yaml +templateDir: modules/openapi-generator/src/main/resources/python +additionalProperties: + packageName: petstore_api + useOneOfDiscriminatorLookup: "true" + disallowAdditionalPropertiesIfNotPresent: false + mapNumberTo: StrictFloat + usePydanticV2: true +nameMappings: + _type: underscore_type + type_: type_with_underscore diff --git a/docs/generators/python.md b/docs/generators/python.md index 84a01d4f3011..b7949aaeb847 100644 --- a/docs/generators/python.md +++ b/docs/generators/python.md @@ -32,6 +32,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |projectName|python project name in setup.py (e.g. petstore-api).| |null| |recursionLimit|Set the recursion limit. If not set, use the system default value.| |null| |useOneOfDiscriminatorLookup|Use the discriminator's mapping in oneOf to speed up the model lookup. IMPORTANT: Validation (e.g. one and only one match in oneOf's schemas) will be skipped.| |false| +|usePydanticV2|Use Pydantic v2 (beta support)| |false| ## IMPORT MAPPING diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonCodegen.java index 12dad3e640c9..a9bd72e390ac 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonCodegen.java @@ -53,6 +53,7 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co protected boolean hasModelsToImport = Boolean.FALSE; protected String mapNumberTo = "Union[StrictFloat, StrictInt]"; protected Map regexModifiers; + protected boolean usePydanticV2; private Map schemaKeyToModelNameCache = new HashMap<>(); // map of set (model imports) @@ -638,6 +639,10 @@ public String patternCorrection(String pattern) { return pattern; } + public void setUsePydanticV2(boolean usePydanticV2) { + this.usePydanticV2 = usePydanticV2; + } + public void setPackageName(String packageName) { this.packageName = packageName; additionalProperties.put(CodegenConstants.PACKAGE_NAME, this.packageName); @@ -1075,10 +1080,12 @@ private String getPydanticType(CodegenParameter cp, if (cp.isArray) { String constraints = ""; if (cp.maxItems != null) { - constraints += String.format(Locale.ROOT, ", max_items=%d", cp.maxItems); + String max = usePydanticV2 ? "max_length" : "max_items"; + constraints += String.format(Locale.ROOT, ", %s=%d", max, cp.maxItems); } if (cp.minItems != null) { - constraints += String.format(Locale.ROOT, ", min_items=%d", cp.minItems); + String min = usePydanticV2 ? "min_length" : "min_items"; + constraints += String.format(Locale.ROOT, ", %s=%d", min, cp.minItems); } if (cp.getUniqueItems()) { constraints += ", unique_items=True"; @@ -1360,10 +1367,12 @@ private String getPydanticType(CodegenProperty cp, if (cp.isArray) { String constraints = ""; if (cp.maxItems != null) { - constraints += String.format(Locale.ROOT, ", max_items=%d", cp.maxItems); + String max = usePydanticV2 ? "max_length" : "max_items"; + constraints += String.format(Locale.ROOT, ", %s=%d", max, cp.maxItems); } if (cp.minItems != null) { - constraints += String.format(Locale.ROOT, ", min_items=%d", cp.minItems); + String min = usePydanticV2 ? "min_length" : "min_items"; + constraints += String.format(Locale.ROOT, ", %s=%d", min, cp.minItems); } if (cp.getUniqueItems()) { constraints += ", unique_items=True"; diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java index b6dc45052487..5ee18ec3f0da 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java @@ -49,6 +49,7 @@ public class PythonClientCodegen extends AbstractPythonCodegen implements Codege public static final String RECURSION_LIMIT = "recursionLimit"; public static final String DATETIME_FORMAT = "datetimeFormat"; public static final String DATE_FORMAT = "dateFormat"; + public static final String USE_PYDANTIC_V2 = "usePydanticV2"; protected String packageUrl; protected String apiDocPath = "docs/"; @@ -164,6 +165,8 @@ public PythonClientCodegen() { cliOptions.add(new CliOption(DATE_FORMAT, "date format for query parameters") .defaultValue("%Y-%m-%d")); cliOptions.add(new CliOption(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP_DESC).defaultValue("false")); + cliOptions.add(new CliOption(USE_PYDANTIC_V2, "Use Pydantic v2 (beta support)") + .defaultValue("false")); supportedLibraries.put("urllib3", "urllib3-based client"); supportedLibraries.put("asyncio", "asyncio-based client"); @@ -256,6 +259,11 @@ public void processOpts() { } } + // to use Pydantic V2? + if (additionalProperties.containsKey(USE_PYDANTIC_V2)) { + setUsePydanticV2(Boolean.valueOf(additionalProperties.get(USE_PYDANTIC_V2).toString())); + } + if (additionalProperties.containsKey(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP)) { setUseOneOfDiscriminatorLookup(convertPropertyToBooleanAndWriteBack(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP)); } else { diff --git a/modules/openapi-generator/src/main/resources/python-fastapi/requirements.mustache b/modules/openapi-generator/src/main/resources/python-fastapi/requirements.mustache index e5a1b375c4c3..6e52599f1f75 100644 --- a/modules/openapi-generator/src/main/resources/python-fastapi/requirements.mustache +++ b/modules/openapi-generator/src/main/resources/python-fastapi/requirements.mustache @@ -7,7 +7,7 @@ chardet==4.0.0 click==7.1.2 dnspython==2.1.0 email-validator==1.1.2 -fastapi==0.95.2 +fastapi==0.103.0 graphene==2.1.8 graphql-core==2.3.2 graphql-relay==2.0.1 @@ -20,7 +20,7 @@ Jinja2==2.11.3 MarkupSafe==2.0.1 orjson==3.5.2 promise==2.3 -pydantic==1.8.2 +pydantic==2.3.0 python-dotenv==0.17.1 python-multipart==0.0.5 PyYAML==5.4.1 diff --git a/modules/openapi-generator/src/main/resources/python/api.mustache b/modules/openapi-generator/src/main/resources/python/api.mustache index 740f2b2f20db..5558a6bc5bd9 100644 --- a/modules/openapi-generator/src/main/resources/python/api.mustache +++ b/modules/openapi-generator/src/main/resources/python/api.mustache @@ -6,7 +6,8 @@ import re # noqa: F401 import io import warnings -from pydantic import validate_arguments, ValidationError +from pydantic import {{#usePydanticV2}}validate_call{{/usePydanticV2}}{{^usePydanticV2}}validate_arguments{{/usePydanticV2}}, ValidationError +from typing_extensions import Annotated {{#asyncio}} from typing import overload, Optional, Union, Awaitable {{/asyncio}} @@ -47,7 +48,7 @@ class {{classname}}: ... {{/asyncio}} - @validate_arguments + @{{#usePydanticV2}}validate_call{{/usePydanticV2}}{{^usePydanticV2}}validate_arguments{{/usePydanticV2}} def {{operationId}}(self, {{#allParams}}{{paramName}} : {{{vendorExtensions.x-py-typing}}}{{^required}} = None{{/required}}, {{/allParams}}{{#asyncio}}async_req: Optional[bool]=None, {{/asyncio}}**kwargs) -> {{#asyncio}}Union[{{{returnType}}}{{^returnType}}None{{/returnType}}, Awaitable[{{{returnType}}}{{^returnType}}None{{/returnType}}]]{{/asyncio}}{{^asyncio}}{{{returnType}}}{{^returnType}}None{{/returnType}}{{/asyncio}}: # noqa: E501 """{{#isDeprecated}}(Deprecated) {{/isDeprecated}}{{{summary}}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501 @@ -85,7 +86,7 @@ class {{classname}}: {{/asyncio}} return self.{{operationId}}_with_http_info({{#allParams}}{{paramName}}, {{/allParams}}**kwargs) # noqa: E501 - @validate_arguments + @{{#usePydanticV2}}validate_call{{/usePydanticV2}}{{^usePydanticV2}}validate_arguments{{/usePydanticV2}} def {{operationId}}_with_http_info(self, {{#allParams}}{{paramName}} : {{{vendorExtensions.x-py-typing}}}{{^required}} = None{{/required}}, {{/allParams}}**kwargs) -> ApiResponse: # noqa: E501 """{{#isDeprecated}}(Deprecated) {{/isDeprecated}}{{{summary}}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501 diff --git a/modules/openapi-generator/src/main/resources/python/model_anyof.mustache b/modules/openapi-generator/src/main/resources/python/model_anyof.mustache index adec7c418683..ff0b3fcd7df5 100644 --- a/modules/openapi-generator/src/main/resources/python/model_anyof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_anyof.mustache @@ -10,7 +10,13 @@ import re # noqa: F401 {{{.}}} {{/vendorExtensions.x-py-model-imports}} from typing import Union, Any, List, TYPE_CHECKING +{{#usePydanticV2}} +try: + from typing import Literal +except ImportError: + from typing_extensions import Literal from pydantic import StrictStr, Field +{{/usePydanticV2}} {{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ANY_OF_SCHEMAS = [{{#anyOf}}"{{.}}"{{^-last}}, {{/-last}}{{/anyOf}}] @@ -27,10 +33,23 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} actual_instance: Union[{{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}}] else: actual_instance: Any + {{^usePydanticV2}} any_of_schemas: List[str] = Field({{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ANY_OF_SCHEMAS, const=True) - + {{/usePydanticV2}} + {{#usePydanticV2}} + any_of_schemas: List[str] = Literal[{{#anyOf}}"{{.}}"{{^-last}}, {{/-last}}{{/anyOf}}] + {{/usePydanticV2}} + + """Pydantic configuration""" + {{#usePydanticV2}} + model_config = { + "validate_assignment": True, + } + {{/usePydanticV2}} + {{^usePydanticV2}} class Config: validate_assignment = True + {{/usePydanticV2}} {{#discriminator}} discriminator_value_class_map = { diff --git a/modules/openapi-generator/src/main/resources/python/model_generic.mustache b/modules/openapi-generator/src/main/resources/python/model_generic.mustache index 6a09b9c9bd19..30072031c0c1 100644 --- a/modules/openapi-generator/src/main/resources/python/model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_generic.mustache @@ -73,10 +73,18 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{/isEnum}} {{/vars}} + """Pydantic configuration""" + {{#usePydanticV2}} + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + {{/usePydanticV2}} + {{^usePydanticV2}} class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True + {{/usePydanticV2}} {{#hasChildren}} {{#discriminator}} diff --git a/modules/openapi-generator/src/main/resources/python/model_oneof.mustache b/modules/openapi-generator/src/main/resources/python/model_oneof.mustache index 2f23bade3418..b2ff88833b54 100644 --- a/modules/openapi-generator/src/main/resources/python/model_oneof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_oneof.mustache @@ -10,7 +10,13 @@ import re # noqa: F401 {{{.}}} {{/vendorExtensions.x-py-model-imports}} from typing import Union, Any, List, TYPE_CHECKING +{{#usePydanticV2}} +try: + from typing import Literal +except ImportError: + from typing_extensions import Literal from pydantic import StrictStr, Field +{{/usePydanticV2}} {{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ONE_OF_SCHEMAS = [{{#oneOf}}"{{.}}"{{^-last}}, {{/-last}}{{/oneOf}}] @@ -26,10 +32,24 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} actual_instance: Union[{{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}] else: actual_instance: Any + + {{#usePydanticV2}} + one_of_schemas: List[str] = Literal[{{#oneOf}}"{{.}}"{{^-last}}, {{/-last}}{{/oneOf}}] + {{/usePydanticV2}} + {{^usePydanticV2}} one_of_schemas: List[str] = Field({{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ONE_OF_SCHEMAS, const=True) + {{/usePydanticV2}} + """Pydantic configuration""" + {{#usePydanticV2}} + model_config = { + "validate_assignment": True, + } + {{/usePydanticV2}} + {{^usePydanticV2}} class Config: validate_assignment = True + {{/usePydanticV2}} {{#discriminator}} discriminator_value_class_map = { diff --git a/modules/openapi-generator/src/main/resources/python/pyproject.mustache b/modules/openapi-generator/src/main/resources/python/pyproject.mustache index 75900ed9f8a6..b557c81bfd2a 100644 --- a/modules/openapi-generator/src/main/resources/python/pyproject.mustache +++ b/modules/openapi-generator/src/main/resources/python/pyproject.mustache @@ -24,7 +24,12 @@ tornado = ">=4.2,<5" pem = ">= 19.3.0" pycryptodome = ">= 3.9.0" {{/hasHttpSignatureMethods}} +{{#usePydanticV2}} +pydantic = ">=2" +{{/usePydanticV2}} +{{^usePydanticV2}} pydantic = "^1.10.5, <2" +{{/usePydanticV2}} aenum = ">=3.1.11" [tool.poetry.dev-dependencies] diff --git a/modules/openapi-generator/src/main/resources/python/requirements.mustache b/modules/openapi-generator/src/main/resources/python/requirements.mustache index bd4fe39d883b..817e0f5a8288 100644 --- a/modules/openapi-generator/src/main/resources/python/requirements.mustache +++ b/modules/openapi-generator/src/main/resources/python/requirements.mustache @@ -1,7 +1,12 @@ python_dateutil >= 2.5.3 setuptools >= 21.0.0 urllib3 >= 1.25.3, < 2.1.0 +{{#usePydanticV2}} +pydantic >= 2 +{{/usePydanticV2}} +{{^usePydanticV2}} pydantic >= 1.10.5, < 2 +{{/usePydanticV2}} aenum >= 3.1.11 {{#asyncio}} aiohttp >= 3.0.0 diff --git a/modules/openapi-generator/src/main/resources/python/setup.mustache b/modules/openapi-generator/src/main/resources/python/setup.mustache index 538a8dff90fb..c5110f4572f4 100644 --- a/modules/openapi-generator/src/main/resources/python/setup.mustache +++ b/modules/openapi-generator/src/main/resources/python/setup.mustache @@ -29,7 +29,12 @@ REQUIRES = [ "pem>=19.3.0", "pycryptodome>=3.9.0", {{/hasHttpSignatureMethods}} +{{#usePydanticV2}} + "pydantic >= 2", +{{/usePydanticV2}} +{{^usePydanticV2}} "pydantic >= 1.10.5, < 2", +{{/usePydanticV2}} "aenum" ] diff --git a/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-pydantic-v2.yaml b/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-pydantic-v2.yaml new file mode 100644 index 000000000000..4fe96df00525 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-pydantic-v2.yaml @@ -0,0 +1,2332 @@ +openapi: 3.0.0 +info: + description: >- + This spec is mainly for testing Petstore server and contains fake endpoints, + models. Please do not use this for any other purpose. Special characters: " + \ + version: 1.0.0 + title: OpenAPI Petstore + license: + name: Apache-2.0 + url: 'https://www.apache.org/licenses/LICENSE-2.0.html' +tags: + - name: pet + description: Everything about your Pets + - name: store + description: Access to Petstore orders + - name: user + description: Operations about user +paths: + /foo: + get: + responses: + default: + description: response + content: + application/json: + schema: + type: object + properties: + string: + $ref: '#/components/schemas/Foo' + /pet: + post: + tags: + - pet + summary: Add a new pet to the store + description: '' + operationId: addPet + responses: + '200': + description: Successful operation + '405': + description: Invalid input + security: + - http_signature_test: [] + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + $ref: '#/components/requestBodies/Pet' + put: + tags: + - pet + summary: Update an existing pet + description: '' + operationId: updatePet + x-webclient-blocking: true + responses: + '200': + description: Successful operation + '400': + description: Invalid ID supplied + '404': + description: Pet not found + '405': + description: Validation exception + security: + - http_signature_test: [] + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + $ref: '#/components/requestBodies/Pet' + /pet/findByStatus: + get: + tags: + - pet + summary: Finds Pets by status + description: Multiple status values can be provided with comma separated strings + operationId: findPetsByStatus + x-webclient-blocking: true + parameters: + - name: status + in: query + description: Status values that need to be considered for filter + required: true + style: form + explode: false + deprecated: true + schema: + type: array + items: + type: string + enum: + - available + - pending + - sold + default: available + responses: + '200': + description: successful operation + content: + application/xml: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + '400': + description: Invalid status value + security: + - http_signature_test: [] + - 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 + x-webclient-blocking: true + parameters: + - name: tags + in: query + description: Tags to filter by + required: true + style: form + explode: false + schema: + type: array + items: + type: string + #uniqueItems: true + responses: + '200': + description: successful operation + content: + application/xml: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + #uniqueItems: true + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + #uniqueItems: true + '400': + description: Invalid tag value + security: + - http_signature_test: [] + - 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 + x-webclient-blocking: true + parameters: + - name: petId + in: path + description: ID of pet to return + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Pet' + application/json: + schema: + $ref: '#/components/schemas/Pet' + '400': + description: Invalid ID supplied + '404': + description: Pet not found + security: + - api_key: [] + post: + tags: + - pet + summary: Updates a pet in the store with form data + description: '' + operationId: updatePetWithForm + parameters: + - name: petId + in: path + description: ID of pet that needs to be updated + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: Successful operation + '405': + description: Invalid input + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string + delete: + tags: + - pet + summary: Deletes a pet + description: '' + operationId: deletePet + parameters: + - name: api_key + in: header + required: false + schema: + type: string + - name: petId + in: path + description: Pet id to delete + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: Successful operation + '400': + description: Invalid pet value + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + '/pet/{petId}/uploadImage': + post: + tags: + - pet + summary: uploads an image + description: '' + operationId: uploadFile + parameters: + - name: petId + in: path + description: ID of pet to update + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + content: + multipart/form-data: + schema: + type: object + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + type: string + format: binary + /store/inventory: + get: + tags: + - store + summary: Returns pet inventories by status + description: Returns a map of status codes to quantities + operationId: getInventory + responses: + '200': + description: successful operation + content: + application/json: + schema: + type: object + additionalProperties: + type: integer + format: int32 + security: + - api_key: [] + /store/order: + post: + tags: + - store + summary: Place an order for a pet + description: '' + operationId: placeOrder + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Order' + application/json: + schema: + $ref: '#/components/schemas/Order' + '400': + description: Invalid Order + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Order' + description: order placed for purchasing the pet + required: true + '/store/order/{order_id}': + get: + tags: + - store + summary: Find purchase order by ID + description: >- + For valid response try integer IDs with value <= 5 or > 10. Other values + will generated exceptions + operationId: getOrderById + parameters: + - name: order_id + in: path + description: ID of pet that needs to be fetched + required: true + schema: + type: integer + format: int64 + minimum: 1 + maximum: 5 + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Order' + application/json: + schema: + $ref: '#/components/schemas/Order' + '400': + description: Invalid ID supplied + '404': + description: Order not found + delete: + tags: + - store + summary: Delete purchase order by ID + description: >- + For valid response try integer IDs with value < 1000. Anything above + 1000 or nonintegers will generate API errors + operationId: deleteOrder + parameters: + - name: order_id + in: path + description: ID of the order that needs to be deleted + required: true + schema: + type: string + responses: + '400': + description: Invalid ID supplied + '404': + description: Order not found + /user: + servers: + - url: 'http://petstore.swagger.io/v2' + - url: 'http://path-server-test.petstore.local/v2' + - url: 'http://{server}.swagger.io:{port}/v2' + description: test server with variables + variables: + server: + description: target server + enum: + - 'petstore' + - 'qa-petstore' + - 'dev-petstore' + default: 'petstore' + port: + enum: + - 80 + - 8080 + default: 80 + post: + tags: + - user + summary: Create user + description: This can only be done by the logged in user. + operationId: createUser + responses: + default: + description: successful operation + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + description: Created user object + required: true + /user/createWithArray: + post: + tags: + - user + summary: Creates list of users with given input array + description: '' + operationId: createUsersWithArrayInput + responses: + default: + description: successful operation + requestBody: + $ref: '#/components/requestBodies/UserArray' + /user/createWithList: + post: + tags: + - user + summary: Creates list of users with given input array + description: '' + operationId: createUsersWithListInput + responses: + default: + description: successful operation + requestBody: + $ref: '#/components/requestBodies/UserArray' + /user/login: + get: + tags: + - user + summary: Logs user into the system + description: '' + operationId: loginUser + parameters: + - name: username + in: query + description: The user name for login + required: true + schema: + type: string + - name: password + in: query + description: The password for login in clear text + required: true + schema: + type: string + responses: + '200': + description: successful operation + headers: + X-Rate-Limit: + description: calls per hour allowed by the user + schema: + type: integer + format: int32 + X-Expires-After: + description: date in UTC when token expires + schema: + type: string + format: date-time + content: + application/xml: + schema: + type: string + application/json: + schema: + type: string + '400': + description: Invalid username/password supplied + /user/logout: + get: + tags: + - user + summary: Logs out current logged in user session + description: '' + operationId: logoutUser + responses: + default: + description: successful operation + '/user/{username}': + get: + tags: + - user + summary: Get user by user name + description: '' + operationId: getUserByName + parameters: + - name: username + in: path + description: The name that needs to be fetched. Use user1 for testing. + required: true + schema: + type: string + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/User' + application/json: + schema: + $ref: '#/components/schemas/User' + '400': + description: Invalid username supplied + '404': + description: User not found + put: + tags: + - user + summary: Updated user + description: This can only be done by the logged in user. + operationId: updateUser + parameters: + - name: username + in: path + description: name that need to be deleted + required: true + schema: + type: string + responses: + '400': + description: Invalid user supplied + '404': + description: User not found + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + description: Updated user object + required: true + delete: + tags: + - user + summary: Delete user + description: This can only be done by the logged in user. + operationId: deleteUser + parameters: + - name: username + in: path + description: The name that needs to be deleted + required: true + schema: + type: string + responses: + '400': + description: Invalid username supplied + '404': + description: User not found + /fake_classname_test: + patch: + tags: + - 'fake_classname_tags 123#$%^' + summary: To test class name in snake case + description: To test class name in snake case + operationId: testClassname + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + security: + - api_key_query: [] + requestBody: + $ref: '#/components/requestBodies/Client' + /fake: + patch: + tags: + - fake + summary: To test "client" model + description: To test "client" model + operationId: testClientModel + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + requestBody: + $ref: '#/components/requestBodies/Client' + # get: + # tags: + # - fake + # summary: To test enum parameters + # description: To test enum parameters + # operationId: testEnumParameters + # parameters: + # - name: enum_header_string_array + # in: header + # description: Header parameter enum test (string array) + # schema: + # type: array + # items: + # type: string + # default: $ + # enum: + # - '>' + # - $ + # - name: enum_header_string + # in: header + # description: Header parameter enum test (string) + # schema: + # type: string + # enum: + # - _abc + # - '-efg' + # - (xyz) + # default: '-efg' + # - name: enum_query_string_array + # in: query + # description: Query parameter enum test (string array) + # schema: + # type: array + # items: + # type: string + # default: $ + # enum: + # - '>' + # - $ + # - name: enum_query_string + # in: query + # description: Query parameter enum test (string) + # schema: + # type: string + # enum: + # - _abc + # - '-efg' + # - (xyz) + # default: '-efg' + # - name: enum_query_integer + # in: query + # description: Query parameter enum test (double) + # schema: + # type: integer + # format: int32 + # enum: + # - 1 + # - -2 + # - name: enum_query_double + # in: query + # description: Query parameter enum test (double) + # schema: + # type: number + # format: double + # enum: + # - 1.1 + # - -1.2 + # #- name: enum_query_model_array + # # in: query + # # schema: + # # type: array + # # items: + # # $ref: '#/components/schemas/EnumClass' + # responses: + # '400': + # description: Invalid request + # '404': + # description: Not found + # requestBody: + # content: + # application/x-www-form-urlencoded: + # schema: + # type: object + # properties: + # enum_form_string_array: + # description: Form parameter enum test (string array) + # type: array + # items: + # type: string + # default: $ + # enum: + # - '>' + # - $ + # enum_form_string: + # description: Form parameter enum test (string) + # type: string + # enum: + # - _abc + # - '-efg' + # - (xyz) + # default: '-efg' + post: + tags: + - fake + summary: | + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + description: | + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + operationId: testEndpointParameters + responses: + '400': + description: Invalid username supplied + '404': + description: User not found + security: + - http_basic_test: [] + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + integer: + description: None + type: integer + minimum: 10 + maximum: 100 + int32: + description: None + type: integer + format: int32 + minimum: 20 + maximum: 200 + int64: + description: None + type: integer + format: int64 + number: + description: None + type: number + minimum: 32.1 + maximum: 543.2 + float: + description: None + type: number + format: float + maximum: 987.6 + double: + description: None + type: number + format: double + minimum: 67.8 + maximum: 123.4 + string: + description: None + type: string + pattern: '/[a-z]/i' + pattern_without_delimiter: + description: None + type: string + pattern: '^[A-Z].*' + byte: + description: None + type: string + format: byte + binary: + description: None + type: string + format: binary + byte_with_max_length: + description: None + type: string + format: byte + maxLength: 64 + date: + description: None + type: string + format: date + dateTime: + description: None + type: string + format: date-time + password: + description: None + type: string + format: password + minLength: 10 + maxLength: 64 + callback: + description: None + type: string + required: + - number + - double + - pattern_without_delimiter + - byte + delete: + tags: + - fake + security: + - bearer_test: [] + 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 + in: query + description: Required String in group parameters + required: true + schema: + type: integer + - name: required_boolean_group + in: header + description: Required Boolean in group parameters + required: true + schema: + type: boolean + - name: required_int64_group + in: query + description: Required Integer in group parameters + required: true + schema: + type: integer + format: int64 + - name: string_group + in: query + description: String in group parameters + schema: + type: integer + - name: boolean_group + in: header + description: Boolean in group parameters + schema: + type: boolean + - name: int64_group + in: query + description: Integer in group parameters + schema: + type: integer + format: int64 + responses: + '400': + description: Someting wrong + /fake/outer/number: + post: + tags: + - fake + description: Test serialization of outer number types + operationId: fakeOuterNumberSerialize + responses: + '200': + description: Output number + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterNumber' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterNumber' + description: Input number as post body + /fake/property/enum-int: + post: + tags: + - fake + description: Test serialization of enum (int) properties with examples + operationId: fakePropertyEnumIntegerSerialize + responses: + '200': + description: Output enum (int) + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterObjectWithEnumProperty' + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/OuterObjectWithEnumProperty' + description: Input enum (int) as post body + /fake/outer/string: + post: + tags: + - fake + description: Test serialization of outer string types + operationId: fakeOuterStringSerialize + responses: + '200': + description: Output string + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterString' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterString' + description: Input string as post body + /fake/outer/boolean: + post: + tags: + - fake + description: Test serialization of outer boolean types + operationId: fakeOuterBooleanSerialize + responses: + '200': + description: Output boolean + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterBoolean' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterBoolean' + description: Input boolean as post body + /fake/outer/composite: + post: + tags: + - fake + description: Test serialization of object with outer number type + operationId: fakeOuterCompositeSerialize + responses: + '200': + description: Output composite + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterComposite' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterComposite' + description: Input composite as post body + /fake/jsonFormData: + get: + tags: + - fake + summary: test json serialization of form data + description: '' + operationId: testJsonFormData + responses: + '200': + description: successful operation + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + param: + description: field1 + type: string + param2: + description: field2 + type: string + required: + - param + - param2 + /fake/inline-additionalProperties: + post: + tags: + - fake + summary: test inline additionalProperties + description: '' + operationId: testInlineAdditionalProperties + responses: + '200': + description: successful operation + requestBody: + content: + application/json: + schema: + type: object + additionalProperties: + type: string + description: request body + required: true + /fake/date-time-query-params: + put: + tags: + - fake + operationId: testDateTimeQueryParameter + parameters: + - name: date_time_query + in: query + required: true + schema: + type: string + format: date-time + - name: str_query + in: query + required: true + schema: + type: string + responses: + '200': + description: Success + /fake/body-with-query-params: + put: + tags: + - fake + operationId: testBodyWithQueryParams + parameters: + - name: query + in: query + required: true + schema: + type: string + responses: + '200': + description: Success + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + required: true + /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' + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + requestBody: + $ref: '#/components/requestBodies/Client' + /fake/body-with-file-schema: + put: + tags: + - fake + description: >- + For this test, the body for this request must reference a schema named + `File`. + operationId: testBodyWithFileSchema + responses: + '200': + description: Success + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/FileSchemaTestClass' + required: true + /fake/body-with-binary: + put: + tags: + - fake + description: >- + For this test, the body has to be a binary file. + operationId: testBodyWithBinary + responses: + '200': + description: Success + requestBody: + content: + image/png: + schema: + type: string + nullable: true + format: binary + description: image to upload + required: true + /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 + style: pipeDelimited + schema: + type: array + items: + type: string + - name: ioutil + in: query + required: true + style: form + explode: false + schema: + type: array + items: + type: string + - name: http + in: query + required: true + style: spaceDelimited + schema: + type: array + items: + type: string + - name: url + in: query + required: true + style: form + explode: false + schema: + type: array + items: + type: string + - name: context + in: query + required: true + explode: true + schema: + type: array + items: + type: string + - name: language + in: query + required: false + schema: + type: object + additionalProperties: + type: string + format: string + - name: allowEmpty + in: query + required: true + allowEmptyValue: true + schema: + type: string + responses: + "200": + description: Success + '/fake/{petId}/uploadImageWithRequiredFile': + post: + tags: + - pet + summary: uploads an image (required) + description: '' + operationId: uploadFileWithRequiredFile + parameters: + - name: petId + in: path + description: ID of pet to update + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + content: + multipart/form-data: + schema: + type: object + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + requiredFile: + description: file to upload + type: string + format: binary + required: + - requiredFile + /fake/health: + get: + tags: + - fake + summary: Health check endpoint + responses: + 200: + description: The instance started successfully + content: + application/json: + schema: + $ref: '#/components/schemas/HealthCheckResult' + /fake/http-signature-test: + get: + tags: + - fake + summary: test http signature authentication + operationId: fake-http-signature-test + parameters: + - name: query_1 + in: query + description: query parameter + required: optional + schema: + type: string + - name: header_1 + in: header + description: header parameter + required: optional + schema: + type: string + security: + - http_signature_test: [] + requestBody: + $ref: '#/components/requestBodies/Pet' + responses: + 200: + description: The instance started successfully + /fake/any_type_body: + post: + tags: + - fake + summary: test any type request body + operationId: fakeAnyTypeRequestBody + requestBody: + content: + application/json: + schema: + type: object + responses: + 200: + description: OK + /fake/uuid_example: + get: + tags: + - fake + summary: test uuid example + operationId: fakeUuidExample + parameters: + - name: uuid_example + in: query + description: uuid example + required: true + schema: + type: string + format: uuid + example: 84529ad2-2265-4e15-b76b-c17025d848f6 + responses: + "200": + description: Get successful + /fake/enum_ref_query_parameter: + get: + tags: + - fake + summary: test enum reference query parameter + operationId: fakeEnumRefQueryParameter + parameters: + - name: enum_ref + in: query + description: enum reference + schema: + $ref: '#/components/schemas/EnumClass' + responses: + "200": + description: Get successful + /fake/return_list_of_object: + get: + tags: + - fake + summary: test returning list of objects + operationId: fake_return_list_of_objects + responses: + 200: + description: OK + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/ListOfObjects" +servers: + - url: 'http://{server}.swagger.io:{port}/v2' + description: petstore server + variables: + server: + enum: + - 'petstore' + - 'qa-petstore' + - 'dev-petstore' + default: 'petstore' + port: + enum: + - 80 + - 8080 + default: 80 + - url: https://localhost:8080/{version} + description: The local server + variables: + version: + enum: + - 'v1' + - 'v2' + default: 'v2' + - url: https://127.0.0.1/no_varaible + description: The local server without variables +components: + requestBodies: + UserArray: + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/User' + description: List of user object + required: true + Client: + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: client model + required: true + Pet: + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + application/xml: + schema: + $ref: '#/components/schemas/Pet' + description: Pet object that needs to be added to the store + required: true + securitySchemes: + petstore_auth: + type: oauth2 + flows: + implicit: + authorizationUrl: 'http://petstore.swagger.io/api/oauth/dialog' + scopes: + 'write:pets': modify pets in your account + 'read:pets': read your pets + api_key: + type: apiKey + name: api_key + in: header + api_key_query: + type: apiKey + name: api_key_query + in: query + http_basic_test: + type: http + scheme: basic + bearer_test: + type: http + scheme: bearer + bearerFormat: JWT + http_signature_test: + # Test the 'HTTP signature' security scheme. + # Each HTTP request is cryptographically signed as specified + # in https://datatracker.ietf.org/doc/draft-cavage-http-signatures/ + type: http + scheme: signature + schemas: + Foo: + type: object + properties: + bar: + $ref: '#/components/schemas/Bar' + Bar: + type: string + default: bar + Order: + type: object + properties: + id: + type: integer + format: int64 + petId: + type: integer + format: int64 + quantity: + type: integer + format: int32 + shipDate: + type: string + format: date-time + status: + type: string + description: Order Status + enum: + - placed + - approved + - delivered + complete: + type: boolean + default: false + xml: + name: Order + Category: + type: object + required: + - name + properties: + id: + type: integer + format: int64 + name: + type: string + default: default-name + xml: + name: Category + User: + type: object + properties: + id: + type: integer + format: int64 + x-is-unique: true + username: + type: string + firstName: + type: string + lastName: + type: string + email: + type: string + password: + type: string + phone: + type: string + userStatus: + type: integer + format: int32 + description: User Status + xml: + name: User + Tag: + type: object + properties: + id: + type: integer + format: int64 + name: + type: string + xml: + name: Tag + Pet: + type: object + required: + - name + - photoUrls + properties: + id: + type: integer + format: int64 + x-is-unique: true + category: + $ref: '#/components/schemas/Category' + name: + type: string + example: doggie + photoUrls: + minItems: 0 + type: array + xml: + name: photoUrl + wrapped: true + items: + type: string + #uniqueItems: true + tags: + type: array + xml: + name: tag + wrapped: true + items: + $ref: '#/components/schemas/Tag' + status: + type: string + description: pet status in the store + enum: + - available + - pending + - sold + xml: + name: Pet + special_name: + type: object + properties: + property: + type: integer + format: int64 + async: + $ref: '#/components/schemas/Category' + schema: + type: string + description: pet status in the store + enum: + - available + - pending + - sold + ApiResponse: + type: object + properties: + code: + type: integer + format: int32 + type: + type: string + message: + type: string + 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: '#/components/schemas/Animal' + - type: object + properties: + breed: + type: string + Cat: + allOf: + - $ref: '#/components/schemas/Animal' + - type: object + properties: + declawed: + type: boolean + Animal: + type: object + discriminator: + propertyName: className + required: + - className + properties: + className: + type: string + color: + type: string + default: red + AnimalFarm: + type: array + items: + $ref: '#/components/schemas/Animal' + format_test: + type: object + required: + - number + - 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 + decimal: + type: string + format: number + string: + type: string + pattern: '/[a-z]/i' + string_with_double_quote_pattern: + type: string + pattern: 'this is "something"' + 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 + pattern_with_digits: + description: A string that is a 10 digit number. Can have leading zeros. + type: string + pattern: '^\d{10}$' + pattern_with_digits_and_delimiter: + description: A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. + type: string + pattern: '/^image_\d{1,3}$/i' + 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_default: + type: integer + format: int32 + enum: + - 1 + - 5 + - 14 + default: 5 + enum_integer: + type: integer + format: int32 + enum: + - 1 + - -1 + enum_number: + type: number + format: double + enum: + - 1.1 + - -1.2 + outerEnum: + $ref: '#/components/schemas/OuterEnum' + outerEnumInteger: + $ref: '#/components/schemas/OuterEnumInteger' + outerEnumDefaultValue: + $ref: '#/components/schemas/OuterEnumDefaultValue' + outerEnumIntegerDefaultValue: + $ref: '#/components/schemas/OuterEnumIntegerDefaultValue' + AdditionalPropertiesClass: + type: object + properties: + map_property: + type: object + additionalProperties: + type: string + map_of_map_property: + type: object + additionalProperties: + type: object + additionalProperties: + type: string + MixedPropertiesAndAdditionalPropertiesClass: + type: object + properties: + uuid: + type: string + format: uuid + dateTime: + type: string + format: date-time + map: + type: object + additionalProperties: + $ref: '#/components/schemas/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 + map_of_enum_string: + type: object + additionalProperties: + type: string + enum: + - UPPER + - lower + direct_map: + type: object + additionalProperties: + type: boolean + indirect_map: + $ref: '#/components/schemas/StringBooleanMap' + ArrayTest: + type: object + properties: + array_of_string: + type: array + items: + type: string + minItems: 0 + maxItems: 3 + 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: '#/components/schemas/ReadOnlyFirst' + 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 + OuterEnum: + nullable: true + type: string + enum: + - placed + - approved + - delivered + OuterEnumInteger: + type: integer + enum: + - 0 + - 1 + - 2 + example: 2 + OuterEnumDefaultValue: + type: string + enum: + - placed + - approved + - delivered + default: placed + OuterEnumIntegerDefaultValue: + type: integer + enum: + - -1 + - 0 + - 1 + - 2 + default: 0 + SpecialCharacterEnum: + type: string + enum: + - "456" + - "123abc" + - "_" + - " " + - "&" + - "$" + - ">=" + - "this_is_!" + - "import" # reserved word + - " hello world " + OuterComposite: + type: object + properties: + my_number: + $ref: '#/components/schemas/OuterNumber' + my_string: + $ref: '#/components/schemas/OuterString' + my_boolean: + $ref: '#/components/schemas/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: '#/components/schemas/File' + files: + type: array + items: + $ref: '#/components/schemas/File' + File: + type: object + description: Must be named `File` for test. + properties: + sourceURI: + description: Test capitalization + type: string + _special_model.name_: + properties: + '$special[property.name]': + type: integer + format: int64 + xml: + name: '$special[model.name]' + HealthCheckResult: + type: object + properties: + NullableMessage: + nullable: true + type: string + description: Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. + NullableClass: + type: object + required: [required_integer_prop] + properties: + required_integer_prop: + type: integer + nullable: true + integer_prop: + type: integer + nullable: true + number_prop: + type: number + nullable: true + boolean_prop: + type: boolean + nullable: true + string_prop: + type: string + nullable: true + date_prop: + type: string + format: date + nullable: true + datetime_prop: + type: string + format: date-time + nullable: true + array_nullable_prop: + type: array + nullable: true + items: + type: object + array_and_items_nullable_prop: + type: array + nullable: true + items: + type: object + nullable: true + array_items_nullable: + type: array + items: + type: object + nullable: true + object_nullable_prop: + type: object + nullable: true + additionalProperties: + type: object + object_and_items_nullable_prop: + type: object + nullable: true + additionalProperties: + type: object + nullable: true + object_items_nullable: + type: object + additionalProperties: + type: object + nullable: true + additionalProperties: + type: object + nullable: true + OuterObjectWithEnumProperty: + type: object + example: + value: 2 + required: + - value + properties: + str_value: + $ref: '#/components/schemas/OuterEnum' + value: + $ref: '#/components/schemas/OuterEnumInteger' + DeprecatedObject: + type: object + deprecated: true + properties: + name: + type: string + ObjectWithDeprecatedFields: + type: object + properties: + uuid: + type: string + id: + type: number + deprecated: true + deprecatedRef: + $ref: '#/components/schemas/DeprecatedObject' + bars: + type: array + deprecated: true + items: + $ref: '#/components/schemas/Bar' + AllOfWithSingleRef: + type: object + properties: + username: + type: string + SingleRefType: + allOf: + - $ref: '#/components/schemas/SingleRefType' + SingleRefType: + type: string + title: SingleRefType + enum: + - admin + - user + Pig: + oneOf: + - $ref: '#/components/schemas/BasquePig' + - $ref: '#/components/schemas/DanishPig' + discriminator: + propertyName: className + BasquePig: + type: object + properties: + className: + type: string + color: + type: string + required: + - className + - color + DanishPig: + type: object + properties: + className: + type: string + size: + type: integer + required: + - className + - size + AnyOfPig: + anyOf: + - $ref: '#/components/schemas/BasquePig' + - $ref: '#/components/schemas/DanishPig' + WithNestedOneOf: + type: object + properties: + size: + type: integer + nested_pig: + $ref: '#/components/schemas/Pig' + nested_oneof_enum_string: + $ref: '#/components/schemas/OneOfEnumString' + Self-Reference-Model: + type: object + properties: + size: + type: integer + nested: + $ref: '#/components/schemas/Dummy-Model' + Dummy-Model: + type: object + properties: + category: + type: string + self_ref: + $ref: '#/components/schemas/Self-Reference-Model' + RgbColor: + description: RGB three element array with values 0-255. + type: array + items: + type: integer + minimum: 0 + maximum: 255 + minItems: 3 + maxItems: 3 + RgbaColor: + description: RGBA four element array with values 0-255. + type: array + items: + type: integer + minimum: 0 + maximum: 255 + minItems: 4 + maxItems: 4 + HexColor: + description: 'Hex color string, such as #00FF00.' + type: string + pattern: ^#(?:[0-9a-fA-F]{3}){1,2}$ + minLength: 7 + maxLength: 7 + Color: + nullable: true + description: RGB array, RGBA array, or hex string. + oneOf: + - $ref: '#/components/schemas/RgbColor' + - $ref: '#/components/schemas/RgbaColor' + - $ref: '#/components/schemas/HexColor' + #- type: "null" + AnyOfColor: + description: Any of RGB array, RGBA array, or hex string. + anyOf: + - $ref: '#/components/schemas/RgbColor' + - $ref: '#/components/schemas/RgbaColor' + - $ref: '#/components/schemas/HexColor' + OneOfEnumString: + description: oneOf enum strings + oneOf: + - $ref: '#/components/schemas/EnumString1' + - $ref: '#/components/schemas/EnumString2' + EnumString1: + type: string + enum: + - "a" + - "b" + EnumString2: + type: string + enum: + - "c" + - "d" + InnerDictWithProperty: + type: object + properties: + aProperty: + type: object + DictWithAdditionalProperties: + type: object + additionalProperties: + $ref: "#/components/schemas/InnerDictWithProperty" + ParentWithOptionalDict: + type: object + properties: + optionalDict: + $ref: "#/components/schemas/DictWithAdditionalProperties" + #Circular-Reference-Model: + # type: object + # properties: + # size: + # type: integer + # nested: + # $ref: '#/components/schemas/FirstRef' + #FirstRef: + # type: object + # properties: + # category: + # type: string + # self_ref: + # $ref: '#/components/schemas/SecondRef' + #SecondRef: + # type: object + # properties: + # category: + # type: string + # circular_ref: + # $ref: '#/components/schemas/Circular-Reference-Model' + InnerDictWithAdditionalProperties: + type: object + additionalProperties: + $ref: "#/components/schemas/InnerDictWithProperty" + Parent: + type: object + properties: + optionalDict: + $ref: "#/components/schemas/DictWithAdditionalProperties" + IntOrString: + oneOf: + - type: integer + minimum: 10 + - type: string + NullableProperty: + type: object + required: + - id + - name + properties: + id: + type: integer + format: int64 + name: + type: string + nullable: true + pattern: "^[A-Z].*" + MapOfArrayOfModel: + type: object + properties: + shopIdToOrgOnlineLipMap: + additionalProperties: + type: array + items: + $ref: "#/components/schemas/Tag" + ArrayOfArrayOfModel: + type: object + properties: + another_property: + type: array + items: + type: array + items: + $ref: "#/components/schemas/Tag" + PropertyNameCollision: + properties: + _type: + type: string + type: + type: string + type_: + type: string + type: object + ObjectToTestAdditionalProperties: + description: Minimal object + type: object + properties: + property: + description: Property + type: boolean + default: false + Creature: + type: object + required: + - info + - type + properties: + info: + $ref: "#/components/schemas/CreatureInfo" + type: + type: string + discriminator: + propertyName: type + CreatureInfo: + type: object + required: + - name + properties: + name: + type: string + Tiger: + allOf: + - $ref: "#/components/schemas/Tiger" + - type: object + properties: + skill: + type: string + AdditionalPropertiesObject: + type: object + properties: + name: + type: string + additionalProperties: + type: object + AdditionalPropertiesAnyType: + type: object + properties: + name: + type: string + additionalProperties: {} + AdditionalPropertiesWithDescriptionOnly: + type: object + properties: + name: + type: string + additionalProperties: + description: This is what the additional property is + ListOfObjects: + type: array + title: ListOfObjects + items: + $ref: "#/components/schemas/Tag" diff --git a/pom.xml b/pom.xml index 40a65602d3e3..0c2ab2fc7595 100644 --- a/pom.xml +++ b/pom.xml @@ -1222,6 +1222,7 @@ samples/openapi3/client/petstore/python + samples/openapi3/client/petstore/python-pydantic-v2 samples/openapi3/client/petstore/python-aiohttp diff --git a/samples/client/echo_api/python/openapi_client/api/auth_api.py b/samples/client/echo_api/python/openapi_client/api/auth_api.py index 16ee7463aad7..07cdda86f589 100644 --- a/samples/client/echo_api/python/openapi_client/api/auth_api.py +++ b/samples/client/echo_api/python/openapi_client/api/auth_api.py @@ -18,6 +18,7 @@ import warnings from pydantic import validate_arguments, ValidationError +from typing_extensions import Annotated from openapi_client.api_client import ApiClient diff --git a/samples/client/echo_api/python/openapi_client/api/body_api.py b/samples/client/echo_api/python/openapi_client/api/body_api.py index 553feae23a3c..47ed64a58409 100644 --- a/samples/client/echo_api/python/openapi_client/api/body_api.py +++ b/samples/client/echo_api/python/openapi_client/api/body_api.py @@ -18,6 +18,7 @@ import warnings from pydantic import validate_arguments, ValidationError +from typing_extensions import Annotated from typing_extensions import Annotated from pydantic import Field, StrictBytes, StrictStr, conlist diff --git a/samples/client/echo_api/python/openapi_client/api/form_api.py b/samples/client/echo_api/python/openapi_client/api/form_api.py index 0071725761d6..808dd48ffa2a 100644 --- a/samples/client/echo_api/python/openapi_client/api/form_api.py +++ b/samples/client/echo_api/python/openapi_client/api/form_api.py @@ -18,6 +18,7 @@ import warnings from pydantic import validate_arguments, ValidationError +from typing_extensions import Annotated from pydantic import StrictBool, StrictInt, StrictStr diff --git a/samples/client/echo_api/python/openapi_client/api/header_api.py b/samples/client/echo_api/python/openapi_client/api/header_api.py index 7f9dc25354f5..a67fc13b2772 100644 --- a/samples/client/echo_api/python/openapi_client/api/header_api.py +++ b/samples/client/echo_api/python/openapi_client/api/header_api.py @@ -18,6 +18,7 @@ import warnings from pydantic import validate_arguments, ValidationError +from typing_extensions import Annotated from pydantic import StrictBool, StrictInt, StrictStr diff --git a/samples/client/echo_api/python/openapi_client/api/path_api.py b/samples/client/echo_api/python/openapi_client/api/path_api.py index 35d0c6a11b0d..13203624883b 100644 --- a/samples/client/echo_api/python/openapi_client/api/path_api.py +++ b/samples/client/echo_api/python/openapi_client/api/path_api.py @@ -18,6 +18,7 @@ import warnings from pydantic import validate_arguments, ValidationError +from typing_extensions import Annotated from pydantic import StrictInt, StrictStr diff --git a/samples/client/echo_api/python/openapi_client/api/query_api.py b/samples/client/echo_api/python/openapi_client/api/query_api.py index 09d55efd2f56..59465cdc0cc6 100644 --- a/samples/client/echo_api/python/openapi_client/api/query_api.py +++ b/samples/client/echo_api/python/openapi_client/api/query_api.py @@ -18,6 +18,7 @@ import warnings from pydantic import validate_arguments, ValidationError +from typing_extensions import Annotated from datetime import date, datetime diff --git a/samples/client/echo_api/python/openapi_client/models/bird.py b/samples/client/echo_api/python/openapi_client/models/bird.py index 77887a53120d..7afefcc9e596 100644 --- a/samples/client/echo_api/python/openapi_client/models/bird.py +++ b/samples/client/echo_api/python/openapi_client/models/bird.py @@ -30,8 +30,8 @@ class Bird(BaseModel): color: Optional[StrictStr] = None __properties = ["size", "color"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/client/echo_api/python/openapi_client/models/category.py b/samples/client/echo_api/python/openapi_client/models/category.py index ee8e5c258ae9..4a9de5bdfb04 100644 --- a/samples/client/echo_api/python/openapi_client/models/category.py +++ b/samples/client/echo_api/python/openapi_client/models/category.py @@ -30,8 +30,8 @@ class Category(BaseModel): name: Optional[StrictStr] = None __properties = ["id", "name"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/client/echo_api/python/openapi_client/models/data_query.py b/samples/client/echo_api/python/openapi_client/models/data_query.py index af8078549f1f..6dc4e225ae91 100644 --- a/samples/client/echo_api/python/openapi_client/models/data_query.py +++ b/samples/client/echo_api/python/openapi_client/models/data_query.py @@ -32,8 +32,8 @@ class DataQuery(Query): var_date: Optional[datetime] = Field(None, alias="date", description="A date") __properties = ["id", "outcomes", "suffix", "text", "date"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/client/echo_api/python/openapi_client/models/default_value.py b/samples/client/echo_api/python/openapi_client/models/default_value.py index a73193247fd1..486612d7ce5a 100644 --- a/samples/client/echo_api/python/openapi_client/models/default_value.py +++ b/samples/client/echo_api/python/openapi_client/models/default_value.py @@ -48,8 +48,8 @@ def array_string_enum_default_validate_enum(cls, value): raise ValueError("each list item must be one of ('success', 'failure', 'unclassified')") return value + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/client/echo_api/python/openapi_client/models/number_properties_only.py b/samples/client/echo_api/python/openapi_client/models/number_properties_only.py index 10bb3a590a21..b8a367516306 100644 --- a/samples/client/echo_api/python/openapi_client/models/number_properties_only.py +++ b/samples/client/echo_api/python/openapi_client/models/number_properties_only.py @@ -31,8 +31,8 @@ class NumberPropertiesOnly(BaseModel): double: Optional[Union[confloat(le=50.2, ge=0.8, strict=True), conint(le=50, ge=1, strict=True)]] = None __properties = ["number", "float", "double"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/client/echo_api/python/openapi_client/models/pet.py b/samples/client/echo_api/python/openapi_client/models/pet.py index 3a40ddc03215..b758fbf5a0ff 100644 --- a/samples/client/echo_api/python/openapi_client/models/pet.py +++ b/samples/client/echo_api/python/openapi_client/models/pet.py @@ -46,8 +46,8 @@ def status_validate_enum(cls, value): raise ValueError("must be one of enum values ('available', 'pending', 'sold')") return value + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/client/echo_api/python/openapi_client/models/query.py b/samples/client/echo_api/python/openapi_client/models/query.py index 02e4233d513a..9342db8bc355 100644 --- a/samples/client/echo_api/python/openapi_client/models/query.py +++ b/samples/client/echo_api/python/openapi_client/models/query.py @@ -41,8 +41,8 @@ def outcomes_validate_enum(cls, value): raise ValueError("each list item must be one of ('SUCCESS', 'FAILURE', 'SKIPPED')") return value + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/client/echo_api/python/openapi_client/models/tag.py b/samples/client/echo_api/python/openapi_client/models/tag.py index 66a39adff29c..28b06fa6bff9 100644 --- a/samples/client/echo_api/python/openapi_client/models/tag.py +++ b/samples/client/echo_api/python/openapi_client/models/tag.py @@ -30,8 +30,8 @@ class Tag(BaseModel): name: Optional[StrictStr] = None __properties = ["id", "name"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py b/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py index 42e1101ec022..ef0865cb0fbf 100644 --- a/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py +++ b/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py @@ -32,8 +32,8 @@ class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter(BaseMod name: Optional[StrictStr] = None __properties = ["size", "color", "id", "name"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py b/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py index 1bff80a6df1c..78c5e72410de 100644 --- a/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py +++ b/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py @@ -29,8 +29,8 @@ class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(BaseModel): values: Optional[conlist(StrictStr)] = None __properties = ["values"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/another_fake_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/another_fake_api.py index 140dcf434609..0cc79b2c2969 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/another_fake_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/another_fake_api.py @@ -17,6 +17,7 @@ import warnings from pydantic import validate_arguments, ValidationError +from typing_extensions import Annotated from typing import overload, Optional, Union, Awaitable from typing_extensions import Annotated diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/default_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/default_api.py index be02dd6b8a7e..69cfa5ebedf5 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/default_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/default_api.py @@ -17,6 +17,7 @@ import warnings from pydantic import validate_arguments, ValidationError +from typing_extensions import Annotated from typing import overload, Optional, Union, Awaitable from petstore_api.models.foo_get_default_response import FooGetDefaultResponse diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py index 3c0ef29b788f..a7214278c468 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py @@ -17,6 +17,7 @@ import warnings from pydantic import validate_arguments, ValidationError +from typing_extensions import Annotated from typing import overload, Optional, Union, Awaitable from typing_extensions import Annotated diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_classname_tags123_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_classname_tags123_api.py index 6b9c88c1212f..6db726c767b1 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_classname_tags123_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_classname_tags123_api.py @@ -17,6 +17,7 @@ import warnings from pydantic import validate_arguments, ValidationError +from typing_extensions import Annotated from typing import overload, Optional, Union, Awaitable from typing_extensions import Annotated diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py index 72e29e7d0429..d37dc1d746fd 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py @@ -17,6 +17,7 @@ import warnings from pydantic import validate_arguments, ValidationError +from typing_extensions import Annotated from typing import overload, Optional, Union, Awaitable from typing_extensions import Annotated diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py index e52b31ee5e13..1e3bf888bc21 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py @@ -17,6 +17,7 @@ import warnings from pydantic import validate_arguments, ValidationError +from typing_extensions import Annotated from typing import overload, Optional, Union, Awaitable from typing_extensions import Annotated diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py index 3c059d73339f..58b448c254bf 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py @@ -17,6 +17,7 @@ import warnings from pydantic import validate_arguments, ValidationError +from typing_extensions import Annotated from typing import overload, Optional, Union, Awaitable from typing_extensions import Annotated diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py index 0441dfd99e92..c0d9294a9094 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py @@ -29,8 +29,8 @@ class AdditionalPropertiesAnyType(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["name"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py index c53af3e2ca67..ad1308c084a5 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py @@ -29,8 +29,8 @@ class AdditionalPropertiesClass(BaseModel): map_of_map_property: Optional[Dict[str, Dict[str, StrictStr]]] = None __properties = ["map_property", "map_of_map_property"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py index cff0e89b0568..b3e50b40923b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py @@ -29,8 +29,8 @@ class AdditionalPropertiesObject(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["name"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py index 17d6c461ed1b..feedf9a744a7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py @@ -29,8 +29,8 @@ class AdditionalPropertiesWithDescriptionOnly(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["name"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py index c5d066463f64..f624188049d7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py @@ -30,8 +30,8 @@ class AllOfWithSingleRef(BaseModel): single_ref_type: Optional[SingleRefType] = Field(None, alias="SingleRefType") __properties = ["username", "SingleRefType"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py index 18738e6051bc..82f6b724d70e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py @@ -29,8 +29,8 @@ class Animal(BaseModel): color: Optional[StrictStr] = 'red' __properties = ["className", "color"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py index b422650686fd..79eece679cda 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py @@ -21,7 +21,6 @@ from typing import List, Optional from pydantic import BaseModel, Field, StrictStr, ValidationError, conint, conlist, constr, validator from typing import Union, Any, List, TYPE_CHECKING -from pydantic import StrictStr, Field ANYOFCOLOR_ANY_OF_SCHEMAS = ["List[int]", "str"] @@ -42,6 +41,7 @@ class AnyOfColor(BaseModel): actual_instance: Any any_of_schemas: List[str] = Field(ANYOFCOLOR_ANY_OF_SCHEMAS, const=True) + """Pydantic configuration""" class Config: validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py index 1254f6789a8c..30274e51269a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py @@ -23,7 +23,6 @@ from petstore_api.models.basque_pig import BasquePig from petstore_api.models.danish_pig import DanishPig from typing import Union, Any, List, TYPE_CHECKING -from pydantic import StrictStr, Field ANYOFPIG_ANY_OF_SCHEMAS = ["BasquePig", "DanishPig"] @@ -42,6 +41,7 @@ class AnyOfPig(BaseModel): actual_instance: Any any_of_schemas: List[str] = Field(ANYOFPIG_ANY_OF_SCHEMAS, const=True) + """Pydantic configuration""" class Config: validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/api_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/api_response.py index 2c58b8b9ccb8..4f5cc095e3c2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/api_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/api_response.py @@ -30,8 +30,8 @@ class ApiResponse(BaseModel): message: Optional[StrictStr] = None __properties = ["code", "type", "message"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py index 6f67b220ccf1..bd23f1c16cf1 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py @@ -29,8 +29,8 @@ class ArrayOfArrayOfModel(BaseModel): another_property: Optional[conlist(conlist(Tag))] = None __properties = ["another_property"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py index 8ce909858b18..eef48c4f0693 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py @@ -28,8 +28,8 @@ class ArrayOfArrayOfNumberOnly(BaseModel): array_array_number: Optional[conlist(conlist(float))] = Field(None, alias="ArrayArrayNumber") __properties = ["ArrayArrayNumber"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py index 768ea5ef0baf..549faf416bd4 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py @@ -28,8 +28,8 @@ class ArrayOfNumberOnly(BaseModel): array_number: Optional[conlist(float)] = Field(None, alias="ArrayNumber") __properties = ["ArrayNumber"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py index 8ec1a1ad67ef..24faffd03434 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py @@ -31,8 +31,8 @@ class ArrayTest(BaseModel): array_array_of_model: Optional[conlist(conlist(ReadOnlyFirst))] = None __properties = ["array_of_string", "array_array_of_integer", "array_array_of_model"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py index 5683a73a3bfc..c54cec9359da 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py @@ -29,8 +29,8 @@ class BasquePig(BaseModel): color: StrictStr = Field(...) __properties = ["className", "color"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py index 2bb4435563b2..72c4d2e044e6 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py @@ -33,8 +33,8 @@ class Capitalization(BaseModel): att_name: Optional[StrictStr] = Field(None, alias="ATT_NAME", description="Name of the pet ") __properties = ["smallCamel", "CapitalCamel", "small_Snake", "Capital_Snake", "SCA_ETH_Flow_Points", "ATT_NAME"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py index efff0890a41a..096693b202e7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py @@ -29,8 +29,8 @@ class Cat(Animal): declawed: Optional[StrictBool] = None __properties = ["className", "color", "declawed"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py index 86a10a8683cf..2fd4312fad55 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py @@ -29,8 +29,8 @@ class Category(BaseModel): name: StrictStr = Field(...) __properties = ["id", "name"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py index 6a9956f5af3b..e427ea092423 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py @@ -29,8 +29,8 @@ class CircularReferenceModel(BaseModel): nested: Optional[FirstRef] = None __properties = ["size", "nested"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py index d345924958ee..ab7646983d9e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py @@ -28,8 +28,8 @@ class ClassModel(BaseModel): var_class: Optional[StrictStr] = Field(None, alias="_class") __properties = ["_class"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py index 01f60acef507..dea9123d8623 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py @@ -28,8 +28,8 @@ class Client(BaseModel): client: Optional[StrictStr] = None __properties = ["client"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py index 4dee9419ab7f..574093092a01 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py @@ -21,7 +21,6 @@ from typing import Any, List, Optional from pydantic import BaseModel, Field, StrictStr, ValidationError, conint, conlist, constr, validator from typing import Union, Any, List, TYPE_CHECKING -from pydantic import StrictStr, Field COLOR_ONE_OF_SCHEMAS = ["List[int]", "str"] @@ -39,8 +38,10 @@ class Color(BaseModel): actual_instance: Union[List[int], str] else: actual_instance: Any + one_of_schemas: List[str] = Field(COLOR_ONE_OF_SCHEMAS, const=True) + """Pydantic configuration""" class Config: validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py index dc2d94ece4cb..2567fa7565f9 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py @@ -30,8 +30,8 @@ class Creature(BaseModel): type: StrictStr = Field(...) __properties = ["info", "type"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py index 327ce9bc4fbc..f287fb975013 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py @@ -28,8 +28,8 @@ class CreatureInfo(BaseModel): name: StrictStr = Field(...) __properties = ["name"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py index cfb24a7d5857..47321e4adb15 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py @@ -29,8 +29,8 @@ class DanishPig(BaseModel): size: StrictInt = Field(...) __properties = ["className", "size"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py index 9ce72f88d48b..0615eb18e66a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py @@ -28,8 +28,8 @@ class DeprecatedObject(BaseModel): name: Optional[StrictStr] = None __properties = ["name"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py index f0533a50e495..2b35e739c1a0 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py @@ -29,8 +29,8 @@ class Dog(Animal): breed: Optional[StrictStr] = None __properties = ["className", "color", "breed"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py index 8e4db12e5c92..8b0242b6cf16 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py @@ -29,8 +29,8 @@ class DummyModel(BaseModel): self_ref: Optional[SelfReferenceModel] = None __properties = ["category", "self_ref"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py index 5f3363b0a564..445292b697e4 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py @@ -50,8 +50,8 @@ def array_enum_validate_enum(cls, value): raise ValueError("each list item must be one of ('fish', 'crab')") return value + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py index b3899720fd30..c8caa42c35de 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py @@ -87,8 +87,8 @@ def enum_number_validate_enum(cls, value): raise ValueError("must be one of enum values (1.1, -1.2)") return value + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py index c87e30f73bf2..8e7dd176489e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py @@ -28,8 +28,8 @@ class File(BaseModel): source_uri: Optional[StrictStr] = Field(None, alias="sourceURI", description="Test capitalization") __properties = ["sourceURI"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py index 32058bd16fa0..a4d41a8cd7d6 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py @@ -30,8 +30,8 @@ class FileSchemaTestClass(BaseModel): files: Optional[conlist(File)] = None __properties = ["file", "files"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py index ace84a5bcb84..80663edce859 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py @@ -29,8 +29,8 @@ class FirstRef(BaseModel): self_ref: Optional[SecondRef] = None __properties = ["category", "self_ref"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py index fc58b159e5f5..44d47be8e6ef 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py @@ -28,8 +28,8 @@ class Foo(BaseModel): bar: Optional[StrictStr] = 'bar' __properties = ["bar"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py index e792358dc002..67548a902f31 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py @@ -29,8 +29,8 @@ class FooGetDefaultResponse(BaseModel): string: Optional[Foo] = None __properties = ["string"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py index a0abc32a6598..139dbeeed32b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py @@ -84,8 +84,8 @@ def pattern_with_digits_and_delimiter_validate_regular_expression(cls, value): raise ValueError(r"must validate the regular expression /^image_\d{1,3}$/i") return value + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py index 5a6dd7857d12..cfacff0a12ab 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py @@ -29,8 +29,8 @@ class HasOnlyReadOnly(BaseModel): foo: Optional[StrictStr] = None __properties = ["bar", "foo"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py index 02405bea384e..4fadb6f6caa6 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py @@ -28,8 +28,8 @@ class HealthCheckResult(BaseModel): nullable_message: Optional[StrictStr] = Field(None, alias="NullableMessage") __properties = ["NullableMessage"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py index 9f134186b6a6..3576f85dde55 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py @@ -28,8 +28,8 @@ class InnerDictWithProperty(BaseModel): a_property: Optional[Dict[str, Any]] = Field(None, alias="aProperty") __properties = ["aProperty"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py index 5d5de47e305a..574c73549525 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py @@ -21,7 +21,6 @@ from typing import Any, List, Optional from pydantic import BaseModel, Field, StrictStr, ValidationError, conint, validator from typing import Union, Any, List, TYPE_CHECKING -from pydantic import StrictStr, Field INTORSTRING_ONE_OF_SCHEMAS = ["int", "str"] @@ -37,8 +36,10 @@ class IntOrString(BaseModel): actual_instance: Union[int, str] else: actual_instance: Any + one_of_schemas: List[str] = Field(INTORSTRING_ONE_OF_SCHEMAS, const=True) + """Pydantic configuration""" class Config: validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list.py index 4c6868146ad0..e77c678ec09e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list.py @@ -28,8 +28,8 @@ class List(BaseModel): var_123_list: Optional[StrictStr] = Field(None, alias="123-list") __properties = ["123-list"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py index 444732620ab5..4ca8b1aadd04 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py @@ -29,8 +29,8 @@ class MapOfArrayOfModel(BaseModel): shop_id_to_org_online_lip_map: Optional[Dict[str, conlist(Tag)]] = Field(None, alias="shopIdToOrgOnlineLipMap") __properties = ["shopIdToOrgOnlineLipMap"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py index 42e47b1cb4f3..c11ef8376458 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py @@ -41,8 +41,8 @@ def map_of_enum_string_validate_enum(cls, value): raise ValueError("must be one of enum values ('UPPER', 'lower')") return value + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py index 03f306af535f..92d55f68bbe7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -31,8 +31,8 @@ class MixedPropertiesAndAdditionalPropertiesClass(BaseModel): map: Optional[Dict[str, Animal]] = None __properties = ["uuid", "dateTime", "map"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py index f129e4dafe80..581bfcd15fe0 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py @@ -29,8 +29,8 @@ class Model200Response(BaseModel): var_class: Optional[StrictStr] = Field(None, alias="class") __properties = ["name", "class"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py index 1d2b0266d343..cc9d76d869e6 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py @@ -28,8 +28,8 @@ class ModelReturn(BaseModel): var_return: Optional[StrictInt] = Field(None, alias="return") __properties = ["return"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py index 5284db112e9b..f0c88a09eee2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py @@ -31,8 +31,8 @@ class Name(BaseModel): var_123_number: Optional[StrictInt] = Field(None, alias="123Number") __properties = ["name", "snake_case", "property", "123Number"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py index f26aac9ff07d..f960d26b6611 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py @@ -41,8 +41,8 @@ class NullableClass(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["required_integer_prop", "integer_prop", "number_prop", "boolean_prop", "string_prop", "date_prop", "datetime_prop", "array_nullable_prop", "array_and_items_nullable_prop", "array_items_nullable", "object_nullable_prop", "object_and_items_nullable_prop", "object_items_nullable"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py index 2312fbbbf5fd..616e4002fafa 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py @@ -39,8 +39,8 @@ def name_validate_regular_expression(cls, value): raise ValueError(r"must validate the regular expression /^[A-Z].*/") return value + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py index 6549b2617824..3092648bbca2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py @@ -28,8 +28,8 @@ class NumberOnly(BaseModel): just_number: Optional[float] = Field(None, alias="JustNumber") __properties = ["JustNumber"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py index f609e06f6a9c..55fa9ad5da1c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py @@ -28,8 +28,8 @@ class ObjectToTestAdditionalProperties(BaseModel): var_property: Optional[StrictBool] = Field(False, alias="property", description="Property") __properties = ["property"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py index 421206c1bc79..653e292cf06a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py @@ -32,8 +32,8 @@ class ObjectWithDeprecatedFields(BaseModel): bars: Optional[conlist(StrictStr)] = None __properties = ["uuid", "id", "deprecatedRef", "bars"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/one_of_enum_string.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/one_of_enum_string.py index d7ae93ccb6a8..f4b18189e6f9 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/one_of_enum_string.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/one_of_enum_string.py @@ -23,7 +23,6 @@ from petstore_api.models.enum_string1 import EnumString1 from petstore_api.models.enum_string2 import EnumString2 from typing import Union, Any, List, TYPE_CHECKING -from pydantic import StrictStr, Field ONEOFENUMSTRING_ONE_OF_SCHEMAS = ["EnumString1", "EnumString2"] @@ -39,8 +38,10 @@ class OneOfEnumString(BaseModel): actual_instance: Union[EnumString1, EnumString2] else: actual_instance: Any + one_of_schemas: List[str] = Field(ONEOFENUMSTRING_ONE_OF_SCHEMAS, const=True) + """Pydantic configuration""" class Config: validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py index da726d2096dc..510d0eac306a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py @@ -43,8 +43,8 @@ def status_validate_enum(cls, value): raise ValueError("must be one of enum values ('placed', 'approved', 'delivered')") return value + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py index 63627c3d0fde..1b6f4f5cb35d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py @@ -30,8 +30,8 @@ class OuterComposite(BaseModel): my_boolean: Optional[StrictBool] = None __properties = ["my_number", "my_string", "my_boolean"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py index c4ae68e5510f..58959f5b17bb 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py @@ -31,8 +31,8 @@ class OuterObjectWithEnumProperty(BaseModel): value: OuterEnumInteger = Field(...) __properties = ["str_value", "value"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py index a3105aff6821..cc52de56a3c0 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py @@ -29,8 +29,8 @@ class Parent(BaseModel): optional_dict: Optional[Dict[str, InnerDictWithProperty]] = Field(None, alias="optionalDict") __properties = ["optionalDict"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py index 253747b3abd7..b910f83b8eae 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py @@ -29,8 +29,8 @@ class ParentWithOptionalDict(BaseModel): optional_dict: Optional[Dict[str, InnerDictWithProperty]] = Field(None, alias="optionalDict") __properties = ["optionalDict"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py index e45fdc4a27d7..06e8bc38ccc4 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py @@ -45,8 +45,8 @@ def status_validate_enum(cls, value): raise ValueError("must be one of enum values ('available', 'pending', 'sold')") return value + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py index 1cb002bf6f7d..8d6478cb2cc5 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py @@ -23,7 +23,6 @@ from petstore_api.models.basque_pig import BasquePig from petstore_api.models.danish_pig import DanishPig from typing import Union, Any, List, TYPE_CHECKING -from pydantic import StrictStr, Field PIG_ONE_OF_SCHEMAS = ["BasquePig", "DanishPig"] @@ -39,8 +38,10 @@ class Pig(BaseModel): actual_instance: Union[BasquePig, DanishPig] else: actual_instance: Any + one_of_schemas: List[str] = Field(PIG_ONE_OF_SCHEMAS, const=True) + """Pydantic configuration""" class Config: validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py index ed45ecdf74c4..c6118a2fabd9 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py @@ -30,8 +30,8 @@ class PropertyNameCollision(BaseModel): type_: Optional[StrictStr] = None __properties = ["_type", "type", "type_"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py index da66589ee79c..892f302f304e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py @@ -29,8 +29,8 @@ class ReadOnlyFirst(BaseModel): baz: Optional[StrictStr] = None __properties = ["bar", "baz"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py index 0c4f70eb9395..51d6b5980c0b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py @@ -29,8 +29,8 @@ class SecondRef(BaseModel): circular_ref: Optional[CircularReferenceModel] = None __properties = ["category", "circular_ref"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py index f7470db995e6..c1a61f7ea998 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py @@ -29,8 +29,8 @@ class SelfReferenceModel(BaseModel): nested: Optional[DummyModel] = None __properties = ["size", "nested"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py index 43e57ff7b7bd..d847e05341bd 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py @@ -28,8 +28,8 @@ class SpecialModelName(BaseModel): special_property_name: Optional[StrictInt] = Field(None, alias="$special[property.name]") __properties = ["$special[property.name]"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py index f8841f7a4cce..886252dde6ff 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py @@ -41,8 +41,8 @@ def var_schema_validate_enum(cls, value): raise ValueError("must be one of enum values ('available', 'pending', 'sold')") return value + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py index 45605d239331..a593806f058c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py @@ -29,8 +29,8 @@ class Tag(BaseModel): name: Optional[StrictStr] = None __properties = ["id", "name"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py index 88b2f3c6a04f..bf1111c222bc 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py @@ -28,8 +28,8 @@ class Tiger(BaseModel): skill: Optional[StrictStr] = None __properties = ["skill"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py index 5c09a897c702..3f04a229ede9 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py @@ -35,8 +35,8 @@ class User(BaseModel): user_status: Optional[StrictInt] = Field(None, alias="userStatus", description="User Status") __properties = ["id", "username", "firstName", "lastName", "email", "password", "phone", "userStatus"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py index 0268402b5f4c..9af30656878d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py @@ -32,8 +32,8 @@ class WithNestedOneOf(BaseModel): nested_oneof_enum_string: Optional[OneOfEnumString] = None __properties = ["size", "nested_pig", "nested_oneof_enum_string"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/.github/workflows/python.yml b/samples/openapi3/client/petstore/python-pydantic-v2/.github/workflows/python.yml new file mode 100644 index 000000000000..6752d090a969 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/.github/workflows/python.yml @@ -0,0 +1,37 @@ +# NOTE: This file is auto generated by OpenAPI Generator. +# URL: https://openapi-generator.tech +# +# ref: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: petstore_api Python package + +on: [push, pull_request] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/.gitignore b/samples/openapi3/client/petstore/python-pydantic-v2/.gitignore new file mode 100755 index 000000000000..43995bd42fa2 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/.gitignore @@ -0,0 +1,66 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ +venv/ +.venv/ +.python-version +.pytest_cache + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +#Ipython Notebook +.ipynb_checkpoints diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/.gitlab-ci.yml b/samples/openapi3/client/petstore/python-pydantic-v2/.gitlab-ci.yml new file mode 100755 index 000000000000..1d94e3846964 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/.gitlab-ci.yml @@ -0,0 +1,25 @@ +# NOTE: This file is auto generated by OpenAPI Generator. +# URL: https://openapi-generator.tech +# +# ref: https://docs.gitlab.com/ee/ci/README.html +# ref: https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Python.gitlab-ci.yml + +stages: + - test + +.pytest: + stage: test + script: + - pip install -r requirements.txt + - pip install -r test-requirements.txt + - pytest --cov=petstore_api + +pytest-3.7: + extends: .pytest + image: python:3.7-alpine +pytest-3.8: + extends: .pytest + image: python:3.8-alpine +pytest-3.9: + extends: .pytest + image: python:3.9-alpine \ No newline at end of file diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/.openapi-generator-ignore b/samples/openapi3/client/petstore/python-pydantic-v2/.openapi-generator-ignore new file mode 100755 index 000000000000..1e66827c8f8d --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/.openapi-generator-ignore @@ -0,0 +1,24 @@ +# 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 +tox.ini diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-pydantic-v2/.openapi-generator/FILES new file mode 100755 index 000000000000..6aacf0a81498 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/.openapi-generator/FILES @@ -0,0 +1,186 @@ +.github/workflows/python.yml +.gitignore +.gitlab-ci.yml +.travis.yml +README.md +docs/AdditionalPropertiesAnyType.md +docs/AdditionalPropertiesClass.md +docs/AdditionalPropertiesObject.md +docs/AdditionalPropertiesWithDescriptionOnly.md +docs/AllOfWithSingleRef.md +docs/Animal.md +docs/AnotherFakeApi.md +docs/AnyOfColor.md +docs/AnyOfPig.md +docs/ApiResponse.md +docs/ArrayOfArrayOfModel.md +docs/ArrayOfArrayOfNumberOnly.md +docs/ArrayOfNumberOnly.md +docs/ArrayTest.md +docs/BasquePig.md +docs/Capitalization.md +docs/Cat.md +docs/Category.md +docs/ClassModel.md +docs/Client.md +docs/Color.md +docs/Creature.md +docs/CreatureInfo.md +docs/DanishPig.md +docs/DefaultApi.md +docs/DeprecatedObject.md +docs/Dog.md +docs/DummyModel.md +docs/EnumArrays.md +docs/EnumClass.md +docs/EnumString1.md +docs/EnumString2.md +docs/EnumTest.md +docs/FakeApi.md +docs/FakeClassnameTags123Api.md +docs/File.md +docs/FileSchemaTestClass.md +docs/Foo.md +docs/FooGetDefaultResponse.md +docs/FormatTest.md +docs/HasOnlyReadOnly.md +docs/HealthCheckResult.md +docs/InnerDictWithProperty.md +docs/IntOrString.md +docs/List.md +docs/MapOfArrayOfModel.md +docs/MapTest.md +docs/MixedPropertiesAndAdditionalPropertiesClass.md +docs/Model200Response.md +docs/ModelReturn.md +docs/Name.md +docs/NullableClass.md +docs/NullableProperty.md +docs/NumberOnly.md +docs/ObjectToTestAdditionalProperties.md +docs/ObjectWithDeprecatedFields.md +docs/OneOfEnumString.md +docs/Order.md +docs/OuterComposite.md +docs/OuterEnum.md +docs/OuterEnumDefaultValue.md +docs/OuterEnumInteger.md +docs/OuterEnumIntegerDefaultValue.md +docs/OuterObjectWithEnumProperty.md +docs/Parent.md +docs/ParentWithOptionalDict.md +docs/Pet.md +docs/PetApi.md +docs/Pig.md +docs/PropertyNameCollision.md +docs/ReadOnlyFirst.md +docs/SelfReferenceModel.md +docs/SingleRefType.md +docs/SpecialCharacterEnum.md +docs/SpecialModelName.md +docs/SpecialName.md +docs/StoreApi.md +docs/Tag.md +docs/Tiger.md +docs/User.md +docs/UserApi.md +docs/WithNestedOneOf.md +git_push.sh +petstore_api/__init__.py +petstore_api/api/__init__.py +petstore_api/api/another_fake_api.py +petstore_api/api/default_api.py +petstore_api/api/fake_api.py +petstore_api/api/fake_classname_tags123_api.py +petstore_api/api/pet_api.py +petstore_api/api/store_api.py +petstore_api/api/user_api.py +petstore_api/api_client.py +petstore_api/api_response.py +petstore_api/configuration.py +petstore_api/exceptions.py +petstore_api/models/__init__.py +petstore_api/models/additional_properties_any_type.py +petstore_api/models/additional_properties_class.py +petstore_api/models/additional_properties_object.py +petstore_api/models/additional_properties_with_description_only.py +petstore_api/models/all_of_with_single_ref.py +petstore_api/models/animal.py +petstore_api/models/any_of_color.py +petstore_api/models/any_of_pig.py +petstore_api/models/api_response.py +petstore_api/models/array_of_array_of_model.py +petstore_api/models/array_of_array_of_number_only.py +petstore_api/models/array_of_number_only.py +petstore_api/models/array_test.py +petstore_api/models/basque_pig.py +petstore_api/models/capitalization.py +petstore_api/models/cat.py +petstore_api/models/category.py +petstore_api/models/class_model.py +petstore_api/models/client.py +petstore_api/models/color.py +petstore_api/models/creature.py +petstore_api/models/creature_info.py +petstore_api/models/danish_pig.py +petstore_api/models/deprecated_object.py +petstore_api/models/dog.py +petstore_api/models/dummy_model.py +petstore_api/models/enum_arrays.py +petstore_api/models/enum_class.py +petstore_api/models/enum_string1.py +petstore_api/models/enum_string2.py +petstore_api/models/enum_test.py +petstore_api/models/file.py +petstore_api/models/file_schema_test_class.py +petstore_api/models/foo.py +petstore_api/models/foo_get_default_response.py +petstore_api/models/format_test.py +petstore_api/models/has_only_read_only.py +petstore_api/models/health_check_result.py +petstore_api/models/inner_dict_with_property.py +petstore_api/models/int_or_string.py +petstore_api/models/list.py +petstore_api/models/map_of_array_of_model.py +petstore_api/models/map_test.py +petstore_api/models/mixed_properties_and_additional_properties_class.py +petstore_api/models/model200_response.py +petstore_api/models/model_return.py +petstore_api/models/name.py +petstore_api/models/nullable_class.py +petstore_api/models/nullable_property.py +petstore_api/models/number_only.py +petstore_api/models/object_to_test_additional_properties.py +petstore_api/models/object_with_deprecated_fields.py +petstore_api/models/one_of_enum_string.py +petstore_api/models/order.py +petstore_api/models/outer_composite.py +petstore_api/models/outer_enum.py +petstore_api/models/outer_enum_default_value.py +petstore_api/models/outer_enum_integer.py +petstore_api/models/outer_enum_integer_default_value.py +petstore_api/models/outer_object_with_enum_property.py +petstore_api/models/parent.py +petstore_api/models/parent_with_optional_dict.py +petstore_api/models/pet.py +petstore_api/models/pig.py +petstore_api/models/property_name_collision.py +petstore_api/models/read_only_first.py +petstore_api/models/self_reference_model.py +petstore_api/models/single_ref_type.py +petstore_api/models/special_character_enum.py +petstore_api/models/special_model_name.py +petstore_api/models/special_name.py +petstore_api/models/tag.py +petstore_api/models/tiger.py +petstore_api/models/user.py +petstore_api/models/with_nested_one_of.py +petstore_api/py.typed +petstore_api/rest.py +petstore_api/signing.py +pyproject.toml +requirements.txt +setup.cfg +setup.py +test-requirements.txt +test/__init__.py diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/.openapi-generator/VERSION b/samples/openapi3/client/petstore/python-pydantic-v2/.openapi-generator/VERSION new file mode 100755 index 000000000000..44bad91b171c --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.0.1-SNAPSHOT \ No newline at end of file diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/.travis.yml b/samples/openapi3/client/petstore/python-pydantic-v2/.travis.yml new file mode 100755 index 000000000000..bb28138c5b1a --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/.travis.yml @@ -0,0 +1,17 @@ +# ref: https://docs.travis-ci.com/user/languages/python +language: python +python: + - "3.7" + - "3.8" + - "3.9" + - "3.10" + - "3.11" + # uncomment the following if needed + #- "3.11-dev" # 3.11 development branch + #- "nightly" # nightly build +# command to install dependencies +install: + - "pip install -r requirements.txt" + - "pip install -r test-requirements.txt" +# command to run tests +script: pytest --cov=petstore_api diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/Makefile b/samples/openapi3/client/petstore/python-pydantic-v2/Makefile new file mode 100755 index 000000000000..739b58747458 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/Makefile @@ -0,0 +1,21 @@ + #!/bin/bash + +REQUIREMENTS_FILE=dev-requirements.txt +REQUIREMENTS_OUT=dev-requirements.txt.log +SETUP_OUT=*.egg-info +VENV=.venv + +clean: + rm -rf $(REQUIREMENTS_OUT) + rm -rf $(SETUP_OUT) + rm -rf $(VENV) + rm -rf .tox + rm -rf .coverage + find . -name "*.py[oc]" -delete + find . -name "__pycache__" -delete + +test: clean + bash ./test_python3.sh + +test-all: clean + bash ./test_python3.sh diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/README.md b/samples/openapi3/client/petstore/python-pydantic-v2/README.md new file mode 100755 index 000000000000..044c74065b1c --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/README.md @@ -0,0 +1,263 @@ +# petstore-api +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: + +- API version: 1.0.0 +- Package version: 1.0.0 +- Build package: org.openapitools.codegen.languages.PythonClientCodegen + +## Requirements. + +Python 3.7+ + +## Installation & Usage +### pip install + +If the python package is hosted on a repository, you can install directly using: + +```sh +pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git +``` +(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git`) + +Then import the package: +```python +import petstore_api +``` + +### Setuptools + +Install via [Setuptools](http://pypi.python.org/pypi/setuptools). + +```sh +python setup.py install --user +``` +(or `sudo python setup.py install` to install the package for all users) + +Then import the package: +```python +import petstore_api +``` + +### Tests + +Execute `pytest` to run the tests. + +## Getting Started + +Please follow the [installation procedure](#installation--usage) and then run the following: + +```python +import datetime +import time +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.AnotherFakeApi(api_client) + client = petstore_api.Client() # Client | client model + + try: + # To test special tags + api_response = api_instance.call_123_test_special_tags(client) + print("The response of AnotherFakeApi->call_123_test_special_tags:\n") + pprint(api_response) + except ApiException as e: + print("Exception when calling AnotherFakeApi->call_123_test_special_tags: %s\n" % e) + +``` + +## Documentation for API Endpoints + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*AnotherFakeApi* | [**call_123_test_special_tags**](docs/AnotherFakeApi.md#call_123_test_special_tags) | **PATCH** /another-fake/dummy | To test special tags +*DefaultApi* | [**foo_get**](docs/DefaultApi.md#foo_get) | **GET** /foo | +*FakeApi* | [**fake_any_type_request_body**](docs/FakeApi.md#fake_any_type_request_body) | **POST** /fake/any_type_body | test any type request body +*FakeApi* | [**fake_enum_ref_query_parameter**](docs/FakeApi.md#fake_enum_ref_query_parameter) | **GET** /fake/enum_ref_query_parameter | test enum reference query parameter +*FakeApi* | [**fake_health_get**](docs/FakeApi.md#fake_health_get) | **GET** /fake/health | Health check endpoint +*FakeApi* | [**fake_http_signature_test**](docs/FakeApi.md#fake_http_signature_test) | **GET** /fake/http-signature-test | test http signature authentication +*FakeApi* | [**fake_outer_boolean_serialize**](docs/FakeApi.md#fake_outer_boolean_serialize) | **POST** /fake/outer/boolean | +*FakeApi* | [**fake_outer_composite_serialize**](docs/FakeApi.md#fake_outer_composite_serialize) | **POST** /fake/outer/composite | +*FakeApi* | [**fake_outer_number_serialize**](docs/FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number | +*FakeApi* | [**fake_outer_string_serialize**](docs/FakeApi.md#fake_outer_string_serialize) | **POST** /fake/outer/string | +*FakeApi* | [**fake_property_enum_integer_serialize**](docs/FakeApi.md#fake_property_enum_integer_serialize) | **POST** /fake/property/enum-int | +*FakeApi* | [**fake_return_list_of_objects**](docs/FakeApi.md#fake_return_list_of_objects) | **GET** /fake/return_list_of_object | test returning list of objects +*FakeApi* | [**fake_uuid_example**](docs/FakeApi.md#fake_uuid_example) | **GET** /fake/uuid_example | test uuid example +*FakeApi* | [**test_body_with_binary**](docs/FakeApi.md#test_body_with_binary) | **PUT** /fake/body-with-binary | +*FakeApi* | [**test_body_with_file_schema**](docs/FakeApi.md#test_body_with_file_schema) | **PUT** /fake/body-with-file-schema | +*FakeApi* | [**test_body_with_query_params**](docs/FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params | +*FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model +*FakeApi* | [**test_date_time_query_parameter**](docs/FakeApi.md#test_date_time_query_parameter) | **PUT** /fake/date-time-query-params | +*FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 +*FakeApi* | [**test_group_parameters**](docs/FakeApi.md#test_group_parameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) +*FakeApi* | [**test_inline_additional_properties**](docs/FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties +*FakeApi* | [**test_json_form_data**](docs/FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**test_query_parameter_collection_format**](docs/FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | +*FakeClassnameTags123Api* | [**test_classname**](docs/FakeClassnameTags123Api.md#test_classname) | **PATCH** /fake_classname_test | To test class name in snake case +*PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store +*PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**find_pets_by_tags**](docs/PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**get_pet_by_id**](docs/PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**update_pet**](docs/PetApi.md#update_pet) | **PUT** /pet | Update an existing pet +*PetApi* | [**update_pet_with_form**](docs/PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data +*PetApi* | [**upload_file**](docs/PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image +*PetApi* | [**upload_file_with_required_file**](docs/PetApi.md#upload_file_with_required_file) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) +*StoreApi* | [**delete_order**](docs/StoreApi.md#delete_order) | **DELETE** /store/order/{order_id} | Delete purchase order by ID +*StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{order_id} | Find purchase order by ID +*StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet +*UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user +*UserApi* | [**create_users_with_array_input**](docs/UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**create_users_with_list_input**](docs/UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**delete_user**](docs/UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user +*UserApi* | [**get_user_by_name**](docs/UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name +*UserApi* | [**login_user**](docs/UserApi.md#login_user) | **GET** /user/login | Logs user into the system +*UserApi* | [**logout_user**](docs/UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**update_user**](docs/UserApi.md#update_user) | **PUT** /user/{username} | Updated user + + +## Documentation For Models + + - [AdditionalPropertiesAnyType](docs/AdditionalPropertiesAnyType.md) + - [AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md) + - [AdditionalPropertiesObject](docs/AdditionalPropertiesObject.md) + - [AdditionalPropertiesWithDescriptionOnly](docs/AdditionalPropertiesWithDescriptionOnly.md) + - [AllOfWithSingleRef](docs/AllOfWithSingleRef.md) + - [Animal](docs/Animal.md) + - [AnyOfColor](docs/AnyOfColor.md) + - [AnyOfPig](docs/AnyOfPig.md) + - [ApiResponse](docs/ApiResponse.md) + - [ArrayOfArrayOfModel](docs/ArrayOfArrayOfModel.md) + - [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md) + - [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) + - [ArrayTest](docs/ArrayTest.md) + - [BasquePig](docs/BasquePig.md) + - [Capitalization](docs/Capitalization.md) + - [Cat](docs/Cat.md) + - [Category](docs/Category.md) + - [ClassModel](docs/ClassModel.md) + - [Client](docs/Client.md) + - [Color](docs/Color.md) + - [Creature](docs/Creature.md) + - [CreatureInfo](docs/CreatureInfo.md) + - [DanishPig](docs/DanishPig.md) + - [DeprecatedObject](docs/DeprecatedObject.md) + - [Dog](docs/Dog.md) + - [DummyModel](docs/DummyModel.md) + - [EnumArrays](docs/EnumArrays.md) + - [EnumClass](docs/EnumClass.md) + - [EnumString1](docs/EnumString1.md) + - [EnumString2](docs/EnumString2.md) + - [EnumTest](docs/EnumTest.md) + - [File](docs/File.md) + - [FileSchemaTestClass](docs/FileSchemaTestClass.md) + - [Foo](docs/Foo.md) + - [FooGetDefaultResponse](docs/FooGetDefaultResponse.md) + - [FormatTest](docs/FormatTest.md) + - [HasOnlyReadOnly](docs/HasOnlyReadOnly.md) + - [HealthCheckResult](docs/HealthCheckResult.md) + - [InnerDictWithProperty](docs/InnerDictWithProperty.md) + - [IntOrString](docs/IntOrString.md) + - [List](docs/List.md) + - [MapOfArrayOfModel](docs/MapOfArrayOfModel.md) + - [MapTest](docs/MapTest.md) + - [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) + - [Model200Response](docs/Model200Response.md) + - [ModelReturn](docs/ModelReturn.md) + - [Name](docs/Name.md) + - [NullableClass](docs/NullableClass.md) + - [NullableProperty](docs/NullableProperty.md) + - [NumberOnly](docs/NumberOnly.md) + - [ObjectToTestAdditionalProperties](docs/ObjectToTestAdditionalProperties.md) + - [ObjectWithDeprecatedFields](docs/ObjectWithDeprecatedFields.md) + - [OneOfEnumString](docs/OneOfEnumString.md) + - [Order](docs/Order.md) + - [OuterComposite](docs/OuterComposite.md) + - [OuterEnum](docs/OuterEnum.md) + - [OuterEnumDefaultValue](docs/OuterEnumDefaultValue.md) + - [OuterEnumInteger](docs/OuterEnumInteger.md) + - [OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md) + - [OuterObjectWithEnumProperty](docs/OuterObjectWithEnumProperty.md) + - [Parent](docs/Parent.md) + - [ParentWithOptionalDict](docs/ParentWithOptionalDict.md) + - [Pet](docs/Pet.md) + - [Pig](docs/Pig.md) + - [PropertyNameCollision](docs/PropertyNameCollision.md) + - [ReadOnlyFirst](docs/ReadOnlyFirst.md) + - [SelfReferenceModel](docs/SelfReferenceModel.md) + - [SingleRefType](docs/SingleRefType.md) + - [SpecialCharacterEnum](docs/SpecialCharacterEnum.md) + - [SpecialModelName](docs/SpecialModelName.md) + - [SpecialName](docs/SpecialName.md) + - [Tag](docs/Tag.md) + - [Tiger](docs/Tiger.md) + - [User](docs/User.md) + - [WithNestedOneOf](docs/WithNestedOneOf.md) + + + +## Documentation For Authorization + + +Authentication schemes defined for the API: + +### petstore_auth + +- **Type**: OAuth +- **Flow**: implicit +- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - **write:pets**: modify pets in your account + - **read:pets**: read your pets + + +### api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + + +### api_key_query + +- **Type**: API key +- **API key parameter name**: api_key_query +- **Location**: URL query string + + +### http_basic_test + +- **Type**: HTTP basic authentication + + +### bearer_test + +- **Type**: Bearer authentication (JWT) + + +### http_signature_test + +- **Type**: HTTP signature authentication + + +## Author + + + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/dev-requirements.txt b/samples/openapi3/client/petstore/python-pydantic-v2/dev-requirements.txt new file mode 100755 index 000000000000..ccdfca629494 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/dev-requirements.txt @@ -0,0 +1,2 @@ +tox +flake8 diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/docs/AdditionalPropertiesAnyType.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/AdditionalPropertiesAnyType.md new file mode 100644 index 000000000000..beedef76c051 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/AdditionalPropertiesAnyType.md @@ -0,0 +1,28 @@ +# AdditionalPropertiesAnyType + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | | [optional] + +## Example + +```python +from petstore_api.models.additional_properties_any_type import AdditionalPropertiesAnyType + +# TODO update the JSON string below +json = "{}" +# create an instance of AdditionalPropertiesAnyType from a JSON string +additional_properties_any_type_instance = AdditionalPropertiesAnyType.from_json(json) +# print the JSON string representation of the object +print AdditionalPropertiesAnyType.to_json() + +# convert the object into a dict +additional_properties_any_type_dict = additional_properties_any_type_instance.to_dict() +# create an instance of AdditionalPropertiesAnyType from a dict +additional_properties_any_type_form_dict = additional_properties_any_type.from_dict(additional_properties_any_type_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/AdditionalPropertiesClass.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/AdditionalPropertiesClass.md new file mode 100644 index 000000000000..6abc3136b9ca --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/AdditionalPropertiesClass.md @@ -0,0 +1,29 @@ +# AdditionalPropertiesClass + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**map_property** | **Dict[str, str]** | | [optional] +**map_of_map_property** | **Dict[str, Dict[str, str]]** | | [optional] + +## Example + +```python +from petstore_api.models.additional_properties_class import AdditionalPropertiesClass + +# TODO update the JSON string below +json = "{}" +# create an instance of AdditionalPropertiesClass from a JSON string +additional_properties_class_instance = AdditionalPropertiesClass.from_json(json) +# print the JSON string representation of the object +print AdditionalPropertiesClass.to_json() + +# convert the object into a dict +additional_properties_class_dict = additional_properties_class_instance.to_dict() +# create an instance of AdditionalPropertiesClass from a dict +additional_properties_class_form_dict = additional_properties_class.from_dict(additional_properties_class_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/AdditionalPropertiesObject.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/AdditionalPropertiesObject.md new file mode 100644 index 000000000000..8b9259c687f6 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/AdditionalPropertiesObject.md @@ -0,0 +1,28 @@ +# AdditionalPropertiesObject + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | | [optional] + +## Example + +```python +from petstore_api.models.additional_properties_object import AdditionalPropertiesObject + +# TODO update the JSON string below +json = "{}" +# create an instance of AdditionalPropertiesObject from a JSON string +additional_properties_object_instance = AdditionalPropertiesObject.from_json(json) +# print the JSON string representation of the object +print AdditionalPropertiesObject.to_json() + +# convert the object into a dict +additional_properties_object_dict = additional_properties_object_instance.to_dict() +# create an instance of AdditionalPropertiesObject from a dict +additional_properties_object_form_dict = additional_properties_object.from_dict(additional_properties_object_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/AdditionalPropertiesWithDescriptionOnly.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/AdditionalPropertiesWithDescriptionOnly.md new file mode 100644 index 000000000000..d66094f18e57 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/AdditionalPropertiesWithDescriptionOnly.md @@ -0,0 +1,28 @@ +# AdditionalPropertiesWithDescriptionOnly + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | | [optional] + +## Example + +```python +from petstore_api.models.additional_properties_with_description_only import AdditionalPropertiesWithDescriptionOnly + +# TODO update the JSON string below +json = "{}" +# create an instance of AdditionalPropertiesWithDescriptionOnly from a JSON string +additional_properties_with_description_only_instance = AdditionalPropertiesWithDescriptionOnly.from_json(json) +# print the JSON string representation of the object +print AdditionalPropertiesWithDescriptionOnly.to_json() + +# convert the object into a dict +additional_properties_with_description_only_dict = additional_properties_with_description_only_instance.to_dict() +# create an instance of AdditionalPropertiesWithDescriptionOnly from a dict +additional_properties_with_description_only_form_dict = additional_properties_with_description_only.from_dict(additional_properties_with_description_only_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/AllOfWithSingleRef.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/AllOfWithSingleRef.md new file mode 100644 index 000000000000..1a8b4df7ecc5 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/AllOfWithSingleRef.md @@ -0,0 +1,29 @@ +# AllOfWithSingleRef + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**username** | **str** | | [optional] +**single_ref_type** | [**SingleRefType**](SingleRefType.md) | | [optional] + +## Example + +```python +from petstore_api.models.all_of_with_single_ref import AllOfWithSingleRef + +# TODO update the JSON string below +json = "{}" +# create an instance of AllOfWithSingleRef from a JSON string +all_of_with_single_ref_instance = AllOfWithSingleRef.from_json(json) +# print the JSON string representation of the object +print AllOfWithSingleRef.to_json() + +# convert the object into a dict +all_of_with_single_ref_dict = all_of_with_single_ref_instance.to_dict() +# create an instance of AllOfWithSingleRef from a dict +all_of_with_single_ref_form_dict = all_of_with_single_ref.from_dict(all_of_with_single_ref_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/Animal.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Animal.md new file mode 100644 index 000000000000..b62f19690994 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Animal.md @@ -0,0 +1,29 @@ +# Animal + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**class_name** | **str** | | +**color** | **str** | | [optional] [default to 'red'] + +## Example + +```python +from petstore_api.models.animal import Animal + +# TODO update the JSON string below +json = "{}" +# create an instance of Animal from a JSON string +animal_instance = Animal.from_json(json) +# print the JSON string representation of the object +print Animal.to_json() + +# convert the object into a dict +animal_dict = animal_instance.to_dict() +# create an instance of Animal from a dict +animal_form_dict = animal.from_dict(animal_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/AnotherFakeApi.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/AnotherFakeApi.md new file mode 100644 index 000000000000..d3103c7d369f --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/AnotherFakeApi.md @@ -0,0 +1,76 @@ +# petstore_api.AnotherFakeApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**call_123_test_special_tags**](AnotherFakeApi.md#call_123_test_special_tags) | **PATCH** /another-fake/dummy | To test special tags + + +# **call_123_test_special_tags** +> Client call_123_test_special_tags(client) + +To test special tags + +To test special tags and operation ID starting with number + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.models.client import Client +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.AnotherFakeApi(api_client) + client = petstore_api.Client() # Client | client model + + try: + # To test special tags + api_response = api_instance.call_123_test_special_tags(client) + print("The response of AnotherFakeApi->call_123_test_special_tags:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling AnotherFakeApi->call_123_test_special_tags: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **client** | [**Client**](Client.md)| client model | + +### Return type + +[**Client**](Client.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/docs/AnyOfColor.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/AnyOfColor.md new file mode 100644 index 000000000000..9b161ccba1c0 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/AnyOfColor.md @@ -0,0 +1,28 @@ +# AnyOfColor + +Any of RGB array, RGBA array, or hex string. + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +## Example + +```python +from petstore_api.models.any_of_color import AnyOfColor + +# TODO update the JSON string below +json = "{}" +# create an instance of AnyOfColor from a JSON string +any_of_color_instance = AnyOfColor.from_json(json) +# print the JSON string representation of the object +print AnyOfColor.to_json() + +# convert the object into a dict +any_of_color_dict = any_of_color_instance.to_dict() +# create an instance of AnyOfColor from a dict +any_of_color_form_dict = any_of_color.from_dict(any_of_color_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/AnyOfPig.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/AnyOfPig.md new file mode 100644 index 000000000000..2da7ca6eefe7 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/AnyOfPig.md @@ -0,0 +1,30 @@ +# AnyOfPig + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**class_name** | **str** | | +**color** | **str** | | +**size** | **int** | | + +## Example + +```python +from petstore_api.models.any_of_pig import AnyOfPig + +# TODO update the JSON string below +json = "{}" +# create an instance of AnyOfPig from a JSON string +any_of_pig_instance = AnyOfPig.from_json(json) +# print the JSON string representation of the object +print AnyOfPig.to_json() + +# convert the object into a dict +any_of_pig_dict = any_of_pig_instance.to_dict() +# create an instance of AnyOfPig from a dict +any_of_pig_form_dict = any_of_pig.from_dict(any_of_pig_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/ApiResponse.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/ApiResponse.md new file mode 100644 index 000000000000..ba35ea9e2f0e --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/ApiResponse.md @@ -0,0 +1,30 @@ +# ApiResponse + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **int** | | [optional] +**type** | **str** | | [optional] +**message** | **str** | | [optional] + +## Example + +```python +from petstore_api.models.api_response import ApiResponse + +# TODO update the JSON string below +json = "{}" +# create an instance of ApiResponse from a JSON string +api_response_instance = ApiResponse.from_json(json) +# print the JSON string representation of the object +print ApiResponse.to_json() + +# convert the object into a dict +api_response_dict = api_response_instance.to_dict() +# create an instance of ApiResponse from a dict +api_response_form_dict = api_response.from_dict(api_response_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/ArrayOfArrayOfModel.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/ArrayOfArrayOfModel.md new file mode 100644 index 000000000000..094061592613 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/ArrayOfArrayOfModel.md @@ -0,0 +1,28 @@ +# ArrayOfArrayOfModel + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**another_property** | **List[List[Tag]]** | | [optional] + +## Example + +```python +from petstore_api.models.array_of_array_of_model import ArrayOfArrayOfModel + +# TODO update the JSON string below +json = "{}" +# create an instance of ArrayOfArrayOfModel from a JSON string +array_of_array_of_model_instance = ArrayOfArrayOfModel.from_json(json) +# print the JSON string representation of the object +print ArrayOfArrayOfModel.to_json() + +# convert the object into a dict +array_of_array_of_model_dict = array_of_array_of_model_instance.to_dict() +# create an instance of ArrayOfArrayOfModel from a dict +array_of_array_of_model_form_dict = array_of_array_of_model.from_dict(array_of_array_of_model_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/ArrayOfArrayOfNumberOnly.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/ArrayOfArrayOfNumberOnly.md new file mode 100644 index 000000000000..3f0c127d4fa3 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/ArrayOfArrayOfNumberOnly.md @@ -0,0 +1,28 @@ +# ArrayOfArrayOfNumberOnly + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_array_number** | **List[List[float]]** | | [optional] + +## Example + +```python +from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly + +# TODO update the JSON string below +json = "{}" +# create an instance of ArrayOfArrayOfNumberOnly from a JSON string +array_of_array_of_number_only_instance = ArrayOfArrayOfNumberOnly.from_json(json) +# print the JSON string representation of the object +print ArrayOfArrayOfNumberOnly.to_json() + +# convert the object into a dict +array_of_array_of_number_only_dict = array_of_array_of_number_only_instance.to_dict() +# create an instance of ArrayOfArrayOfNumberOnly from a dict +array_of_array_of_number_only_form_dict = array_of_array_of_number_only.from_dict(array_of_array_of_number_only_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/ArrayOfNumberOnly.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/ArrayOfNumberOnly.md new file mode 100644 index 000000000000..c10191915a70 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/ArrayOfNumberOnly.md @@ -0,0 +1,28 @@ +# ArrayOfNumberOnly + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_number** | **List[float]** | | [optional] + +## Example + +```python +from petstore_api.models.array_of_number_only import ArrayOfNumberOnly + +# TODO update the JSON string below +json = "{}" +# create an instance of ArrayOfNumberOnly from a JSON string +array_of_number_only_instance = ArrayOfNumberOnly.from_json(json) +# print the JSON string representation of the object +print ArrayOfNumberOnly.to_json() + +# convert the object into a dict +array_of_number_only_dict = array_of_number_only_instance.to_dict() +# create an instance of ArrayOfNumberOnly from a dict +array_of_number_only_form_dict = array_of_number_only.from_dict(array_of_number_only_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/ArrayTest.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/ArrayTest.md new file mode 100644 index 000000000000..0a40fb36d26f --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/ArrayTest.md @@ -0,0 +1,30 @@ +# ArrayTest + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_of_string** | **List[str]** | | [optional] +**array_array_of_integer** | **List[List[int]]** | | [optional] +**array_array_of_model** | **List[List[ReadOnlyFirst]]** | | [optional] + +## Example + +```python +from petstore_api.models.array_test import ArrayTest + +# TODO update the JSON string below +json = "{}" +# create an instance of ArrayTest from a JSON string +array_test_instance = ArrayTest.from_json(json) +# print the JSON string representation of the object +print ArrayTest.to_json() + +# convert the object into a dict +array_test_dict = array_test_instance.to_dict() +# create an instance of ArrayTest from a dict +array_test_form_dict = array_test.from_dict(array_test_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/BasquePig.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/BasquePig.md new file mode 100644 index 000000000000..552b9390c7e5 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/BasquePig.md @@ -0,0 +1,29 @@ +# BasquePig + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**class_name** | **str** | | +**color** | **str** | | + +## Example + +```python +from petstore_api.models.basque_pig import BasquePig + +# TODO update the JSON string below +json = "{}" +# create an instance of BasquePig from a JSON string +basque_pig_instance = BasquePig.from_json(json) +# print the JSON string representation of the object +print BasquePig.to_json() + +# convert the object into a dict +basque_pig_dict = basque_pig_instance.to_dict() +# create an instance of BasquePig from a dict +basque_pig_form_dict = basque_pig.from_dict(basque_pig_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/Capitalization.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Capitalization.md new file mode 100644 index 000000000000..99e6fae88fde --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Capitalization.md @@ -0,0 +1,33 @@ +# Capitalization + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**small_camel** | **str** | | [optional] +**capital_camel** | **str** | | [optional] +**small_snake** | **str** | | [optional] +**capital_snake** | **str** | | [optional] +**sca_eth_flow_points** | **str** | | [optional] +**att_name** | **str** | Name of the pet | [optional] + +## Example + +```python +from petstore_api.models.capitalization import Capitalization + +# TODO update the JSON string below +json = "{}" +# create an instance of Capitalization from a JSON string +capitalization_instance = Capitalization.from_json(json) +# print the JSON string representation of the object +print Capitalization.to_json() + +# convert the object into a dict +capitalization_dict = capitalization_instance.to_dict() +# create an instance of Capitalization from a dict +capitalization_form_dict = capitalization.from_dict(capitalization_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/Cat.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Cat.md new file mode 100644 index 000000000000..4b509dda7ea3 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Cat.md @@ -0,0 +1,28 @@ +# Cat + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**declawed** | **bool** | | [optional] + +## Example + +```python +from petstore_api.models.cat import Cat + +# TODO update the JSON string below +json = "{}" +# create an instance of Cat from a JSON string +cat_instance = Cat.from_json(json) +# print the JSON string representation of the object +print Cat.to_json() + +# convert the object into a dict +cat_dict = cat_instance.to_dict() +# create an instance of Cat from a dict +cat_form_dict = cat.from_dict(cat_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/Category.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Category.md new file mode 100644 index 000000000000..c49514ef8023 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Category.md @@ -0,0 +1,29 @@ +# Category + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**name** | **str** | | [default to 'default-name'] + +## Example + +```python +from petstore_api.models.category import Category + +# TODO update the JSON string below +json = "{}" +# create an instance of Category from a JSON string +category_instance = Category.from_json(json) +# print the JSON string representation of the object +print Category.to_json() + +# convert the object into a dict +category_dict = category_instance.to_dict() +# create an instance of Category from a dict +category_form_dict = category.from_dict(category_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/CircularReferenceModel.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/CircularReferenceModel.md new file mode 100644 index 000000000000..d5e97934d2be --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/CircularReferenceModel.md @@ -0,0 +1,29 @@ +# CircularReferenceModel + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**size** | **int** | | [optional] +**nested** | [**FirstRef**](FirstRef.md) | | [optional] + +## Example + +```python +from petstore_api.models.circular_reference_model import CircularReferenceModel + +# TODO update the JSON string below +json = "{}" +# create an instance of CircularReferenceModel from a JSON string +circular_reference_model_instance = CircularReferenceModel.from_json(json) +# print the JSON string representation of the object +print CircularReferenceModel.to_json() + +# convert the object into a dict +circular_reference_model_dict = circular_reference_model_instance.to_dict() +# create an instance of CircularReferenceModel from a dict +circular_reference_model_form_dict = circular_reference_model.from_dict(circular_reference_model_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/ClassModel.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/ClassModel.md new file mode 100644 index 000000000000..1b6fb7cfc77d --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/ClassModel.md @@ -0,0 +1,29 @@ +# ClassModel + +Model for testing model with \"_class\" property + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**var_class** | **str** | | [optional] + +## Example + +```python +from petstore_api.models.class_model import ClassModel + +# TODO update the JSON string below +json = "{}" +# create an instance of ClassModel from a JSON string +class_model_instance = ClassModel.from_json(json) +# print the JSON string representation of the object +print ClassModel.to_json() + +# convert the object into a dict +class_model_dict = class_model_instance.to_dict() +# create an instance of ClassModel from a dict +class_model_form_dict = class_model.from_dict(class_model_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/Client.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Client.md new file mode 100644 index 000000000000..b0ded10dd762 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Client.md @@ -0,0 +1,28 @@ +# Client + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**client** | **str** | | [optional] + +## Example + +```python +from petstore_api.models.client import Client + +# TODO update the JSON string below +json = "{}" +# create an instance of Client from a JSON string +client_instance = Client.from_json(json) +# print the JSON string representation of the object +print Client.to_json() + +# convert the object into a dict +client_dict = client_instance.to_dict() +# create an instance of Client from a dict +client_form_dict = client.from_dict(client_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/Color.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Color.md new file mode 100644 index 000000000000..07fcd01991ac --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Color.md @@ -0,0 +1,28 @@ +# Color + +RGB array, RGBA array, or hex string. + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +## Example + +```python +from petstore_api.models.color import Color + +# TODO update the JSON string below +json = "{}" +# create an instance of Color from a JSON string +color_instance = Color.from_json(json) +# print the JSON string representation of the object +print Color.to_json() + +# convert the object into a dict +color_dict = color_instance.to_dict() +# create an instance of Color from a dict +color_form_dict = color.from_dict(color_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/Creature.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Creature.md new file mode 100644 index 000000000000..54249d5871e0 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Creature.md @@ -0,0 +1,29 @@ +# Creature + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**info** | [**CreatureInfo**](CreatureInfo.md) | | +**type** | **str** | | + +## Example + +```python +from petstore_api.models.creature import Creature + +# TODO update the JSON string below +json = "{}" +# create an instance of Creature from a JSON string +creature_instance = Creature.from_json(json) +# print the JSON string representation of the object +print Creature.to_json() + +# convert the object into a dict +creature_dict = creature_instance.to_dict() +# create an instance of Creature from a dict +creature_form_dict = creature.from_dict(creature_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/CreatureInfo.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/CreatureInfo.md new file mode 100644 index 000000000000..5a600b9f3374 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/CreatureInfo.md @@ -0,0 +1,28 @@ +# CreatureInfo + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | | + +## Example + +```python +from petstore_api.models.creature_info import CreatureInfo + +# TODO update the JSON string below +json = "{}" +# create an instance of CreatureInfo from a JSON string +creature_info_instance = CreatureInfo.from_json(json) +# print the JSON string representation of the object +print CreatureInfo.to_json() + +# convert the object into a dict +creature_info_dict = creature_info_instance.to_dict() +# create an instance of CreatureInfo from a dict +creature_info_form_dict = creature_info.from_dict(creature_info_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/DanishPig.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/DanishPig.md new file mode 100644 index 000000000000..253616c2fc32 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/DanishPig.md @@ -0,0 +1,29 @@ +# DanishPig + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**class_name** | **str** | | +**size** | **int** | | + +## Example + +```python +from petstore_api.models.danish_pig import DanishPig + +# TODO update the JSON string below +json = "{}" +# create an instance of DanishPig from a JSON string +danish_pig_instance = DanishPig.from_json(json) +# print the JSON string representation of the object +print DanishPig.to_json() + +# convert the object into a dict +danish_pig_dict = danish_pig_instance.to_dict() +# create an instance of DanishPig from a dict +danish_pig_form_dict = danish_pig.from_dict(danish_pig_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/DefaultApi.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/DefaultApi.md new file mode 100644 index 000000000000..a5c2b671f341 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/DefaultApi.md @@ -0,0 +1,69 @@ +# petstore_api.DefaultApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**foo_get**](DefaultApi.md#foo_get) | **GET** /foo | + + +# **foo_get** +> FooGetDefaultResponse foo_get() + + + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.models.foo_get_default_response import FooGetDefaultResponse +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.DefaultApi(api_client) + + try: + api_response = api_instance.foo_get() + print("The response of DefaultApi->foo_get:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling DefaultApi->foo_get: %s\n" % e) +``` + + + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**FooGetDefaultResponse**](FooGetDefaultResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**0** | response | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/docs/DeprecatedObject.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/DeprecatedObject.md new file mode 100644 index 000000000000..e6cf57189634 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/DeprecatedObject.md @@ -0,0 +1,28 @@ +# DeprecatedObject + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | | [optional] + +## Example + +```python +from petstore_api.models.deprecated_object import DeprecatedObject + +# TODO update the JSON string below +json = "{}" +# create an instance of DeprecatedObject from a JSON string +deprecated_object_instance = DeprecatedObject.from_json(json) +# print the JSON string representation of the object +print DeprecatedObject.to_json() + +# convert the object into a dict +deprecated_object_dict = deprecated_object_instance.to_dict() +# create an instance of DeprecatedObject from a dict +deprecated_object_form_dict = deprecated_object.from_dict(deprecated_object_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/Dog.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Dog.md new file mode 100644 index 000000000000..3469be73a761 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Dog.md @@ -0,0 +1,28 @@ +# Dog + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**breed** | **str** | | [optional] + +## Example + +```python +from petstore_api.models.dog import Dog + +# TODO update the JSON string below +json = "{}" +# create an instance of Dog from a JSON string +dog_instance = Dog.from_json(json) +# print the JSON string representation of the object +print Dog.to_json() + +# convert the object into a dict +dog_dict = dog_instance.to_dict() +# create an instance of Dog from a dict +dog_form_dict = dog.from_dict(dog_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/DummyModel.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/DummyModel.md new file mode 100644 index 000000000000..e690a8874f8c --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/DummyModel.md @@ -0,0 +1,29 @@ +# DummyModel + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**category** | **str** | | [optional] +**self_ref** | [**SelfReferenceModel**](SelfReferenceModel.md) | | [optional] + +## Example + +```python +from petstore_api.models.dummy_model import DummyModel + +# TODO update the JSON string below +json = "{}" +# create an instance of DummyModel from a JSON string +dummy_model_instance = DummyModel.from_json(json) +# print the JSON string representation of the object +print DummyModel.to_json() + +# convert the object into a dict +dummy_model_dict = dummy_model_instance.to_dict() +# create an instance of DummyModel from a dict +dummy_model_form_dict = dummy_model.from_dict(dummy_model_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/EnumArrays.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/EnumArrays.md new file mode 100644 index 000000000000..d21f58a66087 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/EnumArrays.md @@ -0,0 +1,29 @@ +# EnumArrays + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**just_symbol** | **str** | | [optional] +**array_enum** | **List[str]** | | [optional] + +## Example + +```python +from petstore_api.models.enum_arrays import EnumArrays + +# TODO update the JSON string below +json = "{}" +# create an instance of EnumArrays from a JSON string +enum_arrays_instance = EnumArrays.from_json(json) +# print the JSON string representation of the object +print EnumArrays.to_json() + +# convert the object into a dict +enum_arrays_dict = enum_arrays_instance.to_dict() +# create an instance of EnumArrays from a dict +enum_arrays_form_dict = enum_arrays.from_dict(enum_arrays_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/EnumClass.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/EnumClass.md new file mode 100644 index 000000000000..64830e3d1dee --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/EnumClass.md @@ -0,0 +1,10 @@ +# EnumClass + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/openapi3/client/petstore/python-pydantic-v2/docs/EnumString1.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/EnumString1.md new file mode 100644 index 000000000000..194d65b48fa0 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/EnumString1.md @@ -0,0 +1,10 @@ +# EnumString1 + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/openapi3/client/petstore/python-pydantic-v2/docs/EnumString2.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/EnumString2.md new file mode 100644 index 000000000000..0d8568bfbeff --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/EnumString2.md @@ -0,0 +1,10 @@ +# EnumString2 + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/openapi3/client/petstore/python-pydantic-v2/docs/EnumTest.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/EnumTest.md new file mode 100644 index 000000000000..5bcb8e7027e3 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/EnumTest.md @@ -0,0 +1,36 @@ +# EnumTest + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**enum_string** | **str** | | [optional] +**enum_string_required** | **str** | | +**enum_integer_default** | **int** | | [optional] [default to 5] +**enum_integer** | **int** | | [optional] +**enum_number** | **float** | | [optional] +**outer_enum** | [**OuterEnum**](OuterEnum.md) | | [optional] +**outer_enum_integer** | [**OuterEnumInteger**](OuterEnumInteger.md) | | [optional] +**outer_enum_default_value** | [**OuterEnumDefaultValue**](OuterEnumDefaultValue.md) | | [optional] +**outer_enum_integer_default_value** | [**OuterEnumIntegerDefaultValue**](OuterEnumIntegerDefaultValue.md) | | [optional] + +## Example + +```python +from petstore_api.models.enum_test import EnumTest + +# TODO update the JSON string below +json = "{}" +# create an instance of EnumTest from a JSON string +enum_test_instance = EnumTest.from_json(json) +# print the JSON string representation of the object +print EnumTest.to_json() + +# convert the object into a dict +enum_test_dict = enum_test_instance.to_dict() +# create an instance of EnumTest from a dict +enum_test_form_dict = enum_test.from_dict(enum_test_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/FakeApi.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/FakeApi.md new file mode 100644 index 000000000000..047af9ef3789 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/FakeApi.md @@ -0,0 +1,1513 @@ +# petstore_api.FakeApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**fake_any_type_request_body**](FakeApi.md#fake_any_type_request_body) | **POST** /fake/any_type_body | test any type request body +[**fake_enum_ref_query_parameter**](FakeApi.md#fake_enum_ref_query_parameter) | **GET** /fake/enum_ref_query_parameter | test enum reference query parameter +[**fake_health_get**](FakeApi.md#fake_health_get) | **GET** /fake/health | Health check endpoint +[**fake_http_signature_test**](FakeApi.md#fake_http_signature_test) | **GET** /fake/http-signature-test | test http signature authentication +[**fake_outer_boolean_serialize**](FakeApi.md#fake_outer_boolean_serialize) | **POST** /fake/outer/boolean | +[**fake_outer_composite_serialize**](FakeApi.md#fake_outer_composite_serialize) | **POST** /fake/outer/composite | +[**fake_outer_number_serialize**](FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number | +[**fake_outer_string_serialize**](FakeApi.md#fake_outer_string_serialize) | **POST** /fake/outer/string | +[**fake_property_enum_integer_serialize**](FakeApi.md#fake_property_enum_integer_serialize) | **POST** /fake/property/enum-int | +[**fake_return_list_of_objects**](FakeApi.md#fake_return_list_of_objects) | **GET** /fake/return_list_of_object | test returning list of objects +[**fake_uuid_example**](FakeApi.md#fake_uuid_example) | **GET** /fake/uuid_example | test uuid example +[**test_body_with_binary**](FakeApi.md#test_body_with_binary) | **PUT** /fake/body-with-binary | +[**test_body_with_file_schema**](FakeApi.md#test_body_with_file_schema) | **PUT** /fake/body-with-file-schema | +[**test_body_with_query_params**](FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params | +[**test_client_model**](FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model +[**test_date_time_query_parameter**](FakeApi.md#test_date_time_query_parameter) | **PUT** /fake/date-time-query-params | +[**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 +[**test_group_parameters**](FakeApi.md#test_group_parameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) +[**test_inline_additional_properties**](FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties +[**test_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +[**test_query_parameter_collection_format**](FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | + + +# **fake_any_type_request_body** +> fake_any_type_request_body(body=body) + +test any type request body + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + body = None # object | (optional) + + try: + # test any type request body + api_instance.fake_any_type_request_body(body=body) + except Exception as e: + print("Exception when calling FakeApi->fake_any_type_request_body: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **object**| | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | OK | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **fake_enum_ref_query_parameter** +> fake_enum_ref_query_parameter(enum_ref=enum_ref) + +test enum reference query parameter + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.models.enum_class import EnumClass +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + enum_ref = petstore_api.EnumClass() # EnumClass | enum reference (optional) + + try: + # test enum reference query parameter + api_instance.fake_enum_ref_query_parameter(enum_ref=enum_ref) + except Exception as e: + print("Exception when calling FakeApi->fake_enum_ref_query_parameter: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **enum_ref** | [**EnumClass**](.md)| enum reference | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Get successful | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **fake_health_get** +> HealthCheckResult fake_health_get() + +Health check endpoint + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.models.health_check_result import HealthCheckResult +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + + try: + # Health check endpoint + api_response = api_instance.fake_health_get() + print("The response of FakeApi->fake_health_get:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling FakeApi->fake_health_get: %s\n" % e) +``` + + + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**HealthCheckResult**](HealthCheckResult.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | The instance started successfully | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **fake_http_signature_test** +> fake_http_signature_test(pet, query_1=query_1, header_1=header_1) + +test http signature authentication + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.models.pet import Pet +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure HTTP message signature: http_signature_test +# The HTTP Signature Header mechanism that can be used by a client to +# authenticate the sender of a message and ensure that particular headers +# have not been modified in transit. +# +# You can specify the signing key-id, private key path, signing scheme, +# signing algorithm, list of signed headers and signature max validity. +# The 'key_id' parameter is an opaque string that the API server can use +# to lookup the client and validate the signature. +# The 'private_key_path' parameter should be the path to a file that +# contains a DER or base-64 encoded private key. +# The 'private_key_passphrase' parameter is optional. Set the passphrase +# if the private key is encrypted. +# The 'signed_headers' parameter is used to specify the list of +# HTTP headers included when generating the signature for the message. +# You can specify HTTP headers that you want to protect with a cryptographic +# signature. Note that proxies may add, modify or remove HTTP headers +# for legitimate reasons, so you should only add headers that you know +# will not be modified. For example, if you want to protect the HTTP request +# body, you can specify the Digest header. In that case, the client calculates +# the digest of the HTTP request body and includes the digest in the message +# signature. +# The 'signature_max_validity' parameter is optional. It is configured as a +# duration to express when the signature ceases to be valid. The client calculates +# the expiration date every time it generates the cryptographic signature +# of an HTTP request. The API server may have its own security policy +# that controls the maximum validity of the signature. The client max validity +# must be lower than the server max validity. +# The time on the client and server must be synchronized, otherwise the +# server may reject the client signature. +# +# The client must use a combination of private key, signing scheme, +# signing algorithm and hash algorithm that matches the security policy of +# the API server. +# +# See petstore_api.signing for a list of all supported parameters. +from petstore_api import signing +import datetime + +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2", + signing_info = petstore_api.HttpSigningConfiguration( + key_id = 'my-key-id', + private_key_path = 'private_key.pem', + private_key_passphrase = 'YOUR_PASSPHRASE', + signing_scheme = petstore_api.signing.SCHEME_HS2019, + signing_algorithm = petstore_api.signing.ALGORITHM_ECDSA_MODE_FIPS_186_3, + hash_algorithm = petstore_api.signing.SCHEME_RSA_SHA256, + signed_headers = [ + petstore_api.signing.HEADER_REQUEST_TARGET, + petstore_api.signing.HEADER_CREATED, + petstore_api.signing.HEADER_EXPIRES, + petstore_api.signing.HEADER_HOST, + petstore_api.signing.HEADER_DATE, + petstore_api.signing.HEADER_DIGEST, + 'Content-Type', + 'Content-Length', + 'User-Agent' + ], + signature_max_validity = datetime.timedelta(minutes=5) + ) +) + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + pet = petstore_api.Pet() # Pet | Pet object that needs to be added to the store + query_1 = 'query_1_example' # str | query parameter (optional) + header_1 = 'header_1_example' # str | header parameter (optional) + + try: + # test http signature authentication + api_instance.fake_http_signature_test(pet, query_1=query_1, header_1=header_1) + except Exception as e: + print("Exception when calling FakeApi->fake_http_signature_test: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + **query_1** | **str**| query parameter | [optional] + **header_1** | **str**| header parameter | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[http_signature_test](../README.md#http_signature_test) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | The instance started successfully | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **fake_outer_boolean_serialize** +> bool fake_outer_boolean_serialize(body=body) + + + +Test serialization of outer boolean types + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + body = True # bool | Input boolean as post body (optional) + + try: + api_response = api_instance.fake_outer_boolean_serialize(body=body) + print("The response of FakeApi->fake_outer_boolean_serialize:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling FakeApi->fake_outer_boolean_serialize: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **bool**| Input boolean as post body | [optional] + +### Return type + +**bool** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: */* + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Output boolean | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **fake_outer_composite_serialize** +> OuterComposite fake_outer_composite_serialize(outer_composite=outer_composite) + + + +Test serialization of object with outer number type + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.models.outer_composite import OuterComposite +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + outer_composite = petstore_api.OuterComposite() # OuterComposite | Input composite as post body (optional) + + try: + api_response = api_instance.fake_outer_composite_serialize(outer_composite=outer_composite) + print("The response of FakeApi->fake_outer_composite_serialize:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling FakeApi->fake_outer_composite_serialize: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **outer_composite** | [**OuterComposite**](OuterComposite.md)| Input composite as post body | [optional] + +### Return type + +[**OuterComposite**](OuterComposite.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: */* + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Output composite | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **fake_outer_number_serialize** +> float fake_outer_number_serialize(body=body) + + + +Test serialization of outer number types + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + body = 3.4 # float | Input number as post body (optional) + + try: + api_response = api_instance.fake_outer_number_serialize(body=body) + print("The response of FakeApi->fake_outer_number_serialize:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling FakeApi->fake_outer_number_serialize: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **float**| Input number as post body | [optional] + +### Return type + +**float** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: */* + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Output number | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **fake_outer_string_serialize** +> str fake_outer_string_serialize(body=body) + + + +Test serialization of outer string types + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + body = 'body_example' # str | Input string as post body (optional) + + try: + api_response = api_instance.fake_outer_string_serialize(body=body) + print("The response of FakeApi->fake_outer_string_serialize:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling FakeApi->fake_outer_string_serialize: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **str**| Input string as post body | [optional] + +### Return type + +**str** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: */* + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Output string | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **fake_property_enum_integer_serialize** +> OuterObjectWithEnumProperty fake_property_enum_integer_serialize(outer_object_with_enum_property) + + + +Test serialization of enum (int) properties with examples + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.models.outer_object_with_enum_property import OuterObjectWithEnumProperty +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + outer_object_with_enum_property = petstore_api.OuterObjectWithEnumProperty() # OuterObjectWithEnumProperty | Input enum (int) as post body + + try: + api_response = api_instance.fake_property_enum_integer_serialize(outer_object_with_enum_property) + print("The response of FakeApi->fake_property_enum_integer_serialize:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling FakeApi->fake_property_enum_integer_serialize: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **outer_object_with_enum_property** | [**OuterObjectWithEnumProperty**](OuterObjectWithEnumProperty.md)| Input enum (int) as post body | + +### Return type + +[**OuterObjectWithEnumProperty**](OuterObjectWithEnumProperty.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: */* + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Output enum (int) | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **fake_return_list_of_objects** +> List[List[Tag]] fake_return_list_of_objects() + +test returning list of objects + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.models.tag import Tag +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + + try: + # test returning list of objects + api_response = api_instance.fake_return_list_of_objects() + print("The response of FakeApi->fake_return_list_of_objects:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling FakeApi->fake_return_list_of_objects: %s\n" % e) +``` + + + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**List[List[Tag]]** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | OK | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **fake_uuid_example** +> fake_uuid_example(uuid_example) + +test uuid example + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + uuid_example = '84529ad2-2265-4e15-b76b-c17025d848f6' # str | uuid example + + try: + # test uuid example + api_instance.fake_uuid_example(uuid_example) + except Exception as e: + print("Exception when calling FakeApi->fake_uuid_example: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **uuid_example** | **str**| uuid example | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Get successful | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **test_body_with_binary** +> test_body_with_binary(body) + + + +For this test, the body has to be a binary file. + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + body = None # bytearray | image to upload + + try: + api_instance.test_body_with_binary(body) + except Exception as e: + print("Exception when calling FakeApi->test_body_with_binary: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **bytearray**| image to upload | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: image/png + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Success | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **test_body_with_file_schema** +> test_body_with_file_schema(file_schema_test_class) + + + +For this test, the body for this request must reference a schema named `File`. + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.models.file_schema_test_class import FileSchemaTestClass +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + file_schema_test_class = petstore_api.FileSchemaTestClass() # FileSchemaTestClass | + + try: + api_instance.test_body_with_file_schema(file_schema_test_class) + except Exception as e: + print("Exception when calling FakeApi->test_body_with_file_schema: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **file_schema_test_class** | [**FileSchemaTestClass**](FileSchemaTestClass.md)| | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Success | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **test_body_with_query_params** +> test_body_with_query_params(query, user) + + + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.models.user import User +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + query = 'query_example' # str | + user = petstore_api.User() # User | + + try: + api_instance.test_body_with_query_params(query, user) + except Exception as e: + print("Exception when calling FakeApi->test_body_with_query_params: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **query** | **str**| | + **user** | [**User**](User.md)| | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Success | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **test_client_model** +> Client test_client_model(client) + +To test \"client\" model + +To test \"client\" model + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.models.client import Client +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + client = petstore_api.Client() # Client | client model + + try: + # To test \"client\" model + api_response = api_instance.test_client_model(client) + print("The response of FakeApi->test_client_model:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling FakeApi->test_client_model: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **client** | [**Client**](Client.md)| client model | + +### Return type + +[**Client**](Client.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **test_date_time_query_parameter** +> test_date_time_query_parameter(date_time_query, str_query) + + + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + date_time_query = '2013-10-20T19:20:30+01:00' # datetime | + str_query = 'str_query_example' # str | + + try: + api_instance.test_date_time_query_parameter(date_time_query, str_query) + except Exception as e: + print("Exception when calling FakeApi->test_date_time_query_parameter: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **date_time_query** | **datetime**| | + **str_query** | **str**| | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Success | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **test_endpoint_parameters** +> test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer=integer, int32=int32, int64=int64, float=float, string=string, binary=binary, byte_with_max_length=byte_with_max_length, var_date=var_date, date_time=date_time, password=password, param_callback=param_callback) + +Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + +Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + +### Example + +* Basic Authentication (http_basic_test): +```python +import time +import os +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure HTTP basic authorization: http_basic_test +configuration = petstore_api.Configuration( + username = os.environ["USERNAME"], + password = os.environ["PASSWORD"] +) + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + number = 3.4 # float | None + double = 3.4 # float | None + pattern_without_delimiter = 'pattern_without_delimiter_example' # str | None + byte = None # bytearray | None + integer = 56 # int | None (optional) + int32 = 56 # int | None (optional) + int64 = 56 # int | None (optional) + float = 3.4 # float | None (optional) + string = 'string_example' # str | None (optional) + binary = None # bytearray | None (optional) + byte_with_max_length = None # bytearray | None (optional) + var_date = '2013-10-20' # date | None (optional) + date_time = '2013-10-20T19:20:30+01:00' # datetime | None (optional) + password = 'password_example' # str | None (optional) + param_callback = 'param_callback_example' # str | None (optional) + + try: + # Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + api_instance.test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer=integer, int32=int32, int64=int64, float=float, string=string, binary=binary, byte_with_max_length=byte_with_max_length, var_date=var_date, date_time=date_time, password=password, param_callback=param_callback) + except Exception as e: + print("Exception when calling FakeApi->test_endpoint_parameters: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **number** | **float**| None | + **double** | **float**| None | + **pattern_without_delimiter** | **str**| None | + **byte** | **bytearray**| None | + **integer** | **int**| None | [optional] + **int32** | **int**| None | [optional] + **int64** | **int**| None | [optional] + **float** | **float**| None | [optional] + **string** | **str**| None | [optional] + **binary** | **bytearray**| None | [optional] + **byte_with_max_length** | **bytearray**| None | [optional] + **var_date** | **date**| None | [optional] + **date_time** | **datetime**| None | [optional] + **password** | **str**| None | [optional] + **param_callback** | **str**| None | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[http_basic_test](../README.md#http_basic_test) + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**400** | Invalid username supplied | - | +**404** | User not found | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **test_group_parameters** +> test_group_parameters(required_string_group, required_boolean_group, required_int64_group, string_group=string_group, boolean_group=boolean_group, int64_group=int64_group) + +Fake endpoint to test group parameters (optional) + +Fake endpoint to test group parameters (optional) + +### Example + +* Bearer (JWT) Authentication (bearer_test): +```python +import time +import os +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure Bearer authorization (JWT): bearer_test +configuration = petstore_api.Configuration( + access_token = os.environ["BEARER_TOKEN"] +) + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + required_string_group = 56 # int | Required String in group parameters + required_boolean_group = True # bool | Required Boolean in group parameters + required_int64_group = 56 # int | Required Integer in group parameters + string_group = 56 # int | String in group parameters (optional) + boolean_group = True # bool | Boolean in group parameters (optional) + int64_group = 56 # int | Integer in group parameters (optional) + + try: + # Fake endpoint to test group parameters (optional) + api_instance.test_group_parameters(required_string_group, required_boolean_group, required_int64_group, string_group=string_group, boolean_group=boolean_group, int64_group=int64_group) + except Exception as e: + print("Exception when calling FakeApi->test_group_parameters: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **required_string_group** | **int**| Required String in group parameters | + **required_boolean_group** | **bool**| Required Boolean in group parameters | + **required_int64_group** | **int**| Required Integer in group parameters | + **string_group** | **int**| String in group parameters | [optional] + **boolean_group** | **bool**| Boolean in group parameters | [optional] + **int64_group** | **int**| Integer in group parameters | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[bearer_test](../README.md#bearer_test) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**400** | Someting wrong | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **test_inline_additional_properties** +> test_inline_additional_properties(request_body) + +test inline additionalProperties + + + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + request_body = {'key': 'request_body_example'} # Dict[str, str] | request body + + try: + # test inline additionalProperties + api_instance.test_inline_additional_properties(request_body) + except Exception as e: + print("Exception when calling FakeApi->test_inline_additional_properties: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **request_body** | [**Dict[str, str]**](str.md)| request body | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **test_json_form_data** +> test_json_form_data(param, param2) + +test json serialization of form data + + + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + param = 'param_example' # str | field1 + param2 = 'param2_example' # str | field2 + + try: + # test json serialization of form data + api_instance.test_json_form_data(param, param2) + except Exception as e: + print("Exception when calling FakeApi->test_json_form_data: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **str**| field1 | + **param2** | **str**| field2 | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **test_query_parameter_collection_format** +> test_query_parameter_collection_format(pipe, ioutil, http, url, context, allow_empty, language=language) + + + +To test the collection format in query parameters + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + pipe = ['pipe_example'] # List[str] | + ioutil = ['ioutil_example'] # List[str] | + http = ['http_example'] # List[str] | + url = ['url_example'] # List[str] | + context = ['context_example'] # List[str] | + allow_empty = 'allow_empty_example' # str | + language = {'key': 'language_example'} # Dict[str, str] | (optional) + + try: + api_instance.test_query_parameter_collection_format(pipe, ioutil, http, url, context, allow_empty, language=language) + except Exception as e: + print("Exception when calling FakeApi->test_query_parameter_collection_format: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pipe** | [**List[str]**](str.md)| | + **ioutil** | [**List[str]**](str.md)| | + **http** | [**List[str]**](str.md)| | + **url** | [**List[str]**](str.md)| | + **context** | [**List[str]**](str.md)| | + **allow_empty** | **str**| | + **language** | [**Dict[str, str]**](str.md)| | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Success | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/docs/FakeClassnameTags123Api.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/FakeClassnameTags123Api.md new file mode 100644 index 000000000000..0319aac41cfc --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/FakeClassnameTags123Api.md @@ -0,0 +1,87 @@ +# petstore_api.FakeClassnameTags123Api + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**test_classname**](FakeClassnameTags123Api.md#test_classname) | **PATCH** /fake_classname_test | To test class name in snake case + + +# **test_classname** +> Client test_classname(client) + +To test class name in snake case + +To test class name in snake case + +### Example + +* Api Key Authentication (api_key_query): +```python +import time +import os +import petstore_api +from petstore_api.models.client import Client +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure API key authorization: api_key_query +configuration.api_key['api_key_query'] = os.environ["API_KEY"] + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['api_key_query'] = 'Bearer' + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeClassnameTags123Api(api_client) + client = petstore_api.Client() # Client | client model + + try: + # To test class name in snake case + api_response = api_instance.test_classname(client) + print("The response of FakeClassnameTags123Api->test_classname:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling FakeClassnameTags123Api->test_classname: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **client** | [**Client**](Client.md)| client model | + +### Return type + +[**Client**](Client.md) + +### Authorization + +[api_key_query](../README.md#api_key_query) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/docs/File.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/File.md new file mode 100644 index 000000000000..586da8e32559 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/File.md @@ -0,0 +1,29 @@ +# File + +Must be named `File` for test. + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**source_uri** | **str** | Test capitalization | [optional] + +## Example + +```python +from petstore_api.models.file import File + +# TODO update the JSON string below +json = "{}" +# create an instance of File from a JSON string +file_instance = File.from_json(json) +# print the JSON string representation of the object +print File.to_json() + +# convert the object into a dict +file_dict = file_instance.to_dict() +# create an instance of File from a dict +file_form_dict = file.from_dict(file_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/FileSchemaTestClass.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/FileSchemaTestClass.md new file mode 100644 index 000000000000..fb967a8d9924 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/FileSchemaTestClass.md @@ -0,0 +1,29 @@ +# FileSchemaTestClass + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**file** | [**File**](File.md) | | [optional] +**files** | [**List[File]**](File.md) | | [optional] + +## Example + +```python +from petstore_api.models.file_schema_test_class import FileSchemaTestClass + +# TODO update the JSON string below +json = "{}" +# create an instance of FileSchemaTestClass from a JSON string +file_schema_test_class_instance = FileSchemaTestClass.from_json(json) +# print the JSON string representation of the object +print FileSchemaTestClass.to_json() + +# convert the object into a dict +file_schema_test_class_dict = file_schema_test_class_instance.to_dict() +# create an instance of FileSchemaTestClass from a dict +file_schema_test_class_form_dict = file_schema_test_class.from_dict(file_schema_test_class_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/FirstRef.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/FirstRef.md new file mode 100644 index 000000000000..b5e7ab766b45 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/FirstRef.md @@ -0,0 +1,29 @@ +# FirstRef + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**category** | **str** | | [optional] +**self_ref** | [**SecondRef**](SecondRef.md) | | [optional] + +## Example + +```python +from petstore_api.models.first_ref import FirstRef + +# TODO update the JSON string below +json = "{}" +# create an instance of FirstRef from a JSON string +first_ref_instance = FirstRef.from_json(json) +# print the JSON string representation of the object +print FirstRef.to_json() + +# convert the object into a dict +first_ref_dict = first_ref_instance.to_dict() +# create an instance of FirstRef from a dict +first_ref_form_dict = first_ref.from_dict(first_ref_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/Foo.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Foo.md new file mode 100644 index 000000000000..8062d08df1dd --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Foo.md @@ -0,0 +1,28 @@ +# Foo + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**bar** | **str** | | [optional] [default to 'bar'] + +## Example + +```python +from petstore_api.models.foo import Foo + +# TODO update the JSON string below +json = "{}" +# create an instance of Foo from a JSON string +foo_instance = Foo.from_json(json) +# print the JSON string representation of the object +print Foo.to_json() + +# convert the object into a dict +foo_dict = foo_instance.to_dict() +# create an instance of Foo from a dict +foo_form_dict = foo.from_dict(foo_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/FooGetDefaultResponse.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/FooGetDefaultResponse.md new file mode 100644 index 000000000000..550fbe78fa17 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/FooGetDefaultResponse.md @@ -0,0 +1,28 @@ +# FooGetDefaultResponse + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**string** | [**Foo**](Foo.md) | | [optional] + +## Example + +```python +from petstore_api.models.foo_get_default_response import FooGetDefaultResponse + +# TODO update the JSON string below +json = "{}" +# create an instance of FooGetDefaultResponse from a JSON string +foo_get_default_response_instance = FooGetDefaultResponse.from_json(json) +# print the JSON string representation of the object +print FooGetDefaultResponse.to_json() + +# convert the object into a dict +foo_get_default_response_dict = foo_get_default_response_instance.to_dict() +# create an instance of FooGetDefaultResponse from a dict +foo_get_default_response_form_dict = foo_get_default_response.from_dict(foo_get_default_response_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/FormatTest.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/FormatTest.md new file mode 100644 index 000000000000..aa81e585952f --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/FormatTest.md @@ -0,0 +1,44 @@ +# FormatTest + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**integer** | **int** | | [optional] +**int32** | **int** | | [optional] +**int64** | **int** | | [optional] +**number** | **float** | | +**float** | **float** | | [optional] +**double** | **float** | | [optional] +**decimal** | **decimal.Decimal** | | [optional] +**string** | **str** | | [optional] +**string_with_double_quote_pattern** | **str** | | [optional] +**byte** | **bytearray** | | [optional] +**binary** | **bytearray** | | [optional] +**var_date** | **date** | | +**date_time** | **datetime** | | [optional] +**uuid** | **str** | | [optional] +**password** | **str** | | +**pattern_with_digits** | **str** | A string that is a 10 digit number. Can have leading zeros. | [optional] +**pattern_with_digits_and_delimiter** | **str** | A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. | [optional] + +## Example + +```python +from petstore_api.models.format_test import FormatTest + +# TODO update the JSON string below +json = "{}" +# create an instance of FormatTest from a JSON string +format_test_instance = FormatTest.from_json(json) +# print the JSON string representation of the object +print FormatTest.to_json() + +# convert the object into a dict +format_test_dict = format_test_instance.to_dict() +# create an instance of FormatTest from a dict +format_test_form_dict = format_test.from_dict(format_test_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/HasOnlyReadOnly.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/HasOnlyReadOnly.md new file mode 100644 index 000000000000..99573bd28a2f --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/HasOnlyReadOnly.md @@ -0,0 +1,29 @@ +# HasOnlyReadOnly + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**bar** | **str** | | [optional] [readonly] +**foo** | **str** | | [optional] [readonly] + +## Example + +```python +from petstore_api.models.has_only_read_only import HasOnlyReadOnly + +# TODO update the JSON string below +json = "{}" +# create an instance of HasOnlyReadOnly from a JSON string +has_only_read_only_instance = HasOnlyReadOnly.from_json(json) +# print the JSON string representation of the object +print HasOnlyReadOnly.to_json() + +# convert the object into a dict +has_only_read_only_dict = has_only_read_only_instance.to_dict() +# create an instance of HasOnlyReadOnly from a dict +has_only_read_only_form_dict = has_only_read_only.from_dict(has_only_read_only_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/HealthCheckResult.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/HealthCheckResult.md new file mode 100644 index 000000000000..b8723e018aa1 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/HealthCheckResult.md @@ -0,0 +1,29 @@ +# HealthCheckResult + +Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**nullable_message** | **str** | | [optional] + +## Example + +```python +from petstore_api.models.health_check_result import HealthCheckResult + +# TODO update the JSON string below +json = "{}" +# create an instance of HealthCheckResult from a JSON string +health_check_result_instance = HealthCheckResult.from_json(json) +# print the JSON string representation of the object +print HealthCheckResult.to_json() + +# convert the object into a dict +health_check_result_dict = health_check_result_instance.to_dict() +# create an instance of HealthCheckResult from a dict +health_check_result_form_dict = health_check_result.from_dict(health_check_result_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/InnerDictWithProperty.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/InnerDictWithProperty.md new file mode 100644 index 000000000000..45d76ad458c4 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/InnerDictWithProperty.md @@ -0,0 +1,28 @@ +# InnerDictWithProperty + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**a_property** | **object** | | [optional] + +## Example + +```python +from petstore_api.models.inner_dict_with_property import InnerDictWithProperty + +# TODO update the JSON string below +json = "{}" +# create an instance of InnerDictWithProperty from a JSON string +inner_dict_with_property_instance = InnerDictWithProperty.from_json(json) +# print the JSON string representation of the object +print InnerDictWithProperty.to_json() + +# convert the object into a dict +inner_dict_with_property_dict = inner_dict_with_property_instance.to_dict() +# create an instance of InnerDictWithProperty from a dict +inner_dict_with_property_form_dict = inner_dict_with_property.from_dict(inner_dict_with_property_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/IntOrString.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/IntOrString.md new file mode 100644 index 000000000000..0a441f186dbc --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/IntOrString.md @@ -0,0 +1,27 @@ +# IntOrString + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +## Example + +```python +from petstore_api.models.int_or_string import IntOrString + +# TODO update the JSON string below +json = "{}" +# create an instance of IntOrString from a JSON string +int_or_string_instance = IntOrString.from_json(json) +# print the JSON string representation of the object +print IntOrString.to_json() + +# convert the object into a dict +int_or_string_dict = int_or_string_instance.to_dict() +# create an instance of IntOrString from a dict +int_or_string_form_dict = int_or_string.from_dict(int_or_string_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/List.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/List.md new file mode 100644 index 000000000000..7643e4ea92dd --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/List.md @@ -0,0 +1,28 @@ +# List + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**var_123_list** | **str** | | [optional] + +## Example + +```python +from petstore_api.models.list import List + +# TODO update the JSON string below +json = "{}" +# create an instance of List from a JSON string +list_instance = List.from_json(json) +# print the JSON string representation of the object +print List.to_json() + +# convert the object into a dict +list_dict = list_instance.to_dict() +# create an instance of List from a dict +list_form_dict = list.from_dict(list_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/MapOfArrayOfModel.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/MapOfArrayOfModel.md new file mode 100644 index 000000000000..b97ace0f42c8 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/MapOfArrayOfModel.md @@ -0,0 +1,28 @@ +# MapOfArrayOfModel + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**shop_id_to_org_online_lip_map** | **Dict[str, List[Tag]]** | | [optional] + +## Example + +```python +from petstore_api.models.map_of_array_of_model import MapOfArrayOfModel + +# TODO update the JSON string below +json = "{}" +# create an instance of MapOfArrayOfModel from a JSON string +map_of_array_of_model_instance = MapOfArrayOfModel.from_json(json) +# print the JSON string representation of the object +print MapOfArrayOfModel.to_json() + +# convert the object into a dict +map_of_array_of_model_dict = map_of_array_of_model_instance.to_dict() +# create an instance of MapOfArrayOfModel from a dict +map_of_array_of_model_form_dict = map_of_array_of_model.from_dict(map_of_array_of_model_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/MapTest.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/MapTest.md new file mode 100644 index 000000000000..ba87758a5220 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/MapTest.md @@ -0,0 +1,31 @@ +# MapTest + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**map_map_of_string** | **Dict[str, Dict[str, str]]** | | [optional] +**map_of_enum_string** | **Dict[str, str]** | | [optional] +**direct_map** | **Dict[str, bool]** | | [optional] +**indirect_map** | **Dict[str, bool]** | | [optional] + +## Example + +```python +from petstore_api.models.map_test import MapTest + +# TODO update the JSON string below +json = "{}" +# create an instance of MapTest from a JSON string +map_test_instance = MapTest.from_json(json) +# print the JSON string representation of the object +print MapTest.to_json() + +# convert the object into a dict +map_test_dict = map_test_instance.to_dict() +# create an instance of MapTest from a dict +map_test_form_dict = map_test.from_dict(map_test_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/MixedPropertiesAndAdditionalPropertiesClass.md new file mode 100644 index 000000000000..8f628d133abf --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/MixedPropertiesAndAdditionalPropertiesClass.md @@ -0,0 +1,30 @@ +# MixedPropertiesAndAdditionalPropertiesClass + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**uuid** | **str** | | [optional] +**date_time** | **datetime** | | [optional] +**map** | [**Dict[str, Animal]**](Animal.md) | | [optional] + +## Example + +```python +from petstore_api.models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass + +# TODO update the JSON string below +json = "{}" +# create an instance of MixedPropertiesAndAdditionalPropertiesClass from a JSON string +mixed_properties_and_additional_properties_class_instance = MixedPropertiesAndAdditionalPropertiesClass.from_json(json) +# print the JSON string representation of the object +print MixedPropertiesAndAdditionalPropertiesClass.to_json() + +# convert the object into a dict +mixed_properties_and_additional_properties_class_dict = mixed_properties_and_additional_properties_class_instance.to_dict() +# create an instance of MixedPropertiesAndAdditionalPropertiesClass from a dict +mixed_properties_and_additional_properties_class_form_dict = mixed_properties_and_additional_properties_class.from_dict(mixed_properties_and_additional_properties_class_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/Model200Response.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Model200Response.md new file mode 100644 index 000000000000..6a20cefe99cb --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Model200Response.md @@ -0,0 +1,30 @@ +# Model200Response + +Model for testing model name starting with number + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **int** | | [optional] +**var_class** | **str** | | [optional] + +## Example + +```python +from petstore_api.models.model200_response import Model200Response + +# TODO update the JSON string below +json = "{}" +# create an instance of Model200Response from a JSON string +model200_response_instance = Model200Response.from_json(json) +# print the JSON string representation of the object +print Model200Response.to_json() + +# convert the object into a dict +model200_response_dict = model200_response_instance.to_dict() +# create an instance of Model200Response from a dict +model200_response_form_dict = model200_response.from_dict(model200_response_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/ModelReturn.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/ModelReturn.md new file mode 100644 index 000000000000..a5b47f423c81 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/ModelReturn.md @@ -0,0 +1,29 @@ +# ModelReturn + +Model for testing reserved words + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**var_return** | **int** | | [optional] + +## Example + +```python +from petstore_api.models.model_return import ModelReturn + +# TODO update the JSON string below +json = "{}" +# create an instance of ModelReturn from a JSON string +model_return_instance = ModelReturn.from_json(json) +# print the JSON string representation of the object +print ModelReturn.to_json() + +# convert the object into a dict +model_return_dict = model_return_instance.to_dict() +# create an instance of ModelReturn from a dict +model_return_form_dict = model_return.from_dict(model_return_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/Name.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Name.md new file mode 100644 index 000000000000..4ccd0ce09aa2 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Name.md @@ -0,0 +1,32 @@ +# Name + +Model for testing model name same as property name + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **int** | | +**snake_case** | **int** | | [optional] [readonly] +**var_property** | **str** | | [optional] +**var_123_number** | **int** | | [optional] [readonly] + +## Example + +```python +from petstore_api.models.name import Name + +# TODO update the JSON string below +json = "{}" +# create an instance of Name from a JSON string +name_instance = Name.from_json(json) +# print the JSON string representation of the object +print Name.to_json() + +# convert the object into a dict +name_dict = name_instance.to_dict() +# create an instance of Name from a dict +name_form_dict = name.from_dict(name_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/NullableClass.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/NullableClass.md new file mode 100644 index 000000000000..1658756b50e4 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/NullableClass.md @@ -0,0 +1,40 @@ +# NullableClass + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**required_integer_prop** | **int** | | +**integer_prop** | **int** | | [optional] +**number_prop** | **float** | | [optional] +**boolean_prop** | **bool** | | [optional] +**string_prop** | **str** | | [optional] +**date_prop** | **date** | | [optional] +**datetime_prop** | **datetime** | | [optional] +**array_nullable_prop** | **List[object]** | | [optional] +**array_and_items_nullable_prop** | **List[object]** | | [optional] +**array_items_nullable** | **List[object]** | | [optional] +**object_nullable_prop** | **Dict[str, object]** | | [optional] +**object_and_items_nullable_prop** | **Dict[str, object]** | | [optional] +**object_items_nullable** | **Dict[str, object]** | | [optional] + +## Example + +```python +from petstore_api.models.nullable_class import NullableClass + +# TODO update the JSON string below +json = "{}" +# create an instance of NullableClass from a JSON string +nullable_class_instance = NullableClass.from_json(json) +# print the JSON string representation of the object +print NullableClass.to_json() + +# convert the object into a dict +nullable_class_dict = nullable_class_instance.to_dict() +# create an instance of NullableClass from a dict +nullable_class_form_dict = nullable_class.from_dict(nullable_class_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/NullableProperty.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/NullableProperty.md new file mode 100644 index 000000000000..fd9cbbc51aaa --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/NullableProperty.md @@ -0,0 +1,29 @@ +# NullableProperty + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | +**name** | **str** | | + +## Example + +```python +from petstore_api.models.nullable_property import NullableProperty + +# TODO update the JSON string below +json = "{}" +# create an instance of NullableProperty from a JSON string +nullable_property_instance = NullableProperty.from_json(json) +# print the JSON string representation of the object +print NullableProperty.to_json() + +# convert the object into a dict +nullable_property_dict = nullable_property_instance.to_dict() +# create an instance of NullableProperty from a dict +nullable_property_form_dict = nullable_property.from_dict(nullable_property_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/NumberOnly.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/NumberOnly.md new file mode 100644 index 000000000000..f49216ddaa4e --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/NumberOnly.md @@ -0,0 +1,28 @@ +# NumberOnly + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**just_number** | **float** | | [optional] + +## Example + +```python +from petstore_api.models.number_only import NumberOnly + +# TODO update the JSON string below +json = "{}" +# create an instance of NumberOnly from a JSON string +number_only_instance = NumberOnly.from_json(json) +# print the JSON string representation of the object +print NumberOnly.to_json() + +# convert the object into a dict +number_only_dict = number_only_instance.to_dict() +# create an instance of NumberOnly from a dict +number_only_form_dict = number_only.from_dict(number_only_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/ObjectToTestAdditionalProperties.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/ObjectToTestAdditionalProperties.md new file mode 100644 index 000000000000..c4ba9a958503 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/ObjectToTestAdditionalProperties.md @@ -0,0 +1,29 @@ +# ObjectToTestAdditionalProperties + +Minimal object + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**var_property** | **bool** | Property | [optional] [default to False] + +## Example + +```python +from petstore_api.models.object_to_test_additional_properties import ObjectToTestAdditionalProperties + +# TODO update the JSON string below +json = "{}" +# create an instance of ObjectToTestAdditionalProperties from a JSON string +object_to_test_additional_properties_instance = ObjectToTestAdditionalProperties.from_json(json) +# print the JSON string representation of the object +print ObjectToTestAdditionalProperties.to_json() + +# convert the object into a dict +object_to_test_additional_properties_dict = object_to_test_additional_properties_instance.to_dict() +# create an instance of ObjectToTestAdditionalProperties from a dict +object_to_test_additional_properties_form_dict = object_to_test_additional_properties.from_dict(object_to_test_additional_properties_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/ObjectWithDeprecatedFields.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/ObjectWithDeprecatedFields.md new file mode 100644 index 000000000000..8daa55a39161 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/ObjectWithDeprecatedFields.md @@ -0,0 +1,31 @@ +# ObjectWithDeprecatedFields + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**uuid** | **str** | | [optional] +**id** | **float** | | [optional] +**deprecated_ref** | [**DeprecatedObject**](DeprecatedObject.md) | | [optional] +**bars** | **List[str]** | | [optional] + +## Example + +```python +from petstore_api.models.object_with_deprecated_fields import ObjectWithDeprecatedFields + +# TODO update the JSON string below +json = "{}" +# create an instance of ObjectWithDeprecatedFields from a JSON string +object_with_deprecated_fields_instance = ObjectWithDeprecatedFields.from_json(json) +# print the JSON string representation of the object +print ObjectWithDeprecatedFields.to_json() + +# convert the object into a dict +object_with_deprecated_fields_dict = object_with_deprecated_fields_instance.to_dict() +# create an instance of ObjectWithDeprecatedFields from a dict +object_with_deprecated_fields_form_dict = object_with_deprecated_fields.from_dict(object_with_deprecated_fields_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/OneOfEnumString.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/OneOfEnumString.md new file mode 100644 index 000000000000..c7c28bc29440 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/OneOfEnumString.md @@ -0,0 +1,28 @@ +# OneOfEnumString + +oneOf enum strings + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +## Example + +```python +from petstore_api.models.one_of_enum_string import OneOfEnumString + +# TODO update the JSON string below +json = "{}" +# create an instance of OneOfEnumString from a JSON string +one_of_enum_string_instance = OneOfEnumString.from_json(json) +# print the JSON string representation of the object +print OneOfEnumString.to_json() + +# convert the object into a dict +one_of_enum_string_dict = one_of_enum_string_instance.to_dict() +# create an instance of OneOfEnumString from a dict +one_of_enum_string_form_dict = one_of_enum_string.from_dict(one_of_enum_string_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/Order.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Order.md new file mode 100644 index 000000000000..e71e955a11dd --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Order.md @@ -0,0 +1,33 @@ +# Order + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**pet_id** | **int** | | [optional] +**quantity** | **int** | | [optional] +**ship_date** | **datetime** | | [optional] +**status** | **str** | Order Status | [optional] +**complete** | **bool** | | [optional] [default to False] + +## Example + +```python +from petstore_api.models.order import Order + +# TODO update the JSON string below +json = "{}" +# create an instance of Order from a JSON string +order_instance = Order.from_json(json) +# print the JSON string representation of the object +print Order.to_json() + +# convert the object into a dict +order_dict = order_instance.to_dict() +# create an instance of Order from a dict +order_form_dict = order.from_dict(order_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/OuterComposite.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/OuterComposite.md new file mode 100644 index 000000000000..504e266f9a14 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/OuterComposite.md @@ -0,0 +1,30 @@ +# OuterComposite + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**my_number** | **float** | | [optional] +**my_string** | **str** | | [optional] +**my_boolean** | **bool** | | [optional] + +## Example + +```python +from petstore_api.models.outer_composite import OuterComposite + +# TODO update the JSON string below +json = "{}" +# create an instance of OuterComposite from a JSON string +outer_composite_instance = OuterComposite.from_json(json) +# print the JSON string representation of the object +print OuterComposite.to_json() + +# convert the object into a dict +outer_composite_dict = outer_composite_instance.to_dict() +# create an instance of OuterComposite from a dict +outer_composite_form_dict = outer_composite.from_dict(outer_composite_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/OuterEnum.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/OuterEnum.md new file mode 100644 index 000000000000..4cb31437c7e2 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/OuterEnum.md @@ -0,0 +1,10 @@ +# OuterEnum + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/openapi3/client/petstore/python-pydantic-v2/docs/OuterEnumDefaultValue.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/OuterEnumDefaultValue.md new file mode 100644 index 000000000000..4a5ba6428d83 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/OuterEnumDefaultValue.md @@ -0,0 +1,10 @@ +# OuterEnumDefaultValue + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/openapi3/client/petstore/python-pydantic-v2/docs/OuterEnumInteger.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/OuterEnumInteger.md new file mode 100644 index 000000000000..fc84ec365851 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/OuterEnumInteger.md @@ -0,0 +1,10 @@ +# OuterEnumInteger + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/openapi3/client/petstore/python-pydantic-v2/docs/OuterEnumIntegerDefaultValue.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/OuterEnumIntegerDefaultValue.md new file mode 100644 index 000000000000..0de4199a8401 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/OuterEnumIntegerDefaultValue.md @@ -0,0 +1,10 @@ +# OuterEnumIntegerDefaultValue + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/openapi3/client/petstore/python-pydantic-v2/docs/OuterObjectWithEnumProperty.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/OuterObjectWithEnumProperty.md new file mode 100644 index 000000000000..c6a1cdcbc193 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/OuterObjectWithEnumProperty.md @@ -0,0 +1,29 @@ +# OuterObjectWithEnumProperty + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**str_value** | [**OuterEnum**](OuterEnum.md) | | [optional] +**value** | [**OuterEnumInteger**](OuterEnumInteger.md) | | + +## Example + +```python +from petstore_api.models.outer_object_with_enum_property import OuterObjectWithEnumProperty + +# TODO update the JSON string below +json = "{}" +# create an instance of OuterObjectWithEnumProperty from a JSON string +outer_object_with_enum_property_instance = OuterObjectWithEnumProperty.from_json(json) +# print the JSON string representation of the object +print OuterObjectWithEnumProperty.to_json() + +# convert the object into a dict +outer_object_with_enum_property_dict = outer_object_with_enum_property_instance.to_dict() +# create an instance of OuterObjectWithEnumProperty from a dict +outer_object_with_enum_property_form_dict = outer_object_with_enum_property.from_dict(outer_object_with_enum_property_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/Parent.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Parent.md new file mode 100644 index 000000000000..9a963a6b722d --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Parent.md @@ -0,0 +1,28 @@ +# Parent + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**optional_dict** | [**Dict[str, InnerDictWithProperty]**](InnerDictWithProperty.md) | | [optional] + +## Example + +```python +from petstore_api.models.parent import Parent + +# TODO update the JSON string below +json = "{}" +# create an instance of Parent from a JSON string +parent_instance = Parent.from_json(json) +# print the JSON string representation of the object +print Parent.to_json() + +# convert the object into a dict +parent_dict = parent_instance.to_dict() +# create an instance of Parent from a dict +parent_form_dict = parent.from_dict(parent_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/ParentWithOptionalDict.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/ParentWithOptionalDict.md new file mode 100644 index 000000000000..04bf94942019 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/ParentWithOptionalDict.md @@ -0,0 +1,28 @@ +# ParentWithOptionalDict + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**optional_dict** | [**Dict[str, InnerDictWithProperty]**](InnerDictWithProperty.md) | | [optional] + +## Example + +```python +from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict + +# TODO update the JSON string below +json = "{}" +# create an instance of ParentWithOptionalDict from a JSON string +parent_with_optional_dict_instance = ParentWithOptionalDict.from_json(json) +# print the JSON string representation of the object +print ParentWithOptionalDict.to_json() + +# convert the object into a dict +parent_with_optional_dict_dict = parent_with_optional_dict_instance.to_dict() +# create an instance of ParentWithOptionalDict from a dict +parent_with_optional_dict_form_dict = parent_with_optional_dict.from_dict(parent_with_optional_dict_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/Pet.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Pet.md new file mode 100644 index 000000000000..05a466f880a3 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Pet.md @@ -0,0 +1,33 @@ +# Pet + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**category** | [**Category**](Category.md) | | [optional] +**name** | **str** | | +**photo_urls** | **List[str]** | | +**tags** | [**List[Tag]**](Tag.md) | | [optional] +**status** | **str** | pet status in the store | [optional] + +## Example + +```python +from petstore_api.models.pet import Pet + +# TODO update the JSON string below +json = "{}" +# create an instance of Pet from a JSON string +pet_instance = Pet.from_json(json) +# print the JSON string representation of the object +print Pet.to_json() + +# convert the object into a dict +pet_dict = pet_instance.to_dict() +# create an instance of Pet from a dict +pet_form_dict = pet.from_dict(pet_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/PetApi.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/PetApi.md new file mode 100644 index 000000000000..8a0202f37531 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/PetApi.md @@ -0,0 +1,953 @@ +# petstore_api.PetApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**add_pet**](PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store +[**delete_pet**](PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet +[**find_pets_by_status**](PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status +[**find_pets_by_tags**](PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags +[**get_pet_by_id**](PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID +[**update_pet**](PetApi.md#update_pet) | **PUT** /pet | Update an existing pet +[**update_pet_with_form**](PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data +[**upload_file**](PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image +[**upload_file_with_required_file**](PetApi.md#upload_file_with_required_file) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) + + +# **add_pet** +> add_pet(pet) + +Add a new pet to the store + + + +### Example + +* OAuth Authentication (petstore_auth): +```python +import time +import os +import petstore_api +from petstore_api.models.pet import Pet +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +configuration.access_token = os.environ["ACCESS_TOKEN"] + +# Configure HTTP message signature: http_signature_test +# The HTTP Signature Header mechanism that can be used by a client to +# authenticate the sender of a message and ensure that particular headers +# have not been modified in transit. +# +# You can specify the signing key-id, private key path, signing scheme, +# signing algorithm, list of signed headers and signature max validity. +# The 'key_id' parameter is an opaque string that the API server can use +# to lookup the client and validate the signature. +# The 'private_key_path' parameter should be the path to a file that +# contains a DER or base-64 encoded private key. +# The 'private_key_passphrase' parameter is optional. Set the passphrase +# if the private key is encrypted. +# The 'signed_headers' parameter is used to specify the list of +# HTTP headers included when generating the signature for the message. +# You can specify HTTP headers that you want to protect with a cryptographic +# signature. Note that proxies may add, modify or remove HTTP headers +# for legitimate reasons, so you should only add headers that you know +# will not be modified. For example, if you want to protect the HTTP request +# body, you can specify the Digest header. In that case, the client calculates +# the digest of the HTTP request body and includes the digest in the message +# signature. +# The 'signature_max_validity' parameter is optional. It is configured as a +# duration to express when the signature ceases to be valid. The client calculates +# the expiration date every time it generates the cryptographic signature +# of an HTTP request. The API server may have its own security policy +# that controls the maximum validity of the signature. The client max validity +# must be lower than the server max validity. +# The time on the client and server must be synchronized, otherwise the +# server may reject the client signature. +# +# The client must use a combination of private key, signing scheme, +# signing algorithm and hash algorithm that matches the security policy of +# the API server. +# +# See petstore_api.signing for a list of all supported parameters. +from petstore_api import signing +import datetime + +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2", + signing_info = petstore_api.HttpSigningConfiguration( + key_id = 'my-key-id', + private_key_path = 'private_key.pem', + private_key_passphrase = 'YOUR_PASSPHRASE', + signing_scheme = petstore_api.signing.SCHEME_HS2019, + signing_algorithm = petstore_api.signing.ALGORITHM_ECDSA_MODE_FIPS_186_3, + hash_algorithm = petstore_api.signing.SCHEME_RSA_SHA256, + signed_headers = [ + petstore_api.signing.HEADER_REQUEST_TARGET, + petstore_api.signing.HEADER_CREATED, + petstore_api.signing.HEADER_EXPIRES, + petstore_api.signing.HEADER_HOST, + petstore_api.signing.HEADER_DATE, + petstore_api.signing.HEADER_DIGEST, + 'Content-Type', + 'Content-Length', + 'User-Agent' + ], + signature_max_validity = datetime.timedelta(minutes=5) + ) +) + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.PetApi(api_client) + pet = petstore_api.Pet() # Pet | Pet object that needs to be added to the store + + try: + # Add a new pet to the store + api_instance.add_pet(pet) + except Exception as e: + print("Exception when calling PetApi->add_pet: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth), [http_signature_test](../README.md#http_signature_test) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful operation | - | +**405** | Invalid input | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **delete_pet** +> delete_pet(pet_id, api_key=api_key) + +Deletes a pet + + + +### Example + +* OAuth Authentication (petstore_auth): +```python +import time +import os +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +configuration.access_token = os.environ["ACCESS_TOKEN"] + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.PetApi(api_client) + pet_id = 56 # int | Pet id to delete + api_key = 'api_key_example' # str | (optional) + + try: + # Deletes a pet + api_instance.delete_pet(pet_id, api_key=api_key) + except Exception as e: + print("Exception when calling PetApi->delete_pet: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| Pet id to delete | + **api_key** | **str**| | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful operation | - | +**400** | Invalid pet value | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **find_pets_by_status** +> List[Pet] find_pets_by_status(status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example + +* OAuth Authentication (petstore_auth): +```python +import time +import os +import petstore_api +from petstore_api.models.pet import Pet +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +configuration.access_token = os.environ["ACCESS_TOKEN"] + +# Configure HTTP message signature: http_signature_test +# The HTTP Signature Header mechanism that can be used by a client to +# authenticate the sender of a message and ensure that particular headers +# have not been modified in transit. +# +# You can specify the signing key-id, private key path, signing scheme, +# signing algorithm, list of signed headers and signature max validity. +# The 'key_id' parameter is an opaque string that the API server can use +# to lookup the client and validate the signature. +# The 'private_key_path' parameter should be the path to a file that +# contains a DER or base-64 encoded private key. +# The 'private_key_passphrase' parameter is optional. Set the passphrase +# if the private key is encrypted. +# The 'signed_headers' parameter is used to specify the list of +# HTTP headers included when generating the signature for the message. +# You can specify HTTP headers that you want to protect with a cryptographic +# signature. Note that proxies may add, modify or remove HTTP headers +# for legitimate reasons, so you should only add headers that you know +# will not be modified. For example, if you want to protect the HTTP request +# body, you can specify the Digest header. In that case, the client calculates +# the digest of the HTTP request body and includes the digest in the message +# signature. +# The 'signature_max_validity' parameter is optional. It is configured as a +# duration to express when the signature ceases to be valid. The client calculates +# the expiration date every time it generates the cryptographic signature +# of an HTTP request. The API server may have its own security policy +# that controls the maximum validity of the signature. The client max validity +# must be lower than the server max validity. +# The time on the client and server must be synchronized, otherwise the +# server may reject the client signature. +# +# The client must use a combination of private key, signing scheme, +# signing algorithm and hash algorithm that matches the security policy of +# the API server. +# +# See petstore_api.signing for a list of all supported parameters. +from petstore_api import signing +import datetime + +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2", + signing_info = petstore_api.HttpSigningConfiguration( + key_id = 'my-key-id', + private_key_path = 'private_key.pem', + private_key_passphrase = 'YOUR_PASSPHRASE', + signing_scheme = petstore_api.signing.SCHEME_HS2019, + signing_algorithm = petstore_api.signing.ALGORITHM_ECDSA_MODE_FIPS_186_3, + hash_algorithm = petstore_api.signing.SCHEME_RSA_SHA256, + signed_headers = [ + petstore_api.signing.HEADER_REQUEST_TARGET, + petstore_api.signing.HEADER_CREATED, + petstore_api.signing.HEADER_EXPIRES, + petstore_api.signing.HEADER_HOST, + petstore_api.signing.HEADER_DATE, + petstore_api.signing.HEADER_DIGEST, + 'Content-Type', + 'Content-Length', + 'User-Agent' + ], + signature_max_validity = datetime.timedelta(minutes=5) + ) +) + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.PetApi(api_client) + status = ['status_example'] # List[str] | Status values that need to be considered for filter + + try: + # Finds Pets by status + api_response = api_instance.find_pets_by_status(status) + print("The response of PetApi->find_pets_by_status:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling PetApi->find_pets_by_status: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | [**List[str]**](str.md)| Status values that need to be considered for filter | + +### Return type + +[**List[Pet]**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth), [http_signature_test](../README.md#http_signature_test) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | +**400** | Invalid status value | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **find_pets_by_tags** +> List[Pet] find_pets_by_tags(tags) + +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Example + +* OAuth Authentication (petstore_auth): +```python +import time +import os +import petstore_api +from petstore_api.models.pet import Pet +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +configuration.access_token = os.environ["ACCESS_TOKEN"] + +# Configure HTTP message signature: http_signature_test +# The HTTP Signature Header mechanism that can be used by a client to +# authenticate the sender of a message and ensure that particular headers +# have not been modified in transit. +# +# You can specify the signing key-id, private key path, signing scheme, +# signing algorithm, list of signed headers and signature max validity. +# The 'key_id' parameter is an opaque string that the API server can use +# to lookup the client and validate the signature. +# The 'private_key_path' parameter should be the path to a file that +# contains a DER or base-64 encoded private key. +# The 'private_key_passphrase' parameter is optional. Set the passphrase +# if the private key is encrypted. +# The 'signed_headers' parameter is used to specify the list of +# HTTP headers included when generating the signature for the message. +# You can specify HTTP headers that you want to protect with a cryptographic +# signature. Note that proxies may add, modify or remove HTTP headers +# for legitimate reasons, so you should only add headers that you know +# will not be modified. For example, if you want to protect the HTTP request +# body, you can specify the Digest header. In that case, the client calculates +# the digest of the HTTP request body and includes the digest in the message +# signature. +# The 'signature_max_validity' parameter is optional. It is configured as a +# duration to express when the signature ceases to be valid. The client calculates +# the expiration date every time it generates the cryptographic signature +# of an HTTP request. The API server may have its own security policy +# that controls the maximum validity of the signature. The client max validity +# must be lower than the server max validity. +# The time on the client and server must be synchronized, otherwise the +# server may reject the client signature. +# +# The client must use a combination of private key, signing scheme, +# signing algorithm and hash algorithm that matches the security policy of +# the API server. +# +# See petstore_api.signing for a list of all supported parameters. +from petstore_api import signing +import datetime + +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2", + signing_info = petstore_api.HttpSigningConfiguration( + key_id = 'my-key-id', + private_key_path = 'private_key.pem', + private_key_passphrase = 'YOUR_PASSPHRASE', + signing_scheme = petstore_api.signing.SCHEME_HS2019, + signing_algorithm = petstore_api.signing.ALGORITHM_ECDSA_MODE_FIPS_186_3, + hash_algorithm = petstore_api.signing.SCHEME_RSA_SHA256, + signed_headers = [ + petstore_api.signing.HEADER_REQUEST_TARGET, + petstore_api.signing.HEADER_CREATED, + petstore_api.signing.HEADER_EXPIRES, + petstore_api.signing.HEADER_HOST, + petstore_api.signing.HEADER_DATE, + petstore_api.signing.HEADER_DIGEST, + 'Content-Type', + 'Content-Length', + 'User-Agent' + ], + signature_max_validity = datetime.timedelta(minutes=5) + ) +) + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.PetApi(api_client) + tags = ['tags_example'] # List[str] | Tags to filter by + + try: + # Finds Pets by tags + api_response = api_instance.find_pets_by_tags(tags) + print("The response of PetApi->find_pets_by_tags:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling PetApi->find_pets_by_tags: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **tags** | [**List[str]**](str.md)| Tags to filter by | + +### Return type + +[**List[Pet]**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth), [http_signature_test](../README.md#http_signature_test) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | +**400** | Invalid tag value | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_pet_by_id** +> Pet get_pet_by_id(pet_id) + +Find pet by ID + +Returns a single pet + +### Example + +* Api Key Authentication (api_key): +```python +import time +import os +import petstore_api +from petstore_api.models.pet import Pet +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure API key authorization: api_key +configuration.api_key['api_key'] = os.environ["API_KEY"] + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['api_key'] = 'Bearer' + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.PetApi(api_client) + pet_id = 56 # int | ID of pet to return + + try: + # Find pet by ID + api_response = api_instance.get_pet_by_id(pet_id) + print("The response of PetApi->get_pet_by_id:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling PetApi->get_pet_by_id: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet to return | + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | +**400** | Invalid ID supplied | - | +**404** | Pet not found | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **update_pet** +> update_pet(pet) + +Update an existing pet + + + +### Example + +* OAuth Authentication (petstore_auth): +```python +import time +import os +import petstore_api +from petstore_api.models.pet import Pet +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +configuration.access_token = os.environ["ACCESS_TOKEN"] + +# Configure HTTP message signature: http_signature_test +# The HTTP Signature Header mechanism that can be used by a client to +# authenticate the sender of a message and ensure that particular headers +# have not been modified in transit. +# +# You can specify the signing key-id, private key path, signing scheme, +# signing algorithm, list of signed headers and signature max validity. +# The 'key_id' parameter is an opaque string that the API server can use +# to lookup the client and validate the signature. +# The 'private_key_path' parameter should be the path to a file that +# contains a DER or base-64 encoded private key. +# The 'private_key_passphrase' parameter is optional. Set the passphrase +# if the private key is encrypted. +# The 'signed_headers' parameter is used to specify the list of +# HTTP headers included when generating the signature for the message. +# You can specify HTTP headers that you want to protect with a cryptographic +# signature. Note that proxies may add, modify or remove HTTP headers +# for legitimate reasons, so you should only add headers that you know +# will not be modified. For example, if you want to protect the HTTP request +# body, you can specify the Digest header. In that case, the client calculates +# the digest of the HTTP request body and includes the digest in the message +# signature. +# The 'signature_max_validity' parameter is optional. It is configured as a +# duration to express when the signature ceases to be valid. The client calculates +# the expiration date every time it generates the cryptographic signature +# of an HTTP request. The API server may have its own security policy +# that controls the maximum validity of the signature. The client max validity +# must be lower than the server max validity. +# The time on the client and server must be synchronized, otherwise the +# server may reject the client signature. +# +# The client must use a combination of private key, signing scheme, +# signing algorithm and hash algorithm that matches the security policy of +# the API server. +# +# See petstore_api.signing for a list of all supported parameters. +from petstore_api import signing +import datetime + +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2", + signing_info = petstore_api.HttpSigningConfiguration( + key_id = 'my-key-id', + private_key_path = 'private_key.pem', + private_key_passphrase = 'YOUR_PASSPHRASE', + signing_scheme = petstore_api.signing.SCHEME_HS2019, + signing_algorithm = petstore_api.signing.ALGORITHM_ECDSA_MODE_FIPS_186_3, + hash_algorithm = petstore_api.signing.SCHEME_RSA_SHA256, + signed_headers = [ + petstore_api.signing.HEADER_REQUEST_TARGET, + petstore_api.signing.HEADER_CREATED, + petstore_api.signing.HEADER_EXPIRES, + petstore_api.signing.HEADER_HOST, + petstore_api.signing.HEADER_DATE, + petstore_api.signing.HEADER_DIGEST, + 'Content-Type', + 'Content-Length', + 'User-Agent' + ], + signature_max_validity = datetime.timedelta(minutes=5) + ) +) + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.PetApi(api_client) + pet = petstore_api.Pet() # Pet | Pet object that needs to be added to the store + + try: + # Update an existing pet + api_instance.update_pet(pet) + except Exception as e: + print("Exception when calling PetApi->update_pet: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth), [http_signature_test](../README.md#http_signature_test) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful operation | - | +**400** | Invalid ID supplied | - | +**404** | Pet not found | - | +**405** | Validation exception | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **update_pet_with_form** +> update_pet_with_form(pet_id, name=name, status=status) + +Updates a pet in the store with form data + + + +### Example + +* OAuth Authentication (petstore_auth): +```python +import time +import os +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +configuration.access_token = os.environ["ACCESS_TOKEN"] + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.PetApi(api_client) + pet_id = 56 # int | ID of pet that needs to be updated + name = 'name_example' # str | Updated name of the pet (optional) + status = 'status_example' # str | Updated status of the pet (optional) + + try: + # Updates a pet in the store with form data + api_instance.update_pet_with_form(pet_id, name=name, status=status) + except Exception as e: + print("Exception when calling PetApi->update_pet_with_form: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet that needs to be updated | + **name** | **str**| Updated name of the pet | [optional] + **status** | **str**| Updated status of the pet | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful operation | - | +**405** | Invalid input | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **upload_file** +> ApiResponse upload_file(pet_id, additional_metadata=additional_metadata, file=file) + +uploads an image + + + +### Example + +* OAuth Authentication (petstore_auth): +```python +import time +import os +import petstore_api +from petstore_api.models.api_response import ApiResponse +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +configuration.access_token = os.environ["ACCESS_TOKEN"] + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.PetApi(api_client) + pet_id = 56 # int | ID of pet to update + additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional) + file = None # bytearray | file to upload (optional) + + try: + # uploads an image + api_response = api_instance.upload_file(pet_id, additional_metadata=additional_metadata, file=file) + print("The response of PetApi->upload_file:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling PetApi->upload_file: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet to update | + **additional_metadata** | **str**| Additional data to pass to server | [optional] + **file** | **bytearray**| file to upload | [optional] + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **upload_file_with_required_file** +> ApiResponse upload_file_with_required_file(pet_id, required_file, additional_metadata=additional_metadata) + +uploads an image (required) + + + +### Example + +* OAuth Authentication (petstore_auth): +```python +import time +import os +import petstore_api +from petstore_api.models.api_response import ApiResponse +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +configuration.access_token = os.environ["ACCESS_TOKEN"] + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.PetApi(api_client) + pet_id = 56 # int | ID of pet to update + required_file = None # bytearray | file to upload + additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional) + + try: + # uploads an image (required) + api_response = api_instance.upload_file_with_required_file(pet_id, required_file, additional_metadata=additional_metadata) + print("The response of PetApi->upload_file_with_required_file:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling PetApi->upload_file_with_required_file: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet to update | + **required_file** | **bytearray**| file to upload | + **additional_metadata** | **str**| Additional data to pass to server | [optional] + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/docs/Pig.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Pig.md new file mode 100644 index 000000000000..398d6c6c6e38 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Pig.md @@ -0,0 +1,30 @@ +# Pig + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**class_name** | **str** | | +**color** | **str** | | +**size** | **int** | | + +## Example + +```python +from petstore_api.models.pig import Pig + +# TODO update the JSON string below +json = "{}" +# create an instance of Pig from a JSON string +pig_instance = Pig.from_json(json) +# print the JSON string representation of the object +print Pig.to_json() + +# convert the object into a dict +pig_dict = pig_instance.to_dict() +# create an instance of Pig from a dict +pig_form_dict = pig.from_dict(pig_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/PropertyNameCollision.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/PropertyNameCollision.md new file mode 100644 index 000000000000..1a9303701b0a --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/PropertyNameCollision.md @@ -0,0 +1,30 @@ +# PropertyNameCollision + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**underscore_type** | **str** | | [optional] +**type** | **str** | | [optional] +**type_with_underscore** | **str** | | [optional] + +## Example + +```python +from petstore_api.models.property_name_collision import PropertyNameCollision + +# TODO update the JSON string below +json = "{}" +# create an instance of PropertyNameCollision from a JSON string +property_name_collision_instance = PropertyNameCollision.from_json(json) +# print the JSON string representation of the object +print PropertyNameCollision.to_json() + +# convert the object into a dict +property_name_collision_dict = property_name_collision_instance.to_dict() +# create an instance of PropertyNameCollision from a dict +property_name_collision_form_dict = property_name_collision.from_dict(property_name_collision_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/ReadOnlyFirst.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/ReadOnlyFirst.md new file mode 100644 index 000000000000..22b5acca70c7 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/ReadOnlyFirst.md @@ -0,0 +1,29 @@ +# ReadOnlyFirst + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**bar** | **str** | | [optional] [readonly] +**baz** | **str** | | [optional] + +## Example + +```python +from petstore_api.models.read_only_first import ReadOnlyFirst + +# TODO update the JSON string below +json = "{}" +# create an instance of ReadOnlyFirst from a JSON string +read_only_first_instance = ReadOnlyFirst.from_json(json) +# print the JSON string representation of the object +print ReadOnlyFirst.to_json() + +# convert the object into a dict +read_only_first_dict = read_only_first_instance.to_dict() +# create an instance of ReadOnlyFirst from a dict +read_only_first_form_dict = read_only_first.from_dict(read_only_first_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/SecondRef.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/SecondRef.md new file mode 100644 index 000000000000..e6fb1e2d4f7c --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/SecondRef.md @@ -0,0 +1,29 @@ +# SecondRef + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**category** | **str** | | [optional] +**circular_ref** | [**CircularReferenceModel**](CircularReferenceModel.md) | | [optional] + +## Example + +```python +from petstore_api.models.second_ref import SecondRef + +# TODO update the JSON string below +json = "{}" +# create an instance of SecondRef from a JSON string +second_ref_instance = SecondRef.from_json(json) +# print the JSON string representation of the object +print SecondRef.to_json() + +# convert the object into a dict +second_ref_dict = second_ref_instance.to_dict() +# create an instance of SecondRef from a dict +second_ref_form_dict = second_ref.from_dict(second_ref_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/SelfReferenceModel.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/SelfReferenceModel.md new file mode 100644 index 000000000000..dbf9589d576b --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/SelfReferenceModel.md @@ -0,0 +1,29 @@ +# SelfReferenceModel + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**size** | **int** | | [optional] +**nested** | [**DummyModel**](DummyModel.md) | | [optional] + +## Example + +```python +from petstore_api.models.self_reference_model import SelfReferenceModel + +# TODO update the JSON string below +json = "{}" +# create an instance of SelfReferenceModel from a JSON string +self_reference_model_instance = SelfReferenceModel.from_json(json) +# print the JSON string representation of the object +print SelfReferenceModel.to_json() + +# convert the object into a dict +self_reference_model_dict = self_reference_model_instance.to_dict() +# create an instance of SelfReferenceModel from a dict +self_reference_model_form_dict = self_reference_model.from_dict(self_reference_model_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/SingleRefType.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/SingleRefType.md new file mode 100644 index 000000000000..4178ac3b505e --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/SingleRefType.md @@ -0,0 +1,10 @@ +# SingleRefType + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/openapi3/client/petstore/python-pydantic-v2/docs/SpecialCharacterEnum.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/SpecialCharacterEnum.md new file mode 100644 index 000000000000..801c3b5c8459 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/SpecialCharacterEnum.md @@ -0,0 +1,10 @@ +# SpecialCharacterEnum + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/openapi3/client/petstore/python-pydantic-v2/docs/SpecialModelName.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/SpecialModelName.md new file mode 100644 index 000000000000..3d27640abb04 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/SpecialModelName.md @@ -0,0 +1,28 @@ +# SpecialModelName + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**special_property_name** | **int** | | [optional] + +## Example + +```python +from petstore_api.models.special_model_name import SpecialModelName + +# TODO update the JSON string below +json = "{}" +# create an instance of SpecialModelName from a JSON string +special_model_name_instance = SpecialModelName.from_json(json) +# print the JSON string representation of the object +print SpecialModelName.to_json() + +# convert the object into a dict +special_model_name_dict = special_model_name_instance.to_dict() +# create an instance of SpecialModelName from a dict +special_model_name_form_dict = special_model_name.from_dict(special_model_name_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/SpecialName.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/SpecialName.md new file mode 100644 index 000000000000..0b4129525978 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/SpecialName.md @@ -0,0 +1,30 @@ +# SpecialName + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**var_property** | **int** | | [optional] +**var_async** | [**Category**](Category.md) | | [optional] +**var_schema** | **str** | pet status in the store | [optional] + +## Example + +```python +from petstore_api.models.special_name import SpecialName + +# TODO update the JSON string below +json = "{}" +# create an instance of SpecialName from a JSON string +special_name_instance = SpecialName.from_json(json) +# print the JSON string representation of the object +print SpecialName.to_json() + +# convert the object into a dict +special_name_dict = special_name_instance.to_dict() +# create an instance of SpecialName from a dict +special_name_form_dict = special_name.from_dict(special_name_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/StoreApi.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/StoreApi.md new file mode 100644 index 000000000000..9a4c0ec8c002 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/StoreApi.md @@ -0,0 +1,287 @@ +# petstore_api.StoreApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**delete_order**](StoreApi.md#delete_order) | **DELETE** /store/order/{order_id} | Delete purchase order by ID +[**get_inventory**](StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status +[**get_order_by_id**](StoreApi.md#get_order_by_id) | **GET** /store/order/{order_id} | Find purchase order by ID +[**place_order**](StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet + + +# **delete_order** +> delete_order(order_id) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.StoreApi(api_client) + order_id = 'order_id_example' # str | ID of the order that needs to be deleted + + try: + # Delete purchase order by ID + api_instance.delete_order(order_id) + except Exception as e: + print("Exception when calling StoreApi->delete_order: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order_id** | **str**| ID of the order that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**400** | Invalid ID supplied | - | +**404** | Order not found | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_inventory** +> Dict[str, int] get_inventory() + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example + +* Api Key Authentication (api_key): +```python +import time +import os +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure API key authorization: api_key +configuration.api_key['api_key'] = os.environ["API_KEY"] + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['api_key'] = 'Bearer' + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.StoreApi(api_client) + + try: + # Returns pet inventories by status + api_response = api_instance.get_inventory() + print("The response of StoreApi->get_inventory:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling StoreApi->get_inventory: %s\n" % e) +``` + + + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**Dict[str, int]** + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_order_by_id** +> Order get_order_by_id(order_id) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.models.order import Order +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.StoreApi(api_client) + order_id = 56 # int | ID of pet that needs to be fetched + + try: + # Find purchase order by ID + api_response = api_instance.get_order_by_id(order_id) + print("The response of StoreApi->get_order_by_id:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling StoreApi->get_order_by_id: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order_id** | **int**| ID of pet that needs to be fetched | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | +**400** | Invalid ID supplied | - | +**404** | Order not found | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **place_order** +> Order place_order(order) + +Place an order for a pet + + + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.models.order import Order +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.StoreApi(api_client) + order = petstore_api.Order() # Order | order placed for purchasing the pet + + try: + # Place an order for a pet + api_response = api_instance.place_order(order) + print("The response of StoreApi->place_order:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling StoreApi->place_order: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order** | [**Order**](Order.md)| order placed for purchasing the pet | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | +**400** | Invalid Order | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/docs/Tag.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Tag.md new file mode 100644 index 000000000000..e680c68bedd8 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Tag.md @@ -0,0 +1,29 @@ +# Tag + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**name** | **str** | | [optional] + +## Example + +```python +from petstore_api.models.tag import Tag + +# TODO update the JSON string below +json = "{}" +# create an instance of Tag from a JSON string +tag_instance = Tag.from_json(json) +# print the JSON string representation of the object +print Tag.to_json() + +# convert the object into a dict +tag_dict = tag_instance.to_dict() +# create an instance of Tag from a dict +tag_form_dict = tag.from_dict(tag_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/Tiger.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Tiger.md new file mode 100644 index 000000000000..6ce50a31f5ae --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/Tiger.md @@ -0,0 +1,28 @@ +# Tiger + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**skill** | **str** | | [optional] + +## Example + +```python +from petstore_api.models.tiger import Tiger + +# TODO update the JSON string below +json = "{}" +# create an instance of Tiger from a JSON string +tiger_instance = Tiger.from_json(json) +# print the JSON string representation of the object +print Tiger.to_json() + +# convert the object into a dict +tiger_dict = tiger_instance.to_dict() +# create an instance of Tiger from a dict +tiger_form_dict = tiger.from_dict(tiger_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/User.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/User.md new file mode 100644 index 000000000000..6d7c357ea865 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/User.md @@ -0,0 +1,35 @@ +# User + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**username** | **str** | | [optional] +**first_name** | **str** | | [optional] +**last_name** | **str** | | [optional] +**email** | **str** | | [optional] +**password** | **str** | | [optional] +**phone** | **str** | | [optional] +**user_status** | **int** | User Status | [optional] + +## Example + +```python +from petstore_api.models.user import User + +# TODO update the JSON string below +json = "{}" +# create an instance of User from a JSON string +user_instance = User.from_json(json) +# print the JSON string representation of the object +print User.to_json() + +# convert the object into a dict +user_dict = user_instance.to_dict() +# create an instance of User from a dict +user_form_dict = user.from_dict(user_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/docs/UserApi.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/UserApi.md new file mode 100644 index 000000000000..810e75e12717 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/UserApi.md @@ -0,0 +1,542 @@ +# petstore_api.UserApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**create_user**](UserApi.md#create_user) | **POST** /user | Create user +[**create_users_with_array_input**](UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array +[**create_users_with_list_input**](UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array +[**delete_user**](UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user +[**get_user_by_name**](UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name +[**login_user**](UserApi.md#login_user) | **GET** /user/login | Logs user into the system +[**logout_user**](UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session +[**update_user**](UserApi.md#update_user) | **PUT** /user/{username} | Updated user + + +# **create_user** +> create_user(user) + +Create user + +This can only be done by the logged in user. + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.models.user import User +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.UserApi(api_client) + user = petstore_api.User() # User | Created user object + + try: + # Create user + api_instance.create_user(user) + except Exception as e: + print("Exception when calling UserApi->create_user: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **user** | [**User**](User.md)| Created user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**0** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **create_users_with_array_input** +> create_users_with_array_input(user) + +Creates list of users with given input array + + + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.models.user import User +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.UserApi(api_client) + user = [petstore_api.User()] # List[User] | List of user object + + try: + # Creates list of users with given input array + api_instance.create_users_with_array_input(user) + except Exception as e: + print("Exception when calling UserApi->create_users_with_array_input: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **user** | [**List[User]**](User.md)| List of user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**0** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **create_users_with_list_input** +> create_users_with_list_input(user) + +Creates list of users with given input array + + + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.models.user import User +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.UserApi(api_client) + user = [petstore_api.User()] # List[User] | List of user object + + try: + # Creates list of users with given input array + api_instance.create_users_with_list_input(user) + except Exception as e: + print("Exception when calling UserApi->create_users_with_list_input: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **user** | [**List[User]**](User.md)| List of user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**0** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **delete_user** +> delete_user(username) + +Delete user + +This can only be done by the logged in user. + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.UserApi(api_client) + username = 'username_example' # str | The name that needs to be deleted + + try: + # Delete user + api_instance.delete_user(username) + except Exception as e: + print("Exception when calling UserApi->delete_user: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **str**| The name that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**400** | Invalid username supplied | - | +**404** | User not found | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_user_by_name** +> User get_user_by_name(username) + +Get user by user name + + + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.models.user import User +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.UserApi(api_client) + username = 'username_example' # str | The name that needs to be fetched. Use user1 for testing. + + try: + # Get user by user name + api_response = api_instance.get_user_by_name(username) + print("The response of UserApi->get_user_by_name:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling UserApi->get_user_by_name: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **str**| The name that needs to be fetched. Use user1 for testing. | + +### Return type + +[**User**](User.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | +**400** | Invalid username supplied | - | +**404** | User not found | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **login_user** +> str login_user(username, password) + +Logs user into the system + + + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.UserApi(api_client) + username = 'username_example' # str | The user name for login + password = 'password_example' # str | The password for login in clear text + + try: + # Logs user into the system + api_response = api_instance.login_user(username, password) + print("The response of UserApi->login_user:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling UserApi->login_user: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **str**| The user name for login | + **password** | **str**| The password for login in clear text | + +### Return type + +**str** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | * X-Rate-Limit - calls per hour allowed by the user
* X-Expires-After - date in UTC when token expires
| +**400** | Invalid username/password supplied | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **logout_user** +> logout_user() + +Logs out current logged in user session + + + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.UserApi(api_client) + + try: + # Logs out current logged in user session + api_instance.logout_user() + except Exception as e: + print("Exception when calling UserApi->logout_user: %s\n" % e) +``` + + + +### Parameters +This endpoint does not need any parameter. + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**0** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **update_user** +> update_user(username, user) + +Updated user + +This can only be done by the logged in user. + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.models.user import User +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.UserApi(api_client) + username = 'username_example' # str | name that need to be deleted + user = petstore_api.User() # User | Updated user object + + try: + # Updated user + api_instance.update_user(username, user) + except Exception as e: + print("Exception when calling UserApi->update_user: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **str**| name that need to be deleted | + **user** | [**User**](User.md)| Updated user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**400** | Invalid user supplied | - | +**404** | User not found | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/docs/WithNestedOneOf.md b/samples/openapi3/client/petstore/python-pydantic-v2/docs/WithNestedOneOf.md new file mode 100644 index 000000000000..247afcab99da --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/docs/WithNestedOneOf.md @@ -0,0 +1,30 @@ +# WithNestedOneOf + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**size** | **int** | | [optional] +**nested_pig** | [**Pig**](Pig.md) | | [optional] +**nested_oneof_enum_string** | [**OneOfEnumString**](OneOfEnumString.md) | | [optional] + +## Example + +```python +from petstore_api.models.with_nested_one_of import WithNestedOneOf + +# TODO update the JSON string below +json = "{}" +# create an instance of WithNestedOneOf from a JSON string +with_nested_one_of_instance = WithNestedOneOf.from_json(json) +# print the JSON string representation of the object +print WithNestedOneOf.to_json() + +# convert the object into a dict +with_nested_one_of_dict = with_nested_one_of_instance.to_dict() +# create an instance of WithNestedOneOf from a dict +with_nested_one_of_form_dict = with_nested_one_of.from_dict(with_nested_one_of_dict) +``` +[[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/openapi3/client/petstore/python-pydantic-v2/git_push.sh b/samples/openapi3/client/petstore/python-pydantic-v2/git_push.sh new file mode 100755 index 000000000000..f53a75d4fabe --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/git_push.sh @@ -0,0 +1,57 @@ +#!/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/openapi3/client/petstore/python-pydantic-v2/petstore_api/__init__.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/__init__.py new file mode 100755 index 000000000000..2fb3745aeaa2 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/__init__.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +# flake8: noqa + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +__version__ = "1.0.0" + +# import apis into sdk package +from petstore_api.api.another_fake_api import AnotherFakeApi +from petstore_api.api.default_api import DefaultApi +from petstore_api.api.fake_api import FakeApi +from petstore_api.api.fake_classname_tags123_api import FakeClassnameTags123Api +from petstore_api.api.pet_api import PetApi +from petstore_api.api.store_api import StoreApi +from petstore_api.api.user_api import UserApi + +# import ApiClient +from petstore_api.api_response import ApiResponse +from petstore_api.api_client import ApiClient +from petstore_api.configuration import Configuration +from petstore_api.exceptions import OpenApiException +from petstore_api.exceptions import ApiTypeError +from petstore_api.exceptions import ApiValueError +from petstore_api.exceptions import ApiKeyError +from petstore_api.exceptions import ApiAttributeError +from petstore_api.exceptions import ApiException +from petstore_api.signing import HttpSigningConfiguration + +# import models into sdk package +from petstore_api.models.additional_properties_any_type import AdditionalPropertiesAnyType +from petstore_api.models.additional_properties_class import AdditionalPropertiesClass +from petstore_api.models.additional_properties_object import AdditionalPropertiesObject +from petstore_api.models.additional_properties_with_description_only import AdditionalPropertiesWithDescriptionOnly +from petstore_api.models.all_of_with_single_ref import AllOfWithSingleRef +from petstore_api.models.animal import Animal +from petstore_api.models.any_of_color import AnyOfColor +from petstore_api.models.any_of_pig import AnyOfPig +from petstore_api.models.api_response import ApiResponse +from petstore_api.models.array_of_array_of_model import ArrayOfArrayOfModel +from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly +from petstore_api.models.array_of_number_only import ArrayOfNumberOnly +from petstore_api.models.array_test import ArrayTest +from petstore_api.models.basque_pig import BasquePig +from petstore_api.models.capitalization import Capitalization +from petstore_api.models.cat import Cat +from petstore_api.models.category import Category +from petstore_api.models.class_model import ClassModel +from petstore_api.models.client import Client +from petstore_api.models.color import Color +from petstore_api.models.creature import Creature +from petstore_api.models.creature_info import CreatureInfo +from petstore_api.models.danish_pig import DanishPig +from petstore_api.models.deprecated_object import DeprecatedObject +from petstore_api.models.dog import Dog +from petstore_api.models.dummy_model import DummyModel +from petstore_api.models.enum_arrays import EnumArrays +from petstore_api.models.enum_class import EnumClass +from petstore_api.models.enum_string1 import EnumString1 +from petstore_api.models.enum_string2 import EnumString2 +from petstore_api.models.enum_test import EnumTest +from petstore_api.models.file import File +from petstore_api.models.file_schema_test_class import FileSchemaTestClass +from petstore_api.models.foo import Foo +from petstore_api.models.foo_get_default_response import FooGetDefaultResponse +from petstore_api.models.format_test import FormatTest +from petstore_api.models.has_only_read_only import HasOnlyReadOnly +from petstore_api.models.health_check_result import HealthCheckResult +from petstore_api.models.inner_dict_with_property import InnerDictWithProperty +from petstore_api.models.int_or_string import IntOrString +from petstore_api.models.list import List +from petstore_api.models.map_of_array_of_model import MapOfArrayOfModel +from petstore_api.models.map_test import MapTest +from petstore_api.models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass +from petstore_api.models.model200_response import Model200Response +from petstore_api.models.model_return import ModelReturn +from petstore_api.models.name import Name +from petstore_api.models.nullable_class import NullableClass +from petstore_api.models.nullable_property import NullableProperty +from petstore_api.models.number_only import NumberOnly +from petstore_api.models.object_to_test_additional_properties import ObjectToTestAdditionalProperties +from petstore_api.models.object_with_deprecated_fields import ObjectWithDeprecatedFields +from petstore_api.models.one_of_enum_string import OneOfEnumString +from petstore_api.models.order import Order +from petstore_api.models.outer_composite import OuterComposite +from petstore_api.models.outer_enum import OuterEnum +from petstore_api.models.outer_enum_default_value import OuterEnumDefaultValue +from petstore_api.models.outer_enum_integer import OuterEnumInteger +from petstore_api.models.outer_enum_integer_default_value import OuterEnumIntegerDefaultValue +from petstore_api.models.outer_object_with_enum_property import OuterObjectWithEnumProperty +from petstore_api.models.parent import Parent +from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict +from petstore_api.models.pet import Pet +from petstore_api.models.pig import Pig +from petstore_api.models.property_name_collision import PropertyNameCollision +from petstore_api.models.read_only_first import ReadOnlyFirst +from petstore_api.models.self_reference_model import SelfReferenceModel +from petstore_api.models.single_ref_type import SingleRefType +from petstore_api.models.special_character_enum import SpecialCharacterEnum +from petstore_api.models.special_model_name import SpecialModelName +from petstore_api.models.special_name import SpecialName +from petstore_api.models.tag import Tag +from petstore_api.models.tiger import Tiger +from petstore_api.models.user import User +from petstore_api.models.with_nested_one_of import WithNestedOneOf diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api/__init__.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api/__init__.py new file mode 100755 index 000000000000..7a2616975a2f --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api/__init__.py @@ -0,0 +1,11 @@ +# flake8: noqa + +# import apis into api package +from petstore_api.api.another_fake_api import AnotherFakeApi +from petstore_api.api.default_api import DefaultApi +from petstore_api.api.fake_api import FakeApi +from petstore_api.api.fake_classname_tags123_api import FakeClassnameTags123Api +from petstore_api.api.pet_api import PetApi +from petstore_api.api.store_api import StoreApi +from petstore_api.api.user_api import UserApi + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api/another_fake_api.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api/another_fake_api.py new file mode 100755 index 000000000000..854834190fc9 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api/another_fake_api.py @@ -0,0 +1,192 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import re # noqa: F401 +import io +import warnings + +from pydantic import validate_call, ValidationError +from typing_extensions import Annotated + +from typing_extensions import Annotated +from pydantic import Field + +from petstore_api.models.client import Client + +from petstore_api.api_client import ApiClient +from petstore_api.api_response import ApiResponse +from petstore_api.exceptions import ( # noqa: F401 + ApiTypeError, + ApiValueError +) + + +class AnotherFakeApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_call + def call_123_test_special_tags(self, client : Annotated[Client, Field(..., description="client model")], **kwargs) -> Client: # noqa: E501 + """To test special tags # noqa: E501 + + To test special tags and operation ID starting with number # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.call_123_test_special_tags(client, async_req=True) + >>> result = thread.get() + + :param client: client model (required) + :type client: Client + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: Client + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the call_123_test_special_tags_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.call_123_test_special_tags_with_http_info(client, **kwargs) # noqa: E501 + + @validate_call + def call_123_test_special_tags_with_http_info(self, client : Annotated[Client, Field(..., description="client model")], **kwargs) -> ApiResponse: # noqa: E501 + """To test special tags # noqa: E501 + + To test special tags and operation ID starting with number # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.call_123_test_special_tags_with_http_info(client, async_req=True) + >>> result = thread.get() + + :param client: client model (required) + :type client: Client + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(Client, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'client' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method call_123_test_special_tags" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['client'] is not None: + _body_params = _params['client'] + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "Client", + } + + return self.api_client.call_api( + '/another-fake/dummy', 'PATCH', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api/default_api.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api/default_api.py new file mode 100755 index 000000000000..7b1eb01ebd3d --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api/default_api.py @@ -0,0 +1,171 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import re # noqa: F401 +import io +import warnings + +from pydantic import validate_call, ValidationError +from typing_extensions import Annotated + +from petstore_api.models.foo_get_default_response import FooGetDefaultResponse + +from petstore_api.api_client import ApiClient +from petstore_api.api_response import ApiResponse +from petstore_api.exceptions import ( # noqa: F401 + ApiTypeError, + ApiValueError +) + + +class DefaultApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_call + def foo_get(self, **kwargs) -> FooGetDefaultResponse: # noqa: E501 + """foo_get # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.foo_get(async_req=True) + >>> result = thread.get() + + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: FooGetDefaultResponse + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the foo_get_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.foo_get_with_http_info(**kwargs) # noqa: E501 + + @validate_call + def foo_get_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 + """foo_get # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.foo_get_with_http_info(async_req=True) + >>> result = thread.get() + + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(FooGetDefaultResponse, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method foo_get" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + } + + return self.api_client.call_api( + '/foo', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api/fake_api.py new file mode 100755 index 000000000000..71ce52841e8d --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api/fake_api.py @@ -0,0 +1,3238 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import re # noqa: F401 +import io +import warnings + +from pydantic import validate_call, ValidationError +from typing_extensions import Annotated + +from typing_extensions import Annotated +from datetime import date, datetime + +from pydantic import Field, StrictBool, StrictBytes, StrictFloat, StrictInt, StrictStr, conbytes, confloat, conint, conlist, constr, validator + +from typing import Any, Dict, List, Optional, Union + +from petstore_api.models.client import Client +from petstore_api.models.enum_class import EnumClass +from petstore_api.models.file_schema_test_class import FileSchemaTestClass +from petstore_api.models.health_check_result import HealthCheckResult +from petstore_api.models.outer_composite import OuterComposite +from petstore_api.models.outer_object_with_enum_property import OuterObjectWithEnumProperty +from petstore_api.models.pet import Pet +from petstore_api.models.tag import Tag +from petstore_api.models.user import User + +from petstore_api.api_client import ApiClient +from petstore_api.api_response import ApiResponse +from petstore_api.exceptions import ( # noqa: F401 + ApiTypeError, + ApiValueError +) + + +class FakeApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_call + def fake_any_type_request_body(self, body : Optional[Dict[str, Any]] = None, **kwargs) -> None: # noqa: E501 + """test any type request body # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.fake_any_type_request_body(body, async_req=True) + >>> result = thread.get() + + :param body: + :type body: object + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the fake_any_type_request_body_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.fake_any_type_request_body_with_http_info(body, **kwargs) # noqa: E501 + + @validate_call + def fake_any_type_request_body_with_http_info(self, body : Optional[Dict[str, Any]] = None, **kwargs) -> ApiResponse: # noqa: E501 + """test any type request body # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.fake_any_type_request_body_with_http_info(body, async_req=True) + >>> result = thread.get() + + :param body: + :type body: object + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + 'body' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method fake_any_type_request_body" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['body'] is not None: + _body_params = _params['body'] + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/fake/any_type_body', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def fake_enum_ref_query_parameter(self, enum_ref : Annotated[Optional[EnumClass], Field(description="enum reference")] = None, **kwargs) -> None: # noqa: E501 + """test enum reference query parameter # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.fake_enum_ref_query_parameter(enum_ref, async_req=True) + >>> result = thread.get() + + :param enum_ref: enum reference + :type enum_ref: EnumClass + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the fake_enum_ref_query_parameter_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.fake_enum_ref_query_parameter_with_http_info(enum_ref, **kwargs) # noqa: E501 + + @validate_call + def fake_enum_ref_query_parameter_with_http_info(self, enum_ref : Annotated[Optional[EnumClass], Field(description="enum reference")] = None, **kwargs) -> ApiResponse: # noqa: E501 + """test enum reference query parameter # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.fake_enum_ref_query_parameter_with_http_info(enum_ref, async_req=True) + >>> result = thread.get() + + :param enum_ref: enum reference + :type enum_ref: EnumClass + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + 'enum_ref' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method fake_enum_ref_query_parameter" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + if _params.get('enum_ref') is not None: # noqa: E501 + _query_params.append(('enum_ref', _params['enum_ref'].value)) + + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/fake/enum_ref_query_parameter', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def fake_health_get(self, **kwargs) -> HealthCheckResult: # noqa: E501 + """Health check endpoint # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.fake_health_get(async_req=True) + >>> result = thread.get() + + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: HealthCheckResult + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the fake_health_get_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.fake_health_get_with_http_info(**kwargs) # noqa: E501 + + @validate_call + def fake_health_get_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 + """Health check endpoint # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.fake_health_get_with_http_info(async_req=True) + >>> result = thread.get() + + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(HealthCheckResult, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method fake_health_get" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "HealthCheckResult", + } + + return self.api_client.call_api( + '/fake/health', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def fake_http_signature_test(self, pet : Annotated[Pet, Field(..., description="Pet object that needs to be added to the store")], query_1 : Annotated[Optional[StrictStr], Field(description="query parameter")] = None, header_1 : Annotated[Optional[StrictStr], Field(description="header parameter")] = None, **kwargs) -> None: # noqa: E501 + """test http signature authentication # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.fake_http_signature_test(pet, query_1, header_1, async_req=True) + >>> result = thread.get() + + :param pet: Pet object that needs to be added to the store (required) + :type pet: Pet + :param query_1: query parameter + :type query_1: str + :param header_1: header parameter + :type header_1: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the fake_http_signature_test_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.fake_http_signature_test_with_http_info(pet, query_1, header_1, **kwargs) # noqa: E501 + + @validate_call + def fake_http_signature_test_with_http_info(self, pet : Annotated[Pet, Field(..., description="Pet object that needs to be added to the store")], query_1 : Annotated[Optional[StrictStr], Field(description="query parameter")] = None, header_1 : Annotated[Optional[StrictStr], Field(description="header parameter")] = None, **kwargs) -> ApiResponse: # noqa: E501 + """test http signature authentication # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.fake_http_signature_test_with_http_info(pet, query_1, header_1, async_req=True) + >>> result = thread.get() + + :param pet: Pet object that needs to be added to the store (required) + :type pet: Pet + :param query_1: query parameter + :type query_1: str + :param header_1: header parameter + :type header_1: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + 'pet', + 'query_1', + 'header_1' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method fake_http_signature_test" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + if _params.get('query_1') is not None: # noqa: E501 + _query_params.append(('query_1', _params['query_1'])) + + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + if _params['header_1']: + _header_params['header_1'] = _params['header_1'] + + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['pet'] is not None: + _body_params = _params['pet'] + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json', 'application/xml'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = ['http_signature_test'] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/fake/http-signature-test', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def fake_outer_boolean_serialize(self, body : Annotated[Optional[StrictBool], Field(description="Input boolean as post body")] = None, **kwargs) -> bool: # noqa: E501 + """fake_outer_boolean_serialize # noqa: E501 + + Test serialization of outer boolean types # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.fake_outer_boolean_serialize(body, async_req=True) + >>> result = thread.get() + + :param body: Input boolean as post body + :type body: bool + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: bool + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the fake_outer_boolean_serialize_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.fake_outer_boolean_serialize_with_http_info(body, **kwargs) # noqa: E501 + + @validate_call + def fake_outer_boolean_serialize_with_http_info(self, body : Annotated[Optional[StrictBool], Field(description="Input boolean as post body")] = None, **kwargs) -> ApiResponse: # noqa: E501 + """fake_outer_boolean_serialize # noqa: E501 + + Test serialization of outer boolean types # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.fake_outer_boolean_serialize_with_http_info(body, async_req=True) + >>> result = thread.get() + + :param body: Input boolean as post body + :type body: bool + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(bool, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'body' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method fake_outer_boolean_serialize" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['body'] is not None: + _body_params = _params['body'] + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['*/*']) # noqa: E501 + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "bool", + } + + return self.api_client.call_api( + '/fake/outer/boolean', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def fake_outer_composite_serialize(self, outer_composite : Annotated[Optional[OuterComposite], Field(description="Input composite as post body")] = None, **kwargs) -> OuterComposite: # noqa: E501 + """fake_outer_composite_serialize # noqa: E501 + + Test serialization of object with outer number type # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.fake_outer_composite_serialize(outer_composite, async_req=True) + >>> result = thread.get() + + :param outer_composite: Input composite as post body + :type outer_composite: OuterComposite + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: OuterComposite + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the fake_outer_composite_serialize_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.fake_outer_composite_serialize_with_http_info(outer_composite, **kwargs) # noqa: E501 + + @validate_call + def fake_outer_composite_serialize_with_http_info(self, outer_composite : Annotated[Optional[OuterComposite], Field(description="Input composite as post body")] = None, **kwargs) -> ApiResponse: # noqa: E501 + """fake_outer_composite_serialize # noqa: E501 + + Test serialization of object with outer number type # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.fake_outer_composite_serialize_with_http_info(outer_composite, async_req=True) + >>> result = thread.get() + + :param outer_composite: Input composite as post body + :type outer_composite: OuterComposite + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(OuterComposite, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'outer_composite' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method fake_outer_composite_serialize" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['outer_composite'] is not None: + _body_params = _params['outer_composite'] + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['*/*']) # noqa: E501 + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "OuterComposite", + } + + return self.api_client.call_api( + '/fake/outer/composite', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def fake_outer_number_serialize(self, body : Annotated[Optional[StrictFloat], Field(description="Input number as post body")] = None, **kwargs) -> float: # noqa: E501 + """fake_outer_number_serialize # noqa: E501 + + Test serialization of outer number types # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.fake_outer_number_serialize(body, async_req=True) + >>> result = thread.get() + + :param body: Input number as post body + :type body: float + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: float + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the fake_outer_number_serialize_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.fake_outer_number_serialize_with_http_info(body, **kwargs) # noqa: E501 + + @validate_call + def fake_outer_number_serialize_with_http_info(self, body : Annotated[Optional[StrictFloat], Field(description="Input number as post body")] = None, **kwargs) -> ApiResponse: # noqa: E501 + """fake_outer_number_serialize # noqa: E501 + + Test serialization of outer number types # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.fake_outer_number_serialize_with_http_info(body, async_req=True) + >>> result = thread.get() + + :param body: Input number as post body + :type body: float + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(float, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'body' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method fake_outer_number_serialize" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['body'] is not None: + _body_params = _params['body'] + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['*/*']) # noqa: E501 + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "float", + } + + return self.api_client.call_api( + '/fake/outer/number', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def fake_outer_string_serialize(self, body : Annotated[Optional[StrictStr], Field(description="Input string as post body")] = None, **kwargs) -> str: # noqa: E501 + """fake_outer_string_serialize # noqa: E501 + + Test serialization of outer string types # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.fake_outer_string_serialize(body, async_req=True) + >>> result = thread.get() + + :param body: Input string as post body + :type body: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: str + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the fake_outer_string_serialize_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.fake_outer_string_serialize_with_http_info(body, **kwargs) # noqa: E501 + + @validate_call + def fake_outer_string_serialize_with_http_info(self, body : Annotated[Optional[StrictStr], Field(description="Input string as post body")] = None, **kwargs) -> ApiResponse: # noqa: E501 + """fake_outer_string_serialize # noqa: E501 + + Test serialization of outer string types # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.fake_outer_string_serialize_with_http_info(body, async_req=True) + >>> result = thread.get() + + :param body: Input string as post body + :type body: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(str, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'body' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method fake_outer_string_serialize" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['body'] is not None: + _body_params = _params['body'] + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['*/*']) # noqa: E501 + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "str", + } + + return self.api_client.call_api( + '/fake/outer/string', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def fake_property_enum_integer_serialize(self, outer_object_with_enum_property : Annotated[OuterObjectWithEnumProperty, Field(..., description="Input enum (int) as post body")], **kwargs) -> OuterObjectWithEnumProperty: # noqa: E501 + """fake_property_enum_integer_serialize # noqa: E501 + + Test serialization of enum (int) properties with examples # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.fake_property_enum_integer_serialize(outer_object_with_enum_property, async_req=True) + >>> result = thread.get() + + :param outer_object_with_enum_property: Input enum (int) as post body (required) + :type outer_object_with_enum_property: OuterObjectWithEnumProperty + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: OuterObjectWithEnumProperty + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the fake_property_enum_integer_serialize_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.fake_property_enum_integer_serialize_with_http_info(outer_object_with_enum_property, **kwargs) # noqa: E501 + + @validate_call + def fake_property_enum_integer_serialize_with_http_info(self, outer_object_with_enum_property : Annotated[OuterObjectWithEnumProperty, Field(..., description="Input enum (int) as post body")], **kwargs) -> ApiResponse: # noqa: E501 + """fake_property_enum_integer_serialize # noqa: E501 + + Test serialization of enum (int) properties with examples # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.fake_property_enum_integer_serialize_with_http_info(outer_object_with_enum_property, async_req=True) + >>> result = thread.get() + + :param outer_object_with_enum_property: Input enum (int) as post body (required) + :type outer_object_with_enum_property: OuterObjectWithEnumProperty + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(OuterObjectWithEnumProperty, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'outer_object_with_enum_property' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method fake_property_enum_integer_serialize" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['outer_object_with_enum_property'] is not None: + _body_params = _params['outer_object_with_enum_property'] + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['*/*']) # noqa: E501 + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "OuterObjectWithEnumProperty", + } + + return self.api_client.call_api( + '/fake/property/enum-int', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def fake_return_list_of_objects(self, **kwargs) -> List[List[Tag]]: # noqa: E501 + """test returning list of objects # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.fake_return_list_of_objects(async_req=True) + >>> result = thread.get() + + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: List[List[Tag]] + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the fake_return_list_of_objects_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.fake_return_list_of_objects_with_http_info(**kwargs) # noqa: E501 + + @validate_call + def fake_return_list_of_objects_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 + """test returning list of objects # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.fake_return_list_of_objects_with_http_info(async_req=True) + >>> result = thread.get() + + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(List[List[Tag]], status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method fake_return_list_of_objects" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "List[List[Tag]]", + } + + return self.api_client.call_api( + '/fake/return_list_of_object', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def fake_uuid_example(self, uuid_example : Annotated[StrictStr, Field(..., description="uuid example")], **kwargs) -> None: # noqa: E501 + """test uuid example # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.fake_uuid_example(uuid_example, async_req=True) + >>> result = thread.get() + + :param uuid_example: uuid example (required) + :type uuid_example: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the fake_uuid_example_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.fake_uuid_example_with_http_info(uuid_example, **kwargs) # noqa: E501 + + @validate_call + def fake_uuid_example_with_http_info(self, uuid_example : Annotated[StrictStr, Field(..., description="uuid example")], **kwargs) -> ApiResponse: # noqa: E501 + """test uuid example # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.fake_uuid_example_with_http_info(uuid_example, async_req=True) + >>> result = thread.get() + + :param uuid_example: uuid example (required) + :type uuid_example: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + 'uuid_example' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method fake_uuid_example" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + if _params.get('uuid_example') is not None: # noqa: E501 + _query_params.append(('uuid_example', _params['uuid_example'])) + + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/fake/uuid_example', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def test_body_with_binary(self, body : Annotated[Optional[Union[StrictBytes, StrictStr]], Field(..., description="image to upload")], **kwargs) -> None: # noqa: E501 + """test_body_with_binary # noqa: E501 + + For this test, the body has to be a binary file. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_body_with_binary(body, async_req=True) + >>> result = thread.get() + + :param body: image to upload (required) + :type body: bytearray + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the test_body_with_binary_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.test_body_with_binary_with_http_info(body, **kwargs) # noqa: E501 + + @validate_call + def test_body_with_binary_with_http_info(self, body : Annotated[Optional[Union[StrictBytes, StrictStr]], Field(..., description="image to upload")], **kwargs) -> ApiResponse: # noqa: E501 + """test_body_with_binary # noqa: E501 + + For this test, the body has to be a binary file. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_body_with_binary_with_http_info(body, async_req=True) + >>> result = thread.get() + + :param body: image to upload (required) + :type body: bytearray + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + 'body' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method test_body_with_binary" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['body'] is not None: + _body_params = _params['body'] + # convert to byte array if the input is a file name (str) + if isinstance(_body_params, str): + with io.open(_body_params, "rb") as _fp: + _body_params_from_file = _fp.read() + _body_params = _body_params_from_file + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['image/png'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/fake/body-with-binary', 'PUT', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def test_body_with_file_schema(self, file_schema_test_class : FileSchemaTestClass, **kwargs) -> None: # noqa: E501 + """test_body_with_file_schema # noqa: E501 + + For this test, the body for this request must reference a schema named `File`. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_body_with_file_schema(file_schema_test_class, async_req=True) + >>> result = thread.get() + + :param file_schema_test_class: (required) + :type file_schema_test_class: FileSchemaTestClass + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the test_body_with_file_schema_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.test_body_with_file_schema_with_http_info(file_schema_test_class, **kwargs) # noqa: E501 + + @validate_call + def test_body_with_file_schema_with_http_info(self, file_schema_test_class : FileSchemaTestClass, **kwargs) -> ApiResponse: # noqa: E501 + """test_body_with_file_schema # noqa: E501 + + For this test, the body for this request must reference a schema named `File`. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_body_with_file_schema_with_http_info(file_schema_test_class, async_req=True) + >>> result = thread.get() + + :param file_schema_test_class: (required) + :type file_schema_test_class: FileSchemaTestClass + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + 'file_schema_test_class' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method test_body_with_file_schema" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['file_schema_test_class'] is not None: + _body_params = _params['file_schema_test_class'] + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/fake/body-with-file-schema', 'PUT', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def test_body_with_query_params(self, query : StrictStr, user : User, **kwargs) -> None: # noqa: E501 + """test_body_with_query_params # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_body_with_query_params(query, user, async_req=True) + >>> result = thread.get() + + :param query: (required) + :type query: str + :param user: (required) + :type user: User + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the test_body_with_query_params_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.test_body_with_query_params_with_http_info(query, user, **kwargs) # noqa: E501 + + @validate_call + def test_body_with_query_params_with_http_info(self, query : StrictStr, user : User, **kwargs) -> ApiResponse: # noqa: E501 + """test_body_with_query_params # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_body_with_query_params_with_http_info(query, user, async_req=True) + >>> result = thread.get() + + :param query: (required) + :type query: str + :param user: (required) + :type user: User + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + 'query', + 'user' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method test_body_with_query_params" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + if _params.get('query') is not None: # noqa: E501 + _query_params.append(('query', _params['query'])) + + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['user'] is not None: + _body_params = _params['user'] + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/fake/body-with-query-params', 'PUT', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def test_client_model(self, client : Annotated[Client, Field(..., description="client model")], **kwargs) -> Client: # noqa: E501 + """To test \"client\" model # noqa: E501 + + To test \"client\" model # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_client_model(client, async_req=True) + >>> result = thread.get() + + :param client: client model (required) + :type client: Client + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: Client + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the test_client_model_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.test_client_model_with_http_info(client, **kwargs) # noqa: E501 + + @validate_call + def test_client_model_with_http_info(self, client : Annotated[Client, Field(..., description="client model")], **kwargs) -> ApiResponse: # noqa: E501 + """To test \"client\" model # noqa: E501 + + To test \"client\" model # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_client_model_with_http_info(client, async_req=True) + >>> result = thread.get() + + :param client: client model (required) + :type client: Client + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(Client, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'client' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method test_client_model" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['client'] is not None: + _body_params = _params['client'] + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "Client", + } + + return self.api_client.call_api( + '/fake', 'PATCH', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def test_date_time_query_parameter(self, date_time_query : datetime, str_query : StrictStr, **kwargs) -> None: # noqa: E501 + """test_date_time_query_parameter # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_date_time_query_parameter(date_time_query, str_query, async_req=True) + >>> result = thread.get() + + :param date_time_query: (required) + :type date_time_query: datetime + :param str_query: (required) + :type str_query: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the test_date_time_query_parameter_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.test_date_time_query_parameter_with_http_info(date_time_query, str_query, **kwargs) # noqa: E501 + + @validate_call + def test_date_time_query_parameter_with_http_info(self, date_time_query : datetime, str_query : StrictStr, **kwargs) -> ApiResponse: # noqa: E501 + """test_date_time_query_parameter # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_date_time_query_parameter_with_http_info(date_time_query, str_query, async_req=True) + >>> result = thread.get() + + :param date_time_query: (required) + :type date_time_query: datetime + :param str_query: (required) + :type str_query: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + 'date_time_query', + 'str_query' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method test_date_time_query_parameter" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + if _params.get('date_time_query') is not None: # noqa: E501 + if isinstance(_params['date_time_query'], datetime): + _query_params.append(('date_time_query', _params['date_time_query'].strftime(self.api_client.configuration.datetime_format))) + else: + _query_params.append(('date_time_query', _params['date_time_query'])) + + if _params.get('str_query') is not None: # noqa: E501 + _query_params.append(('str_query', _params['str_query'])) + + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/fake/date-time-query-params', 'PUT', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def test_endpoint_parameters(self, number : Annotated[confloat(le=543.2, ge=32.1, strict=True), Field(..., description="None")], double : Annotated[confloat(le=123.4, ge=67.8, strict=True), Field(..., description="None")], pattern_without_delimiter : Annotated[constr(strict=True), Field(..., description="None")], byte : Annotated[Union[StrictBytes, StrictStr], Field(..., description="None")], integer : Annotated[Optional[conint(strict=True, le=100, ge=10)], Field(description="None")] = None, int32 : Annotated[Optional[conint(strict=True, le=200, ge=20)], Field(description="None")] = None, int64 : Annotated[Optional[StrictInt], Field(description="None")] = None, float : Annotated[Optional[confloat(le=987.6, strict=True)], Field(description="None")] = None, string : Annotated[Optional[constr(strict=True)], Field(description="None")] = None, binary : Annotated[Optional[Union[StrictBytes, StrictStr]], Field(description="None")] = None, byte_with_max_length : Annotated[Optional[Union[conbytes(strict=True, max_length=64), constr(strict=True, max_length=64)]], Field(description="None")] = None, var_date : Annotated[Optional[date], Field(description="None")] = None, date_time : Annotated[Optional[datetime], Field(description="None")] = None, password : Annotated[Optional[constr(strict=True, max_length=64, min_length=10)], Field(description="None")] = None, param_callback : Annotated[Optional[StrictStr], Field(description="None")] = None, **kwargs) -> None: # noqa: E501 + """Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501 + + Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer, int32, int64, float, string, binary, byte_with_max_length, var_date, date_time, password, param_callback, async_req=True) + >>> result = thread.get() + + :param number: None (required) + :type number: float + :param double: None (required) + :type double: float + :param pattern_without_delimiter: None (required) + :type pattern_without_delimiter: str + :param byte: None (required) + :type byte: bytearray + :param integer: None + :type integer: int + :param int32: None + :type int32: int + :param int64: None + :type int64: int + :param float: None + :type float: float + :param string: None + :type string: str + :param binary: None + :type binary: bytearray + :param byte_with_max_length: None + :type byte_with_max_length: bytearray + :param var_date: None + :type var_date: date + :param date_time: None + :type date_time: datetime + :param password: None + :type password: str + :param param_callback: None + :type param_callback: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the test_endpoint_parameters_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.test_endpoint_parameters_with_http_info(number, double, pattern_without_delimiter, byte, integer, int32, int64, float, string, binary, byte_with_max_length, var_date, date_time, password, param_callback, **kwargs) # noqa: E501 + + @validate_call + def test_endpoint_parameters_with_http_info(self, number : Annotated[confloat(le=543.2, ge=32.1, strict=True), Field(..., description="None")], double : Annotated[confloat(le=123.4, ge=67.8, strict=True), Field(..., description="None")], pattern_without_delimiter : Annotated[constr(strict=True), Field(..., description="None")], byte : Annotated[Union[StrictBytes, StrictStr], Field(..., description="None")], integer : Annotated[Optional[conint(strict=True, le=100, ge=10)], Field(description="None")] = None, int32 : Annotated[Optional[conint(strict=True, le=200, ge=20)], Field(description="None")] = None, int64 : Annotated[Optional[StrictInt], Field(description="None")] = None, float : Annotated[Optional[confloat(le=987.6, strict=True)], Field(description="None")] = None, string : Annotated[Optional[constr(strict=True)], Field(description="None")] = None, binary : Annotated[Optional[Union[StrictBytes, StrictStr]], Field(description="None")] = None, byte_with_max_length : Annotated[Optional[Union[conbytes(strict=True, max_length=64), constr(strict=True, max_length=64)]], Field(description="None")] = None, var_date : Annotated[Optional[date], Field(description="None")] = None, date_time : Annotated[Optional[datetime], Field(description="None")] = None, password : Annotated[Optional[constr(strict=True, max_length=64, min_length=10)], Field(description="None")] = None, param_callback : Annotated[Optional[StrictStr], Field(description="None")] = None, **kwargs) -> ApiResponse: # noqa: E501 + """Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501 + + Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_endpoint_parameters_with_http_info(number, double, pattern_without_delimiter, byte, integer, int32, int64, float, string, binary, byte_with_max_length, var_date, date_time, password, param_callback, async_req=True) + >>> result = thread.get() + + :param number: None (required) + :type number: float + :param double: None (required) + :type double: float + :param pattern_without_delimiter: None (required) + :type pattern_without_delimiter: str + :param byte: None (required) + :type byte: bytearray + :param integer: None + :type integer: int + :param int32: None + :type int32: int + :param int64: None + :type int64: int + :param float: None + :type float: float + :param string: None + :type string: str + :param binary: None + :type binary: bytearray + :param byte_with_max_length: None + :type byte_with_max_length: bytearray + :param var_date: None + :type var_date: date + :param date_time: None + :type date_time: datetime + :param password: None + :type password: str + :param param_callback: None + :type param_callback: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + 'number', + 'double', + 'pattern_without_delimiter', + 'byte', + 'integer', + 'int32', + 'int64', + 'float', + 'string', + 'binary', + 'byte_with_max_length', + 'var_date', + 'date_time', + 'password', + 'param_callback' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method test_endpoint_parameters" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + if _params['integer']: + _form_params.append(('integer', _params['integer'])) + + if _params['int32']: + _form_params.append(('int32', _params['int32'])) + + if _params['int64']: + _form_params.append(('int64', _params['int64'])) + + if _params['number']: + _form_params.append(('number', _params['number'])) + + if _params['float']: + _form_params.append(('float', _params['float'])) + + if _params['double']: + _form_params.append(('double', _params['double'])) + + if _params['string']: + _form_params.append(('string', _params['string'])) + + if _params['pattern_without_delimiter']: + _form_params.append(('pattern_without_delimiter', _params['pattern_without_delimiter'])) + + if _params['byte']: + _form_params.append(('byte', _params['byte'])) + + if _params['binary']: + _files['binary'] = _params['binary'] + + if _params['byte_with_max_length']: + _form_params.append(('byte_with_max_length', _params['byte_with_max_length'])) + + if _params['var_date']: + _form_params.append(('date', _params['var_date'])) + + if _params['date_time']: + _form_params.append(('dateTime', _params['date_time'])) + + if _params['password']: + _form_params.append(('password', _params['password'])) + + if _params['param_callback']: + _form_params.append(('callback', _params['param_callback'])) + + # process the body parameter + _body_params = None + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/x-www-form-urlencoded'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = ['http_basic_test'] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/fake', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def test_group_parameters(self, required_string_group : Annotated[StrictInt, Field(..., description="Required String in group parameters")], required_boolean_group : Annotated[StrictBool, Field(..., description="Required Boolean in group parameters")], required_int64_group : Annotated[StrictInt, Field(..., description="Required Integer in group parameters")], string_group : Annotated[Optional[StrictInt], Field(description="String in group parameters")] = None, boolean_group : Annotated[Optional[StrictBool], Field(description="Boolean in group parameters")] = None, int64_group : Annotated[Optional[StrictInt], Field(description="Integer in group parameters")] = None, **kwargs) -> None: # noqa: E501 + """Fake endpoint to test group parameters (optional) # noqa: E501 + + Fake endpoint to test group parameters (optional) # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_group_parameters(required_string_group, required_boolean_group, required_int64_group, string_group, boolean_group, int64_group, async_req=True) + >>> result = thread.get() + + :param required_string_group: Required String in group parameters (required) + :type required_string_group: int + :param required_boolean_group: Required Boolean in group parameters (required) + :type required_boolean_group: bool + :param required_int64_group: Required Integer in group parameters (required) + :type required_int64_group: int + :param string_group: String in group parameters + :type string_group: int + :param boolean_group: Boolean in group parameters + :type boolean_group: bool + :param int64_group: Integer in group parameters + :type int64_group: int + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the test_group_parameters_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.test_group_parameters_with_http_info(required_string_group, required_boolean_group, required_int64_group, string_group, boolean_group, int64_group, **kwargs) # noqa: E501 + + @validate_call + def test_group_parameters_with_http_info(self, required_string_group : Annotated[StrictInt, Field(..., description="Required String in group parameters")], required_boolean_group : Annotated[StrictBool, Field(..., description="Required Boolean in group parameters")], required_int64_group : Annotated[StrictInt, Field(..., description="Required Integer in group parameters")], string_group : Annotated[Optional[StrictInt], Field(description="String in group parameters")] = None, boolean_group : Annotated[Optional[StrictBool], Field(description="Boolean in group parameters")] = None, int64_group : Annotated[Optional[StrictInt], Field(description="Integer in group parameters")] = None, **kwargs) -> ApiResponse: # noqa: E501 + """Fake endpoint to test group parameters (optional) # noqa: E501 + + Fake endpoint to test group parameters (optional) # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_group_parameters_with_http_info(required_string_group, required_boolean_group, required_int64_group, string_group, boolean_group, int64_group, async_req=True) + >>> result = thread.get() + + :param required_string_group: Required String in group parameters (required) + :type required_string_group: int + :param required_boolean_group: Required Boolean in group parameters (required) + :type required_boolean_group: bool + :param required_int64_group: Required Integer in group parameters (required) + :type required_int64_group: int + :param string_group: String in group parameters + :type string_group: int + :param boolean_group: Boolean in group parameters + :type boolean_group: bool + :param int64_group: Integer in group parameters + :type int64_group: int + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + 'required_string_group', + 'required_boolean_group', + 'required_int64_group', + 'string_group', + 'boolean_group', + 'int64_group' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method test_group_parameters" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + if _params.get('required_string_group') is not None: # noqa: E501 + _query_params.append(('required_string_group', _params['required_string_group'])) + + if _params.get('required_int64_group') is not None: # noqa: E501 + _query_params.append(('required_int64_group', _params['required_int64_group'])) + + if _params.get('string_group') is not None: # noqa: E501 + _query_params.append(('string_group', _params['string_group'])) + + if _params.get('int64_group') is not None: # noqa: E501 + _query_params.append(('int64_group', _params['int64_group'])) + + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + if _params['required_boolean_group']: + _header_params['required_boolean_group'] = _params['required_boolean_group'] + + if _params['boolean_group']: + _header_params['boolean_group'] = _params['boolean_group'] + + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # authentication setting + _auth_settings = ['bearer_test'] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/fake', 'DELETE', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def test_inline_additional_properties(self, request_body : Annotated[Dict[str, StrictStr], Field(..., description="request body")], **kwargs) -> None: # noqa: E501 + """test inline additionalProperties # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_inline_additional_properties(request_body, async_req=True) + >>> result = thread.get() + + :param request_body: request body (required) + :type request_body: Dict[str, str] + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the test_inline_additional_properties_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.test_inline_additional_properties_with_http_info(request_body, **kwargs) # noqa: E501 + + @validate_call + def test_inline_additional_properties_with_http_info(self, request_body : Annotated[Dict[str, StrictStr], Field(..., description="request body")], **kwargs) -> ApiResponse: # noqa: E501 + """test inline additionalProperties # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_inline_additional_properties_with_http_info(request_body, async_req=True) + >>> result = thread.get() + + :param request_body: request body (required) + :type request_body: Dict[str, str] + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + 'request_body' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method test_inline_additional_properties" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['request_body'] is not None: + _body_params = _params['request_body'] + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/fake/inline-additionalProperties', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def test_json_form_data(self, param : Annotated[StrictStr, Field(..., description="field1")], param2 : Annotated[StrictStr, Field(..., description="field2")], **kwargs) -> None: # noqa: E501 + """test json serialization of form data # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_json_form_data(param, param2, async_req=True) + >>> result = thread.get() + + :param param: field1 (required) + :type param: str + :param param2: field2 (required) + :type param2: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the test_json_form_data_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.test_json_form_data_with_http_info(param, param2, **kwargs) # noqa: E501 + + @validate_call + def test_json_form_data_with_http_info(self, param : Annotated[StrictStr, Field(..., description="field1")], param2 : Annotated[StrictStr, Field(..., description="field2")], **kwargs) -> ApiResponse: # noqa: E501 + """test json serialization of form data # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_json_form_data_with_http_info(param, param2, async_req=True) + >>> result = thread.get() + + :param param: field1 (required) + :type param: str + :param param2: field2 (required) + :type param2: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + 'param', + 'param2' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method test_json_form_data" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + if _params['param']: + _form_params.append(('param', _params['param'])) + + if _params['param2']: + _form_params.append(('param2', _params['param2'])) + + # process the body parameter + _body_params = None + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/x-www-form-urlencoded'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/fake/jsonFormData', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def test_query_parameter_collection_format(self, pipe : conlist(StrictStr), ioutil : conlist(StrictStr), http : conlist(StrictStr), url : conlist(StrictStr), context : conlist(StrictStr), allow_empty : StrictStr, language : Optional[Dict[str, StrictStr]] = None, **kwargs) -> None: # noqa: E501 + """test_query_parameter_collection_format # noqa: E501 + + To test the collection format in query parameters # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_query_parameter_collection_format(pipe, ioutil, http, url, context, allow_empty, language, async_req=True) + >>> result = thread.get() + + :param pipe: (required) + :type pipe: List[str] + :param ioutil: (required) + :type ioutil: List[str] + :param http: (required) + :type http: List[str] + :param url: (required) + :type url: List[str] + :param context: (required) + :type context: List[str] + :param allow_empty: (required) + :type allow_empty: str + :param language: + :type language: Dict[str, str] + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the test_query_parameter_collection_format_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.test_query_parameter_collection_format_with_http_info(pipe, ioutil, http, url, context, allow_empty, language, **kwargs) # noqa: E501 + + @validate_call + def test_query_parameter_collection_format_with_http_info(self, pipe : conlist(StrictStr), ioutil : conlist(StrictStr), http : conlist(StrictStr), url : conlist(StrictStr), context : conlist(StrictStr), allow_empty : StrictStr, language : Optional[Dict[str, StrictStr]] = None, **kwargs) -> ApiResponse: # noqa: E501 + """test_query_parameter_collection_format # noqa: E501 + + To test the collection format in query parameters # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_query_parameter_collection_format_with_http_info(pipe, ioutil, http, url, context, allow_empty, language, async_req=True) + >>> result = thread.get() + + :param pipe: (required) + :type pipe: List[str] + :param ioutil: (required) + :type ioutil: List[str] + :param http: (required) + :type http: List[str] + :param url: (required) + :type url: List[str] + :param context: (required) + :type context: List[str] + :param allow_empty: (required) + :type allow_empty: str + :param language: + :type language: Dict[str, str] + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + 'pipe', + 'ioutil', + 'http', + 'url', + 'context', + 'allow_empty', + 'language' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method test_query_parameter_collection_format" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + if _params.get('pipe') is not None: # noqa: E501 + _query_params.append(('pipe', _params['pipe'])) + _collection_formats['pipe'] = 'pipes' + + if _params.get('ioutil') is not None: # noqa: E501 + _query_params.append(('ioutil', _params['ioutil'])) + _collection_formats['ioutil'] = 'csv' + + if _params.get('http') is not None: # noqa: E501 + _query_params.append(('http', _params['http'])) + _collection_formats['http'] = 'ssv' + + if _params.get('url') is not None: # noqa: E501 + _query_params.append(('url', _params['url'])) + _collection_formats['url'] = 'csv' + + if _params.get('context') is not None: # noqa: E501 + _query_params.append(('context', _params['context'])) + _collection_formats['context'] = 'multi' + + if _params.get('language') is not None: # noqa: E501 + _query_params.append(('language', _params['language'])) + + if _params.get('allow_empty') is not None: # noqa: E501 + _query_params.append(('allowEmpty', _params['allow_empty'])) + + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/fake/test-query-parameters', 'PUT', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api/fake_classname_tags123_api.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api/fake_classname_tags123_api.py new file mode 100644 index 000000000000..d0528d3d9d17 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api/fake_classname_tags123_api.py @@ -0,0 +1,192 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import re # noqa: F401 +import io +import warnings + +from pydantic import validate_call, ValidationError +from typing_extensions import Annotated + +from typing_extensions import Annotated +from pydantic import Field + +from petstore_api.models.client import Client + +from petstore_api.api_client import ApiClient +from petstore_api.api_response import ApiResponse +from petstore_api.exceptions import ( # noqa: F401 + ApiTypeError, + ApiValueError +) + + +class FakeClassnameTags123Api: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_call + def test_classname(self, client : Annotated[Client, Field(..., description="client model")], **kwargs) -> Client: # noqa: E501 + """To test class name in snake case # noqa: E501 + + To test class name in snake case # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_classname(client, async_req=True) + >>> result = thread.get() + + :param client: client model (required) + :type client: Client + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: Client + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the test_classname_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.test_classname_with_http_info(client, **kwargs) # noqa: E501 + + @validate_call + def test_classname_with_http_info(self, client : Annotated[Client, Field(..., description="client model")], **kwargs) -> ApiResponse: # noqa: E501 + """To test class name in snake case # noqa: E501 + + To test class name in snake case # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_classname_with_http_info(client, async_req=True) + >>> result = thread.get() + + :param client: client model (required) + :type client: Client + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(Client, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'client' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method test_classname" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['client'] is not None: + _body_params = _params['client'] + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = ['api_key_query'] # noqa: E501 + + _response_types_map = { + '200': "Client", + } + + return self.api_client.call_api( + '/fake_classname_test', 'PATCH', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api/fake_classname_tags_123_api.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api/fake_classname_tags_123_api.py new file mode 100755 index 000000000000..05c1c8a0e4ff --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api/fake_classname_tags_123_api.py @@ -0,0 +1,181 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import re # noqa: F401 + +# python 2 and python 3 compatibility library +import six + +from petstore_api.api_client import ApiClient +from petstore_api.exceptions import ( # noqa: F401 + ApiTypeError, + ApiValueError +) + + +class FakeClassnameTags123Api(object): + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None): + if api_client is None: + api_client = ApiClient() + self.api_client = api_client + + def test_classname(self, client, **kwargs): # noqa: E501 + """To test class name in snake case # noqa: E501 + + To test class name in snake case # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_classname(client, async_req=True) + >>> result = thread.get() + + :param client: client model (required) + :type client: Client + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :type _preload_content: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: Client + """ + kwargs['_return_http_data_only'] = True + return self.test_classname_with_http_info(client, **kwargs) # noqa: E501 + + def test_classname_with_http_info(self, client, **kwargs): # noqa: E501 + """To test class name in snake case # noqa: E501 + + To test class name in snake case # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_classname_with_http_info(client, async_req=True) + >>> result = thread.get() + + :param client: client model (required) + :type client: Client + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _return_http_data_only: response data without head status code + and headers + :type _return_http_data_only: bool, optional + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :type _preload_content: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(Client, status_code(int), headers(HTTPHeaderDict)) + """ + + local_var_params = locals() + + all_params = [ + 'client' + ] + all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + for key, val in six.iteritems(local_var_params['kwargs']): + if key not in all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method test_classname" % key + ) + local_var_params[key] = val + del local_var_params['kwargs'] + # verify the required parameter 'client' is set + if self.api_client.client_side_validation and ('client' not in local_var_params or # noqa: E501 + local_var_params['client'] is None): # noqa: E501 + raise ApiValueError("Missing the required parameter `client` when calling `test_classname`") # noqa: E501 + + collection_formats = {} + + path_params = {} + + query_params = [] + + header_params = dict(local_var_params.get('_headers', {})) + + form_params = [] + local_var_files = {} + + body_params = None + if 'client' in local_var_params: + body_params = local_var_params['client'] + # HTTP header `Accept` + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # HTTP header `Content-Type` + header_params['Content-Type'] = local_var_params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'], + 'PATCH', body_params)) # noqa: E501 + + # Authentication setting + auth_settings = ['api_key_query'] # noqa: E501 + + response_types_map = { + 200: "Client", + } + + return self.api_client.call_api( + '/fake_classname_test', 'PATCH', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_types_map=response_types_map, + auth_settings=auth_settings, + async_req=local_var_params.get('async_req'), + _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=local_var_params.get('_preload_content', True), + _request_timeout=local_var_params.get('_request_timeout'), + collection_formats=collection_formats, + _request_auth=local_var_params.get('_request_auth')) diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api/pet_api.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api/pet_api.py new file mode 100755 index 000000000000..979aaa65a244 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api/pet_api.py @@ -0,0 +1,1383 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import re # noqa: F401 +import io +import warnings + +from pydantic import validate_call, ValidationError +from typing_extensions import Annotated + +from typing_extensions import Annotated +from pydantic import Field, StrictBytes, StrictInt, StrictStr, conlist, validator + +from typing import List, Optional, Union + +from petstore_api.models.api_response import ApiResponse +from petstore_api.models.pet import Pet + +from petstore_api.api_client import ApiClient +from petstore_api.api_response import ApiResponse +from petstore_api.exceptions import ( # noqa: F401 + ApiTypeError, + ApiValueError +) + + +class PetApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_call + def add_pet(self, pet : Annotated[Pet, Field(..., description="Pet object that needs to be added to the store")], **kwargs) -> None: # noqa: E501 + """Add a new pet to the store # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.add_pet(pet, async_req=True) + >>> result = thread.get() + + :param pet: Pet object that needs to be added to the store (required) + :type pet: Pet + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the add_pet_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.add_pet_with_http_info(pet, **kwargs) # noqa: E501 + + @validate_call + def add_pet_with_http_info(self, pet : Annotated[Pet, Field(..., description="Pet object that needs to be added to the store")], **kwargs) -> ApiResponse: # noqa: E501 + """Add a new pet to the store # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.add_pet_with_http_info(pet, async_req=True) + >>> result = thread.get() + + :param pet: Pet object that needs to be added to the store (required) + :type pet: Pet + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + 'pet' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method add_pet" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['pet'] is not None: + _body_params = _params['pet'] + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json', 'application/xml'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = ['petstore_auth', 'http_signature_test'] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/pet', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def delete_pet(self, pet_id : Annotated[StrictInt, Field(..., description="Pet id to delete")], api_key : Optional[StrictStr] = None, **kwargs) -> None: # noqa: E501 + """Deletes a pet # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.delete_pet(pet_id, api_key, async_req=True) + >>> result = thread.get() + + :param pet_id: Pet id to delete (required) + :type pet_id: int + :param api_key: + :type api_key: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the delete_pet_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.delete_pet_with_http_info(pet_id, api_key, **kwargs) # noqa: E501 + + @validate_call + def delete_pet_with_http_info(self, pet_id : Annotated[StrictInt, Field(..., description="Pet id to delete")], api_key : Optional[StrictStr] = None, **kwargs) -> ApiResponse: # noqa: E501 + """Deletes a pet # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.delete_pet_with_http_info(pet_id, api_key, async_req=True) + >>> result = thread.get() + + :param pet_id: Pet id to delete (required) + :type pet_id: int + :param api_key: + :type api_key: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + 'pet_id', + 'api_key' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method delete_pet" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + if _params['pet_id']: + _path_params['petId'] = _params['pet_id'] + + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + if _params['api_key']: + _header_params['api_key'] = _params['api_key'] + + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # authentication setting + _auth_settings = ['petstore_auth'] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/pet/{petId}', 'DELETE', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def find_pets_by_status(self, status : Annotated[conlist(StrictStr), Field(..., description="Status values that need to be considered for filter")], **kwargs) -> List[Pet]: # noqa: E501 + """Finds Pets by status # noqa: E501 + + Multiple status values can be provided with comma separated strings # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.find_pets_by_status(status, async_req=True) + >>> result = thread.get() + + :param status: Status values that need to be considered for filter (required) + :type status: List[str] + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: List[Pet] + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the find_pets_by_status_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.find_pets_by_status_with_http_info(status, **kwargs) # noqa: E501 + + @validate_call + def find_pets_by_status_with_http_info(self, status : Annotated[conlist(StrictStr), Field(..., description="Status values that need to be considered for filter")], **kwargs) -> ApiResponse: # noqa: E501 + """Finds Pets by status # noqa: E501 + + Multiple status values can be provided with comma separated strings # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.find_pets_by_status_with_http_info(status, async_req=True) + >>> result = thread.get() + + :param status: Status values that need to be considered for filter (required) + :type status: List[str] + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(List[Pet], status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'status' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method find_pets_by_status" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + if _params.get('status') is not None: # noqa: E501 + _query_params.append(('status', _params['status'])) + _collection_formats['status'] = 'csv' + + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/xml', 'application/json']) # noqa: E501 + + # authentication setting + _auth_settings = ['petstore_auth', 'http_signature_test'] # noqa: E501 + + _response_types_map = { + '200': "List[Pet]", + '400': None, + } + + return self.api_client.call_api( + '/pet/findByStatus', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def find_pets_by_tags(self, tags : Annotated[conlist(StrictStr), Field(..., description="Tags to filter by")], **kwargs) -> List[Pet]: # noqa: E501 + """(Deprecated) Finds Pets by tags # noqa: E501 + + Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.find_pets_by_tags(tags, async_req=True) + >>> result = thread.get() + + :param tags: Tags to filter by (required) + :type tags: List[str] + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: List[Pet] + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the find_pets_by_tags_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.find_pets_by_tags_with_http_info(tags, **kwargs) # noqa: E501 + + @validate_call + def find_pets_by_tags_with_http_info(self, tags : Annotated[conlist(StrictStr), Field(..., description="Tags to filter by")], **kwargs) -> ApiResponse: # noqa: E501 + """(Deprecated) Finds Pets by tags # noqa: E501 + + Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.find_pets_by_tags_with_http_info(tags, async_req=True) + >>> result = thread.get() + + :param tags: Tags to filter by (required) + :type tags: List[str] + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(List[Pet], status_code(int), headers(HTTPHeaderDict)) + """ + + warnings.warn("GET /pet/findByTags is deprecated.", DeprecationWarning) + + _params = locals() + + _all_params = [ + 'tags' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method find_pets_by_tags" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + if _params.get('tags') is not None: # noqa: E501 + _query_params.append(('tags', _params['tags'])) + _collection_formats['tags'] = 'csv' + + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/xml', 'application/json']) # noqa: E501 + + # authentication setting + _auth_settings = ['petstore_auth', 'http_signature_test'] # noqa: E501 + + _response_types_map = { + '200': "List[Pet]", + '400': None, + } + + return self.api_client.call_api( + '/pet/findByTags', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def get_pet_by_id(self, pet_id : Annotated[StrictInt, Field(..., description="ID of pet to return")], **kwargs) -> Pet: # noqa: E501 + """Find pet by ID # noqa: E501 + + Returns a single pet # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_pet_by_id(pet_id, async_req=True) + >>> result = thread.get() + + :param pet_id: ID of pet to return (required) + :type pet_id: int + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: Pet + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the get_pet_by_id_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.get_pet_by_id_with_http_info(pet_id, **kwargs) # noqa: E501 + + @validate_call + def get_pet_by_id_with_http_info(self, pet_id : Annotated[StrictInt, Field(..., description="ID of pet to return")], **kwargs) -> ApiResponse: # noqa: E501 + """Find pet by ID # noqa: E501 + + Returns a single pet # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_pet_by_id_with_http_info(pet_id, async_req=True) + >>> result = thread.get() + + :param pet_id: ID of pet to return (required) + :type pet_id: int + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(Pet, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'pet_id' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method get_pet_by_id" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + if _params['pet_id']: + _path_params['petId'] = _params['pet_id'] + + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/xml', 'application/json']) # noqa: E501 + + # authentication setting + _auth_settings = ['api_key'] # noqa: E501 + + _response_types_map = { + '200': "Pet", + '400': None, + '404': None, + } + + return self.api_client.call_api( + '/pet/{petId}', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def update_pet(self, pet : Annotated[Pet, Field(..., description="Pet object that needs to be added to the store")], **kwargs) -> None: # noqa: E501 + """Update an existing pet # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.update_pet(pet, async_req=True) + >>> result = thread.get() + + :param pet: Pet object that needs to be added to the store (required) + :type pet: Pet + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the update_pet_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.update_pet_with_http_info(pet, **kwargs) # noqa: E501 + + @validate_call + def update_pet_with_http_info(self, pet : Annotated[Pet, Field(..., description="Pet object that needs to be added to the store")], **kwargs) -> ApiResponse: # noqa: E501 + """Update an existing pet # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.update_pet_with_http_info(pet, async_req=True) + >>> result = thread.get() + + :param pet: Pet object that needs to be added to the store (required) + :type pet: Pet + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + 'pet' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method update_pet" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['pet'] is not None: + _body_params = _params['pet'] + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json', 'application/xml'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = ['petstore_auth', 'http_signature_test'] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/pet', 'PUT', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def update_pet_with_form(self, pet_id : Annotated[StrictInt, Field(..., description="ID of pet that needs to be updated")], name : Annotated[Optional[StrictStr], Field(description="Updated name of the pet")] = None, status : Annotated[Optional[StrictStr], Field(description="Updated status of the pet")] = None, **kwargs) -> None: # noqa: E501 + """Updates a pet in the store with form data # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.update_pet_with_form(pet_id, name, status, async_req=True) + >>> result = thread.get() + + :param pet_id: ID of pet that needs to be updated (required) + :type pet_id: int + :param name: Updated name of the pet + :type name: str + :param status: Updated status of the pet + :type status: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the update_pet_with_form_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.update_pet_with_form_with_http_info(pet_id, name, status, **kwargs) # noqa: E501 + + @validate_call + def update_pet_with_form_with_http_info(self, pet_id : Annotated[StrictInt, Field(..., description="ID of pet that needs to be updated")], name : Annotated[Optional[StrictStr], Field(description="Updated name of the pet")] = None, status : Annotated[Optional[StrictStr], Field(description="Updated status of the pet")] = None, **kwargs) -> ApiResponse: # noqa: E501 + """Updates a pet in the store with form data # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.update_pet_with_form_with_http_info(pet_id, name, status, async_req=True) + >>> result = thread.get() + + :param pet_id: ID of pet that needs to be updated (required) + :type pet_id: int + :param name: Updated name of the pet + :type name: str + :param status: Updated status of the pet + :type status: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + 'pet_id', + 'name', + 'status' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method update_pet_with_form" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + if _params['pet_id']: + _path_params['petId'] = _params['pet_id'] + + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + if _params['name']: + _form_params.append(('name', _params['name'])) + + if _params['status']: + _form_params.append(('status', _params['status'])) + + # process the body parameter + _body_params = None + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/x-www-form-urlencoded'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = ['petstore_auth'] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/pet/{petId}', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def upload_file(self, pet_id : Annotated[StrictInt, Field(..., description="ID of pet to update")], additional_metadata : Annotated[Optional[StrictStr], Field(description="Additional data to pass to server")] = None, file : Annotated[Optional[Union[StrictBytes, StrictStr]], Field(description="file to upload")] = None, **kwargs) -> ApiResponse: # noqa: E501 + """uploads an image # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.upload_file(pet_id, additional_metadata, file, async_req=True) + >>> result = thread.get() + + :param pet_id: ID of pet to update (required) + :type pet_id: int + :param additional_metadata: Additional data to pass to server + :type additional_metadata: str + :param file: file to upload + :type file: bytearray + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: ApiResponse + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the upload_file_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.upload_file_with_http_info(pet_id, additional_metadata, file, **kwargs) # noqa: E501 + + @validate_call + def upload_file_with_http_info(self, pet_id : Annotated[StrictInt, Field(..., description="ID of pet to update")], additional_metadata : Annotated[Optional[StrictStr], Field(description="Additional data to pass to server")] = None, file : Annotated[Optional[Union[StrictBytes, StrictStr]], Field(description="file to upload")] = None, **kwargs) -> ApiResponse: # noqa: E501 + """uploads an image # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.upload_file_with_http_info(pet_id, additional_metadata, file, async_req=True) + >>> result = thread.get() + + :param pet_id: ID of pet to update (required) + :type pet_id: int + :param additional_metadata: Additional data to pass to server + :type additional_metadata: str + :param file: file to upload + :type file: bytearray + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(ApiResponse, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'pet_id', + 'additional_metadata', + 'file' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method upload_file" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + if _params['pet_id']: + _path_params['petId'] = _params['pet_id'] + + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + if _params['additional_metadata']: + _form_params.append(('additionalMetadata', _params['additional_metadata'])) + + if _params['file']: + _files['file'] = _params['file'] + + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['multipart/form-data'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = ['petstore_auth'] # noqa: E501 + + _response_types_map = { + '200': "ApiResponse", + } + + return self.api_client.call_api( + '/pet/{petId}/uploadImage', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def upload_file_with_required_file(self, pet_id : Annotated[StrictInt, Field(..., description="ID of pet to update")], required_file : Annotated[Union[StrictBytes, StrictStr], Field(..., description="file to upload")], additional_metadata : Annotated[Optional[StrictStr], Field(description="Additional data to pass to server")] = None, **kwargs) -> ApiResponse: # noqa: E501 + """uploads an image (required) # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.upload_file_with_required_file(pet_id, required_file, additional_metadata, async_req=True) + >>> result = thread.get() + + :param pet_id: ID of pet to update (required) + :type pet_id: int + :param required_file: file to upload (required) + :type required_file: bytearray + :param additional_metadata: Additional data to pass to server + :type additional_metadata: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: ApiResponse + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the upload_file_with_required_file_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.upload_file_with_required_file_with_http_info(pet_id, required_file, additional_metadata, **kwargs) # noqa: E501 + + @validate_call + def upload_file_with_required_file_with_http_info(self, pet_id : Annotated[StrictInt, Field(..., description="ID of pet to update")], required_file : Annotated[Union[StrictBytes, StrictStr], Field(..., description="file to upload")], additional_metadata : Annotated[Optional[StrictStr], Field(description="Additional data to pass to server")] = None, **kwargs) -> ApiResponse: # noqa: E501 + """uploads an image (required) # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.upload_file_with_required_file_with_http_info(pet_id, required_file, additional_metadata, async_req=True) + >>> result = thread.get() + + :param pet_id: ID of pet to update (required) + :type pet_id: int + :param required_file: file to upload (required) + :type required_file: bytearray + :param additional_metadata: Additional data to pass to server + :type additional_metadata: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(ApiResponse, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'pet_id', + 'required_file', + 'additional_metadata' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method upload_file_with_required_file" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + if _params['pet_id']: + _path_params['petId'] = _params['pet_id'] + + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + if _params['additional_metadata']: + _form_params.append(('additionalMetadata', _params['additional_metadata'])) + + if _params['required_file']: + _files['requiredFile'] = _params['required_file'] + + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['multipart/form-data'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = ['petstore_auth'] # noqa: E501 + + _response_types_map = { + '200': "ApiResponse", + } + + return self.api_client.call_api( + '/fake/{petId}/uploadImageWithRequiredFile', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api/store_api.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api/store_api.py new file mode 100755 index 000000000000..5258426e129d --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api/store_api.py @@ -0,0 +1,603 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import re # noqa: F401 +import io +import warnings + +from pydantic import validate_call, ValidationError +from typing_extensions import Annotated + +from typing_extensions import Annotated +from pydantic import Field, StrictStr, conint + +from typing import Dict + +from petstore_api.models.order import Order + +from petstore_api.api_client import ApiClient +from petstore_api.api_response import ApiResponse +from petstore_api.exceptions import ( # noqa: F401 + ApiTypeError, + ApiValueError +) + + +class StoreApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_call + def delete_order(self, order_id : Annotated[StrictStr, Field(..., description="ID of the order that needs to be deleted")], **kwargs) -> None: # noqa: E501 + """Delete purchase order by ID # noqa: E501 + + For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.delete_order(order_id, async_req=True) + >>> result = thread.get() + + :param order_id: ID of the order that needs to be deleted (required) + :type order_id: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the delete_order_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.delete_order_with_http_info(order_id, **kwargs) # noqa: E501 + + @validate_call + def delete_order_with_http_info(self, order_id : Annotated[StrictStr, Field(..., description="ID of the order that needs to be deleted")], **kwargs) -> ApiResponse: # noqa: E501 + """Delete purchase order by ID # noqa: E501 + + For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.delete_order_with_http_info(order_id, async_req=True) + >>> result = thread.get() + + :param order_id: ID of the order that needs to be deleted (required) + :type order_id: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + 'order_id' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method delete_order" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + if _params['order_id']: + _path_params['order_id'] = _params['order_id'] + + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/store/order/{order_id}', 'DELETE', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def get_inventory(self, **kwargs) -> Dict[str, int]: # noqa: E501 + """Returns pet inventories by status # noqa: E501 + + Returns a map of status codes to quantities # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_inventory(async_req=True) + >>> result = thread.get() + + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: Dict[str, int] + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the get_inventory_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.get_inventory_with_http_info(**kwargs) # noqa: E501 + + @validate_call + def get_inventory_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 + """Returns pet inventories by status # noqa: E501 + + Returns a map of status codes to quantities # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_inventory_with_http_info(async_req=True) + >>> result = thread.get() + + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(Dict[str, int], status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method get_inventory" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = ['api_key'] # noqa: E501 + + _response_types_map = { + '200': "Dict[str, int]", + } + + return self.api_client.call_api( + '/store/inventory', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def get_order_by_id(self, order_id : Annotated[conint(strict=True, le=5, ge=1), Field(..., description="ID of pet that needs to be fetched")], **kwargs) -> Order: # noqa: E501 + """Find purchase order by ID # noqa: E501 + + For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_order_by_id(order_id, async_req=True) + >>> result = thread.get() + + :param order_id: ID of pet that needs to be fetched (required) + :type order_id: int + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: Order + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the get_order_by_id_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.get_order_by_id_with_http_info(order_id, **kwargs) # noqa: E501 + + @validate_call + def get_order_by_id_with_http_info(self, order_id : Annotated[conint(strict=True, le=5, ge=1), Field(..., description="ID of pet that needs to be fetched")], **kwargs) -> ApiResponse: # noqa: E501 + """Find purchase order by ID # noqa: E501 + + For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_order_by_id_with_http_info(order_id, async_req=True) + >>> result = thread.get() + + :param order_id: ID of pet that needs to be fetched (required) + :type order_id: int + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(Order, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'order_id' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method get_order_by_id" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + if _params['order_id']: + _path_params['order_id'] = _params['order_id'] + + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/xml', 'application/json']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "Order", + '400': None, + '404': None, + } + + return self.api_client.call_api( + '/store/order/{order_id}', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def place_order(self, order : Annotated[Order, Field(..., description="order placed for purchasing the pet")], **kwargs) -> Order: # noqa: E501 + """Place an order for a pet # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.place_order(order, async_req=True) + >>> result = thread.get() + + :param order: order placed for purchasing the pet (required) + :type order: Order + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: Order + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the place_order_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.place_order_with_http_info(order, **kwargs) # noqa: E501 + + @validate_call + def place_order_with_http_info(self, order : Annotated[Order, Field(..., description="order placed for purchasing the pet")], **kwargs) -> ApiResponse: # noqa: E501 + """Place an order for a pet # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.place_order_with_http_info(order, async_req=True) + >>> result = thread.get() + + :param order: order placed for purchasing the pet (required) + :type order: Order + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(Order, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'order' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method place_order" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['order'] is not None: + _body_params = _params['order'] + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/xml', 'application/json']) # noqa: E501 + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "Order", + '400': None, + } + + return self.api_client.call_api( + '/store/order', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api/user_api.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api/user_api.py new file mode 100755 index 000000000000..4e5cd3eae811 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api/user_api.py @@ -0,0 +1,1183 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import re # noqa: F401 +import io +import warnings + +from pydantic import validate_call, ValidationError +from typing_extensions import Annotated + +from typing_extensions import Annotated +from pydantic import Field, StrictStr, conlist + +from petstore_api.models.user import User + +from petstore_api.api_client import ApiClient +from petstore_api.api_response import ApiResponse +from petstore_api.exceptions import ( # noqa: F401 + ApiTypeError, + ApiValueError +) + + +class UserApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_call + def create_user(self, user : Annotated[User, Field(..., description="Created user object")], **kwargs) -> None: # noqa: E501 + """Create user # noqa: E501 + + This can only be done by the logged in user. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.create_user(user, async_req=True) + >>> result = thread.get() + + :param user: Created user object (required) + :type user: User + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the create_user_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.create_user_with_http_info(user, **kwargs) # noqa: E501 + + @validate_call + def create_user_with_http_info(self, user : Annotated[User, Field(..., description="Created user object")], **kwargs) -> ApiResponse: # noqa: E501 + """Create user # noqa: E501 + + This can only be done by the logged in user. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.create_user_with_http_info(user, async_req=True) + >>> result = thread.get() + + :param user: Created user object (required) + :type user: User + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _hosts = [ + 'http://petstore.swagger.io/v2', + 'http://path-server-test.petstore.local/v2', + 'http://{server}.swagger.io:{port}/v2' + ] + _host = _hosts[0] + if kwargs.get('_host_index'): + _host_index = int(kwargs.get('_host_index')) + if _host_index < 0 or _host_index >= len(_hosts): + raise ApiValueError( + "Invalid host index. Must be 0 <= index < %s" + % len(_host) + ) + _host = _hosts[_host_index] + _params = locals() + + _all_params = [ + 'user' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params and _key != "_host_index": + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method create_user" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['user'] is not None: + _body_params = _params['user'] + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/user', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + _host=_host, + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def create_users_with_array_input(self, user : Annotated[conlist(User), Field(..., description="List of user object")], **kwargs) -> None: # noqa: E501 + """Creates list of users with given input array # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.create_users_with_array_input(user, async_req=True) + >>> result = thread.get() + + :param user: List of user object (required) + :type user: List[User] + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the create_users_with_array_input_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.create_users_with_array_input_with_http_info(user, **kwargs) # noqa: E501 + + @validate_call + def create_users_with_array_input_with_http_info(self, user : Annotated[conlist(User), Field(..., description="List of user object")], **kwargs) -> ApiResponse: # noqa: E501 + """Creates list of users with given input array # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.create_users_with_array_input_with_http_info(user, async_req=True) + >>> result = thread.get() + + :param user: List of user object (required) + :type user: List[User] + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + 'user' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method create_users_with_array_input" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['user'] is not None: + _body_params = _params['user'] + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/user/createWithArray', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def create_users_with_list_input(self, user : Annotated[conlist(User), Field(..., description="List of user object")], **kwargs) -> None: # noqa: E501 + """Creates list of users with given input array # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.create_users_with_list_input(user, async_req=True) + >>> result = thread.get() + + :param user: List of user object (required) + :type user: List[User] + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the create_users_with_list_input_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.create_users_with_list_input_with_http_info(user, **kwargs) # noqa: E501 + + @validate_call + def create_users_with_list_input_with_http_info(self, user : Annotated[conlist(User), Field(..., description="List of user object")], **kwargs) -> ApiResponse: # noqa: E501 + """Creates list of users with given input array # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.create_users_with_list_input_with_http_info(user, async_req=True) + >>> result = thread.get() + + :param user: List of user object (required) + :type user: List[User] + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + 'user' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method create_users_with_list_input" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['user'] is not None: + _body_params = _params['user'] + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/user/createWithList', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def delete_user(self, username : Annotated[StrictStr, Field(..., description="The name that needs to be deleted")], **kwargs) -> None: # noqa: E501 + """Delete user # noqa: E501 + + This can only be done by the logged in user. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.delete_user(username, async_req=True) + >>> result = thread.get() + + :param username: The name that needs to be deleted (required) + :type username: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the delete_user_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.delete_user_with_http_info(username, **kwargs) # noqa: E501 + + @validate_call + def delete_user_with_http_info(self, username : Annotated[StrictStr, Field(..., description="The name that needs to be deleted")], **kwargs) -> ApiResponse: # noqa: E501 + """Delete user # noqa: E501 + + This can only be done by the logged in user. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.delete_user_with_http_info(username, async_req=True) + >>> result = thread.get() + + :param username: The name that needs to be deleted (required) + :type username: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + 'username' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method delete_user" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + if _params['username']: + _path_params['username'] = _params['username'] + + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/user/{username}', 'DELETE', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def get_user_by_name(self, username : Annotated[StrictStr, Field(..., description="The name that needs to be fetched. Use user1 for testing.")], **kwargs) -> User: # noqa: E501 + """Get user by user name # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_user_by_name(username, async_req=True) + >>> result = thread.get() + + :param username: The name that needs to be fetched. Use user1 for testing. (required) + :type username: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: User + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the get_user_by_name_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.get_user_by_name_with_http_info(username, **kwargs) # noqa: E501 + + @validate_call + def get_user_by_name_with_http_info(self, username : Annotated[StrictStr, Field(..., description="The name that needs to be fetched. Use user1 for testing.")], **kwargs) -> ApiResponse: # noqa: E501 + """Get user by user name # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_user_by_name_with_http_info(username, async_req=True) + >>> result = thread.get() + + :param username: The name that needs to be fetched. Use user1 for testing. (required) + :type username: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(User, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'username' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method get_user_by_name" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + if _params['username']: + _path_params['username'] = _params['username'] + + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/xml', 'application/json']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "User", + '400': None, + '404': None, + } + + return self.api_client.call_api( + '/user/{username}', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def login_user(self, username : Annotated[StrictStr, Field(..., description="The user name for login")], password : Annotated[StrictStr, Field(..., description="The password for login in clear text")], **kwargs) -> str: # noqa: E501 + """Logs user into the system # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.login_user(username, password, async_req=True) + >>> result = thread.get() + + :param username: The user name for login (required) + :type username: str + :param password: The password for login in clear text (required) + :type password: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: str + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the login_user_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.login_user_with_http_info(username, password, **kwargs) # noqa: E501 + + @validate_call + def login_user_with_http_info(self, username : Annotated[StrictStr, Field(..., description="The user name for login")], password : Annotated[StrictStr, Field(..., description="The password for login in clear text")], **kwargs) -> ApiResponse: # noqa: E501 + """Logs user into the system # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.login_user_with_http_info(username, password, async_req=True) + >>> result = thread.get() + + :param username: The user name for login (required) + :type username: str + :param password: The password for login in clear text (required) + :type password: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(str, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'username', + 'password' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method login_user" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + if _params.get('username') is not None: # noqa: E501 + _query_params.append(('username', _params['username'])) + + if _params.get('password') is not None: # noqa: E501 + _query_params.append(('password', _params['password'])) + + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/xml', 'application/json']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = { + '200': "str", + '400': None, + } + + return self.api_client.call_api( + '/user/login', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def logout_user(self, **kwargs) -> None: # noqa: E501 + """Logs out current logged in user session # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.logout_user(async_req=True) + >>> result = thread.get() + + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the logout_user_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.logout_user_with_http_info(**kwargs) # noqa: E501 + + @validate_call + def logout_user_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 + """Logs out current logged in user session # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.logout_user_with_http_info(async_req=True) + >>> result = thread.get() + + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method logout_user" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/user/logout', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_call + def update_user(self, username : Annotated[StrictStr, Field(..., description="name that need to be deleted")], user : Annotated[User, Field(..., description="Updated user object")], **kwargs) -> None: # noqa: E501 + """Updated user # noqa: E501 + + This can only be done by the logged in user. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.update_user(username, user, async_req=True) + >>> result = thread.get() + + :param username: name that need to be deleted (required) + :type username: str + :param user: Updated user object (required) + :type user: User + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the update_user_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.update_user_with_http_info(username, user, **kwargs) # noqa: E501 + + @validate_call + def update_user_with_http_info(self, username : Annotated[StrictStr, Field(..., description="name that need to be deleted")], user : Annotated[User, Field(..., description="Updated user object")], **kwargs) -> ApiResponse: # noqa: E501 + """Updated user # noqa: E501 + + This can only be done by the logged in user. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.update_user_with_http_info(username, user, async_req=True) + >>> result = thread.get() + + :param username: name that need to be deleted (required) + :type username: str + :param user: Updated user object (required) + :type user: User + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + 'username', + 'user' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method update_user" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + if _params['username']: + _path_params['username'] = _params['username'] + + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['user'] is not None: + _body_params = _params['user'] + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/user/{username}', 'PUT', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api_client.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api_client.py new file mode 100755 index 000000000000..d5f9031e32ca --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api_client.py @@ -0,0 +1,765 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import atexit +import datetime +from dateutil.parser import parse +import json +import mimetypes +from multiprocessing.pool import ThreadPool +import os +import re +import tempfile + +from urllib.parse import quote + +from petstore_api.configuration import Configuration +from petstore_api.api_response import ApiResponse +import petstore_api.models +from petstore_api import rest +from petstore_api.exceptions import ApiValueError, ApiException + + +class ApiClient: + """Generic API client for OpenAPI client library builds. + + OpenAPI generic API client. This client handles the client- + server communication, and is invariant across implementations. Specifics of + the methods and models for each application are generated from the OpenAPI + templates. + + :param configuration: .Configuration object for this client + :param header_name: a header to pass when making calls to the API. + :param header_value: a header value to pass when making calls to + the API. + :param cookie: a cookie to include in the header when making calls + to the API + :param pool_threads: The number of threads to use for async requests + to the API. More threads means more concurrent API requests. + """ + + PRIMITIVE_TYPES = (float, bool, bytes, str, int) + NATIVE_TYPES_MAPPING = { + 'int': int, + 'long': int, # TODO remove as only py3 is supported? + 'float': float, + 'str': str, + 'bool': bool, + 'date': datetime.date, + 'datetime': datetime.datetime, + 'object': object, + } + _pool = None + + def __init__(self, configuration=None, header_name=None, header_value=None, + cookie=None, pool_threads=1) -> None: + # use default configuration if none is provided + if configuration is None: + configuration = Configuration.get_default() + self.configuration = configuration + self.pool_threads = pool_threads + + self.rest_client = rest.RESTClientObject(configuration) + self.default_headers = {} + if header_name is not None: + self.default_headers[header_name] = header_value + self.cookie = cookie + # Set default User-Agent. + self.user_agent = 'OpenAPI-Generator/1.0.0/python' + self.client_side_validation = configuration.client_side_validation + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + self.close() + + def close(self): + if self._pool: + self._pool.close() + self._pool.join() + self._pool = None + if hasattr(atexit, 'unregister'): + atexit.unregister(self.close) + + @property + def pool(self): + """Create thread pool on first request + avoids instantiating unused threadpool for blocking clients. + """ + if self._pool is None: + atexit.register(self.close) + self._pool = ThreadPool(self.pool_threads) + return self._pool + + @property + def user_agent(self): + """User agent for this API client""" + return self.default_headers['User-Agent'] + + @user_agent.setter + def user_agent(self, value): + self.default_headers['User-Agent'] = value + + def set_default_header(self, header_name, header_value): + self.default_headers[header_name] = header_value + + + _default = None + + @classmethod + def get_default(cls): + """Return new instance of ApiClient. + + This method returns newly created, based on default constructor, + object of ApiClient class or returns a copy of default + ApiClient. + + :return: The ApiClient object. + """ + if cls._default is None: + cls._default = ApiClient() + return cls._default + + @classmethod + def set_default(cls, default): + """Set default instance of ApiClient. + + It stores default ApiClient. + + :param default: object of ApiClient. + """ + cls._default = default + + def __call_api( + self, resource_path, method, path_params=None, + query_params=None, header_params=None, body=None, post_params=None, + files=None, response_types_map=None, auth_settings=None, + _return_http_data_only=None, collection_formats=None, + _preload_content=True, _request_timeout=None, _host=None, + _request_auth=None): + + config = self.configuration + + # header parameters + header_params = header_params or {} + header_params.update(self.default_headers) + if self.cookie: + header_params['Cookie'] = self.cookie + if header_params: + header_params = self.sanitize_for_serialization(header_params) + header_params = dict(self.parameters_to_tuples(header_params, + collection_formats)) + + # path parameters + if path_params: + path_params = self.sanitize_for_serialization(path_params) + path_params = self.parameters_to_tuples(path_params, + collection_formats) + for k, v in path_params: + # specified safe chars, encode everything + resource_path = resource_path.replace( + '{%s}' % k, + quote(str(v), safe=config.safe_chars_for_path_param) + ) + + # post parameters + if post_params or files: + post_params = post_params if post_params else [] + post_params = self.sanitize_for_serialization(post_params) + post_params = self.parameters_to_tuples(post_params, + collection_formats) + post_params.extend(self.files_parameters(files)) + + # auth setting + self.update_params_for_auth( + header_params, query_params, auth_settings, + resource_path, method, body, + request_auth=_request_auth) + + # body + if body: + body = self.sanitize_for_serialization(body) + + # request url + if _host is None: + url = self.configuration.host + resource_path + else: + # use server/host defined in path or operation instead + url = _host + resource_path + + # query parameters + if query_params: + query_params = self.sanitize_for_serialization(query_params) + url_query = self.parameters_to_url_query(query_params, + collection_formats) + url += "?" + url_query + + try: + # perform request and return response + response_data = self.request( + method, url, + query_params=query_params, + headers=header_params, + post_params=post_params, body=body, + _preload_content=_preload_content, + _request_timeout=_request_timeout) + except ApiException as e: + if e.body: + e.body = e.body.decode('utf-8') + raise e + + self.last_response = response_data + + return_data = None # assuming derialization is not needed + # data needs deserialization or returns HTTP data (deserialized) only + if _preload_content or _return_http_data_only: + response_type = response_types_map.get(str(response_data.status), None) + if not response_type and isinstance(response_data.status, int) and 100 <= response_data.status <= 599: + # if not found, look for '1XX', '2XX', etc. + response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) + + if response_type == "bytearray": + response_data.data = response_data.data + else: + match = None + content_type = response_data.getheader('content-type') + if content_type is not None: + match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type) + encoding = match.group(1) if match else "utf-8" + response_data.data = response_data.data.decode(encoding) + + # deserialize response data + if response_type == "bytearray": + return_data = response_data.data + elif response_type: + return_data = self.deserialize(response_data, response_type) + else: + return_data = None + + if _return_http_data_only: + return return_data + else: + return ApiResponse(status_code = response_data.status, + data = return_data, + headers = response_data.getheaders(), + raw_data = response_data.data) + + def sanitize_for_serialization(self, obj): + """Builds a JSON POST object. + + If obj is None, return None. + If obj is str, int, long, float, bool, return directly. + If obj is datetime.datetime, datetime.date + convert to string in iso8601 format. + If obj is list, sanitize each element in the list. + If obj is dict, return the dict. + If obj is OpenAPI model, return the properties dict. + + :param obj: The data to serialize. + :return: The serialized form of data. + """ + if obj is None: + return None + elif isinstance(obj, self.PRIMITIVE_TYPES): + return obj + elif isinstance(obj, list): + return [self.sanitize_for_serialization(sub_obj) + for sub_obj in obj] + elif isinstance(obj, tuple): + return tuple(self.sanitize_for_serialization(sub_obj) + for sub_obj in obj) + elif isinstance(obj, (datetime.datetime, datetime.date)): + return obj.isoformat() + + if isinstance(obj, dict): + obj_dict = obj + else: + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + obj_dict = obj.to_dict() + + return {key: self.sanitize_for_serialization(val) + for key, val in obj_dict.items()} + + def deserialize(self, response, response_type): + """Deserializes response into an object. + + :param response: RESTResponse object to be deserialized. + :param response_type: class literal for + deserialized object, or string of class name. + + :return: deserialized object. + """ + # handle file downloading + # save response body into a tmp file and return the instance + if response_type == "file": + return self.__deserialize_file(response) + + # fetch data from response object + try: + data = json.loads(response.data) + except ValueError: + data = response.data + + return self.__deserialize(data, response_type) + + def __deserialize(self, data, klass): + """Deserializes dict, list, str into an object. + + :param data: dict, list or str. + :param klass: class literal, or string of class name. + + :return: object. + """ + if data is None: + return None + + if isinstance(klass, str): + if klass.startswith('List['): + sub_kls = re.match(r'List\[(.*)]', klass).group(1) + return [self.__deserialize(sub_data, sub_kls) + for sub_data in data] + + if klass.startswith('Dict['): + sub_kls = re.match(r'Dict\[([^,]*), (.*)]', klass).group(2) + return {k: self.__deserialize(v, sub_kls) + for k, v in data.items()} + + # convert str to class + if klass in self.NATIVE_TYPES_MAPPING: + klass = self.NATIVE_TYPES_MAPPING[klass] + else: + klass = getattr(petstore_api.models, klass) + + if klass in self.PRIMITIVE_TYPES: + return self.__deserialize_primitive(data, klass) + elif klass == object: + return self.__deserialize_object(data) + elif klass == datetime.date: + return self.__deserialize_date(data) + elif klass == datetime.datetime: + return self.__deserialize_datetime(data) + else: + return self.__deserialize_model(data, klass) + + def call_api(self, resource_path, method, + path_params=None, query_params=None, header_params=None, + body=None, post_params=None, files=None, + response_types_map=None, auth_settings=None, + async_req=None, _return_http_data_only=None, + collection_formats=None, _preload_content=True, + _request_timeout=None, _host=None, _request_auth=None): + """Makes the HTTP request (synchronous) and returns deserialized data. + + To make an async_req request, set the async_req parameter. + + :param resource_path: Path to method endpoint. + :param method: Method to call. + :param path_params: Path parameters in the url. + :param query_params: Query parameters in the url. + :param header_params: Header parameters to be + placed in the request header. + :param body: Request body. + :param post_params dict: Request post form parameters, + for `application/x-www-form-urlencoded`, `multipart/form-data`. + :param auth_settings list: Auth Settings names for the request. + :param response: Response data type. + :param files dict: key -> filename, value -> filepath, + for `multipart/form-data`. + :param async_req bool: execute request asynchronously + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :param collection_formats: dict of collection formats for path, query, + header, and post parameters. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_token: dict, optional + :return: + If async_req parameter is True, + the request will be called asynchronously. + The method will return the request thread. + If parameter async_req is False or missing, + then the method will return the response directly. + """ + if not async_req: + return self.__call_api(resource_path, method, + path_params, query_params, header_params, + body, post_params, files, + response_types_map, auth_settings, + _return_http_data_only, collection_formats, + _preload_content, _request_timeout, _host, + _request_auth) + + return self.pool.apply_async(self.__call_api, (resource_path, + method, path_params, + query_params, + header_params, body, + post_params, files, + response_types_map, + auth_settings, + _return_http_data_only, + collection_formats, + _preload_content, + _request_timeout, + _host, _request_auth)) + + def request(self, method, url, query_params=None, headers=None, + post_params=None, body=None, _preload_content=True, + _request_timeout=None): + """Makes the HTTP request using RESTClient.""" + if method == "GET": + return self.rest_client.get_request(url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers) + elif method == "HEAD": + return self.rest_client.head_request(url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers) + elif method == "OPTIONS": + return self.rest_client.options_request(url, + query_params=query_params, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout) + elif method == "POST": + return self.rest_client.post_request(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "PUT": + return self.rest_client.put_request(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "PATCH": + return self.rest_client.patch_request(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "DELETE": + return self.rest_client.delete_request(url, + query_params=query_params, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + else: + raise ApiValueError( + "http method must be `GET`, `HEAD`, `OPTIONS`," + " `POST`, `PATCH`, `PUT` or `DELETE`." + ) + + def parameters_to_tuples(self, params, collection_formats): + """Get parameters as list of tuples, formatting collections. + + :param params: Parameters as dict or list of two-tuples + :param dict collection_formats: Parameter collection formats + :return: Parameters as list of tuples, collections formatted + """ + new_params = [] + if collection_formats is None: + collection_formats = {} + for k, v in params.items() if isinstance(params, dict) else params: # noqa: E501 + if k in collection_formats: + collection_format = collection_formats[k] + if collection_format == 'multi': + new_params.extend((k, value) for value in v) + else: + if collection_format == 'ssv': + delimiter = ' ' + elif collection_format == 'tsv': + delimiter = '\t' + elif collection_format == 'pipes': + delimiter = '|' + else: # csv is the default + delimiter = ',' + new_params.append( + (k, delimiter.join(str(value) for value in v))) + else: + new_params.append((k, v)) + return new_params + + def parameters_to_url_query(self, params, collection_formats): + """Get parameters as list of tuples, formatting collections. + + :param params: Parameters as dict or list of two-tuples + :param dict collection_formats: Parameter collection formats + :return: URL query string (e.g. a=Hello%20World&b=123) + """ + new_params = [] + if collection_formats is None: + collection_formats = {} + for k, v in params.items() if isinstance(params, dict) else params: # noqa: E501 + if isinstance(v, (int, float)): + v = str(v) + if isinstance(v, bool): + v = str(v).lower() + if isinstance(v, dict): + v = json.dumps(v) + + if k in collection_formats: + collection_format = collection_formats[k] + if collection_format == 'multi': + new_params.extend((k, value) for value in v) + else: + if collection_format == 'ssv': + delimiter = ' ' + elif collection_format == 'tsv': + delimiter = '\t' + elif collection_format == 'pipes': + delimiter = '|' + else: # csv is the default + delimiter = ',' + new_params.append( + (k, delimiter.join(quote(str(value)) for value in v))) + else: + new_params.append((k, quote(str(v)))) + + return "&".join(["=".join(item) for item in new_params]) + + def files_parameters(self, files=None): + """Builds form parameters. + + :param files: File parameters. + :return: Form parameters with files. + """ + params = [] + + if files: + for k, v in files.items(): + if not v: + continue + file_names = v if type(v) is list else [v] + for n in file_names: + with open(n, 'rb') as f: + filename = os.path.basename(f.name) + filedata = f.read() + mimetype = (mimetypes.guess_type(filename)[0] or + 'application/octet-stream') + params.append( + tuple([k, tuple([filename, filedata, mimetype])])) + + return params + + def select_header_accept(self, accepts): + """Returns `Accept` based on an array of accepts provided. + + :param accepts: List of headers. + :return: Accept (e.g. application/json). + """ + if not accepts: + return + + for accept in accepts: + if re.search('json', accept, re.IGNORECASE): + return accept + + return accepts[0] + + def select_header_content_type(self, content_types): + """Returns `Content-Type` based on an array of content_types provided. + + :param content_types: List of content-types. + :return: Content-Type (e.g. application/json). + """ + if not content_types: + return None + + for content_type in content_types: + if re.search('json', content_type, re.IGNORECASE): + return content_type + + return content_types[0] + + def update_params_for_auth(self, headers, queries, auth_settings, + resource_path, method, body, + request_auth=None): + """Updates header and query params based on authentication setting. + + :param headers: Header parameters dict to be updated. + :param queries: Query parameters tuple list to be updated. + :param auth_settings: Authentication setting identifiers list. + :resource_path: A string representation of the HTTP request resource path. + :method: A string representation of the HTTP request method. + :body: A object representing the body of the HTTP request. + The object type is the return value of sanitize_for_serialization(). + :param request_auth: if set, the provided settings will + override the token in the configuration. + """ + if not auth_settings: + return + + if request_auth: + self._apply_auth_params(headers, queries, + resource_path, method, body, + request_auth) + return + + for auth in auth_settings: + auth_setting = self.configuration.auth_settings().get(auth) + if auth_setting: + self._apply_auth_params(headers, queries, + resource_path, method, body, + auth_setting) + + def _apply_auth_params(self, headers, queries, + resource_path, method, body, + auth_setting): + """Updates the request parameters based on a single auth_setting + + :param headers: Header parameters dict to be updated. + :param queries: Query parameters tuple list to be updated. + :resource_path: A string representation of the HTTP request resource path. + :method: A string representation of the HTTP request method. + :body: A object representing the body of the HTTP request. + The object type is the return value of sanitize_for_serialization(). + :param auth_setting: auth settings for the endpoint + """ + if auth_setting['in'] == 'cookie': + headers['Cookie'] = auth_setting['value'] + elif auth_setting['in'] == 'header': + if auth_setting['type'] != 'http-signature': + headers[auth_setting['key']] = auth_setting['value'] + else: + # The HTTP signature scheme requires multiple HTTP headers + # that are calculated dynamically. + signing_info = self.configuration.signing_info + auth_headers = signing_info.get_http_signature_headers( + resource_path, method, headers, body, queries) + headers.update(auth_headers) + elif auth_setting['in'] == 'query': + queries.append((auth_setting['key'], auth_setting['value'])) + else: + raise ApiValueError( + 'Authentication token must be in `query` or `header`' + ) + + def __deserialize_file(self, response): + """Deserializes body to file + + Saves response body into a file in a temporary folder, + using the filename from the `Content-Disposition` header if provided. + + :param response: RESTResponse. + :return: file path. + """ + fd, path = tempfile.mkstemp(dir=self.configuration.temp_folder_path) + os.close(fd) + os.remove(path) + + content_disposition = response.getheader("Content-Disposition") + if content_disposition: + filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', + content_disposition).group(1) + path = os.path.join(os.path.dirname(path), filename) + + with open(path, "wb") as f: + f.write(response.data) + + return path + + def __deserialize_primitive(self, data, klass): + """Deserializes string to primitive type. + + :param data: str. + :param klass: class literal. + + :return: int, long, float, str, bool. + """ + try: + return klass(data) + except UnicodeEncodeError: + return str(data) + except TypeError: + return data + + def __deserialize_object(self, value): + """Return an original value. + + :return: object. + """ + return value + + def __deserialize_date(self, string): + """Deserializes string to date. + + :param string: str. + :return: date. + """ + try: + return parse(string).date() + except ImportError: + return string + except ValueError: + raise rest.ApiException( + status=0, + reason="Failed to parse `{0}` as date object".format(string) + ) + + def __deserialize_datetime(self, string): + """Deserializes string to datetime. + + The string should be in iso8601 datetime format. + + :param string: str. + :return: datetime. + """ + try: + return parse(string) + except ImportError: + return string + except ValueError: + raise rest.ApiException( + status=0, + reason=( + "Failed to parse `{0}` as datetime object" + .format(string) + ) + ) + + def __deserialize_model(self, data, klass): + """Deserializes list or dict to model. + + :param data: dict, list. + :param klass: class literal. + :return: model object. + """ + + return klass.from_dict(data) diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api_response.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api_response.py new file mode 100644 index 000000000000..a0b62b95246c --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/api_response.py @@ -0,0 +1,25 @@ +"""API response object.""" + +from __future__ import annotations +from typing import Any, Dict, Optional +from pydantic import Field, StrictInt, StrictStr + +class ApiResponse: + """ + API response object + """ + + status_code: Optional[StrictInt] = Field(None, description="HTTP status code") + headers: Optional[Dict[StrictStr, StrictStr]] = Field(None, description="HTTP headers") + data: Optional[Any] = Field(None, description="Deserialized data given the data type") + raw_data: Optional[Any] = Field(None, description="Raw data (HTTP response body)") + + def __init__(self, + status_code=None, + headers=None, + data=None, + raw_data=None) -> None: + self.status_code = status_code + self.headers = headers + self.data = data + self.raw_data = raw_data diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/configuration.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/configuration.py new file mode 100755 index 000000000000..8bca6dc7ab0e --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/configuration.py @@ -0,0 +1,605 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import copy +import logging +import multiprocessing +import sys +import urllib3 + +import http.client as httplib + +JSON_SCHEMA_VALIDATION_KEYWORDS = { + 'multipleOf', 'maximum', 'exclusiveMaximum', + 'minimum', 'exclusiveMinimum', 'maxLength', + 'minLength', 'pattern', 'maxItems', 'minItems' +} + +class Configuration: + """This class contains various settings of the API client. + + :param host: Base url. + :param api_key: Dict to store API key(s). + Each entry in the dict specifies an API key. + The dict key is the name of the security scheme in the OAS specification. + The dict value is the API key secret. + :param api_key_prefix: Dict to store API prefix (e.g. Bearer). + The dict key is the name of the security scheme in the OAS specification. + The dict value is an API key prefix when generating the auth data. + :param username: Username for HTTP basic authentication. + :param password: Password for HTTP basic authentication. + :param access_token: Access token. + :param signing_info: Configuration parameters for the HTTP signature security scheme. + Must be an instance of petstore_api.signing.HttpSigningConfiguration + :param server_index: Index to servers configuration. + :param server_variables: Mapping with string values to replace variables in + templated server configuration. The validation of enums is performed for + variables with defined enum values before. + :param server_operation_index: Mapping from operation ID to an index to server + configuration. + :param server_operation_variables: Mapping from operation ID to a mapping with + string values to replace variables in templated server configuration. + The validation of enums is performed for variables with defined enum + values before. + :param ssl_ca_cert: str - the path to a file of concatenated CA certificates + in PEM format. + + :Example: + + API Key Authentication Example. + Given the following security scheme in the OpenAPI specification: + components: + securitySchemes: + cookieAuth: # name for the security scheme + type: apiKey + in: cookie + name: JSESSIONID # cookie name + + You can programmatically set the cookie: + +conf = petstore_api.Configuration( + api_key={'cookieAuth': 'abc123'} + api_key_prefix={'cookieAuth': 'JSESSIONID'} +) + + The following cookie will be added to the HTTP request: + Cookie: JSESSIONID abc123 + + HTTP Basic Authentication Example. + Given the following security scheme in the OpenAPI specification: + components: + securitySchemes: + http_basic_auth: + type: http + scheme: basic + + Configure API client with HTTP basic authentication: + +conf = petstore_api.Configuration( + username='the-user', + password='the-password', +) + + + HTTP Signature Authentication Example. + Given the following security scheme in the OpenAPI specification: + components: + securitySchemes: + http_basic_auth: + type: http + scheme: signature + + Configure API client with HTTP signature authentication. Use the 'hs2019' signature scheme, + sign the HTTP requests with the RSA-SSA-PSS signature algorithm, and set the expiration time + of the signature to 5 minutes after the signature has been created. + Note you can use the constants defined in the petstore_api.signing module, and you can + also specify arbitrary HTTP headers to be included in the HTTP signature, except for the + 'Authorization' header, which is used to carry the signature. + + One may be tempted to sign all headers by default, but in practice it rarely works. + This is because explicit proxies, transparent proxies, TLS termination endpoints or + load balancers may add/modify/remove headers. Include the HTTP headers that you know + are not going to be modified in transit. + +conf = petstore_api.Configuration( + signing_info = petstore_api.signing.HttpSigningConfiguration( + key_id = 'my-key-id', + private_key_path = 'rsa.pem', + signing_scheme = petstore_api.signing.SCHEME_HS2019, + signing_algorithm = petstore_api.signing.ALGORITHM_RSASSA_PSS, + signed_headers = [petstore_api.signing.HEADER_REQUEST_TARGET, + petstore_api.signing.HEADER_CREATED, + petstore_api.signing.HEADER_EXPIRES, + petstore_api.signing.HEADER_HOST, + petstore_api.signing.HEADER_DATE, + petstore_api.signing.HEADER_DIGEST, + 'Content-Type', + 'User-Agent' + ], + signature_max_validity = datetime.timedelta(minutes=5) + ) +) + """ + + _default = None + + def __init__(self, host=None, + api_key=None, api_key_prefix=None, + username=None, password=None, + access_token=None, + signing_info=None, + server_index=None, server_variables=None, + server_operation_index=None, server_operation_variables=None, + ssl_ca_cert=None, + ) -> None: + """Constructor + """ + self._base_path = "http://petstore.swagger.io:80/v2" if host is None else host + """Default Base url + """ + self.server_index = 0 if server_index is None and host is None else server_index + self.server_operation_index = server_operation_index or {} + """Default server index + """ + self.server_variables = server_variables or {} + self.server_operation_variables = server_operation_variables or {} + """Default server variables + """ + self.temp_folder_path = None + """Temp file folder for downloading files + """ + # Authentication Settings + self.api_key = {} + if api_key: + self.api_key = api_key + """dict to store API key(s) + """ + self.api_key_prefix = {} + if api_key_prefix: + self.api_key_prefix = api_key_prefix + """dict to store API prefix (e.g. Bearer) + """ + self.refresh_api_key_hook = None + """function hook to refresh API key if expired + """ + self.username = username + """Username for HTTP basic authentication + """ + self.password = password + """Password for HTTP basic authentication + """ + self.access_token = access_token + """Access token + """ + if signing_info is not None: + signing_info.host = host + self.signing_info = signing_info + """The HTTP signing configuration + """ + self.logger = {} + """Logging Settings + """ + self.logger["package_logger"] = logging.getLogger("petstore_api") + self.logger["urllib3_logger"] = logging.getLogger("urllib3") + self.logger_format = '%(asctime)s %(levelname)s %(message)s' + """Log format + """ + self.logger_stream_handler = None + """Log stream handler + """ + self.logger_file_handler = None + """Log file handler + """ + self.logger_file = None + """Debug file location + """ + self.debug = False + """Debug switch + """ + + self.verify_ssl = True + """SSL/TLS verification + Set this to false to skip verifying SSL certificate when calling API + from https server. + """ + self.ssl_ca_cert = ssl_ca_cert + """Set this to customize the certificate file to verify the peer. + """ + self.cert_file = None + """client certificate file + """ + self.key_file = None + """client key file + """ + self.assert_hostname = None + """Set this to True/False to enable/disable SSL hostname verification. + """ + self.tls_server_name = None + """SSL/TLS Server Name Indication (SNI) + Set this to the SNI value expected by the server. + """ + + self.connection_pool_maxsize = multiprocessing.cpu_count() * 5 + """urllib3 connection pool's maximum number of connections saved + per pool. urllib3 uses 1 connection as default value, but this is + not the best value when you are making a lot of possibly parallel + requests to the same host, which is often the case here. + cpu_count * 5 is used as default value to increase performance. + """ + + self.proxy = None + """Proxy URL + """ + self.proxy_headers = None + """Proxy headers + """ + self.safe_chars_for_path_param = '' + """Safe chars for path_param + """ + self.retries = None + """Adding retries to override urllib3 default value 3 + """ + # Enable client side validation + self.client_side_validation = True + + self.socket_options = None + """Options to pass down to the underlying urllib3 socket + """ + + self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z" + """datetime format + """ + + self.date_format = "%Y-%m-%d" + """date format + """ + + def __deepcopy__(self, memo): + cls = self.__class__ + result = cls.__new__(cls) + memo[id(self)] = result + for k, v in self.__dict__.items(): + if k not in ('logger', 'logger_file_handler'): + setattr(result, k, copy.deepcopy(v, memo)) + # shallow copy of loggers + result.logger = copy.copy(self.logger) + # use setters to configure loggers + result.logger_file = self.logger_file + result.debug = self.debug + return result + + def __setattr__(self, name, value): + object.__setattr__(self, name, value) + if name == "signing_info" and value is not None: + # Ensure the host parameter from signing info is the same as + # Configuration.host. + value.host = self.host + + @classmethod + def set_default(cls, default): + """Set default instance of configuration. + + It stores default configuration, which can be + returned by get_default_copy method. + + :param default: object of Configuration + """ + cls._default = default + + @classmethod + def get_default_copy(cls): + """Deprecated. Please use `get_default` instead. + + Deprecated. Please use `get_default` instead. + + :return: The configuration object. + """ + return cls.get_default() + + @classmethod + def get_default(cls): + """Return the default configuration. + + This method returns newly created, based on default constructor, + object of Configuration class or returns a copy of default + configuration. + + :return: The configuration object. + """ + if cls._default is None: + cls._default = Configuration() + return cls._default + + @property + def logger_file(self): + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + return self.__logger_file + + @logger_file.setter + def logger_file(self, value): + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + self.__logger_file = value + if self.__logger_file: + # If set logging file, + # then add file handler and remove stream handler. + self.logger_file_handler = logging.FileHandler(self.__logger_file) + self.logger_file_handler.setFormatter(self.logger_formatter) + for _, logger in self.logger.items(): + logger.addHandler(self.logger_file_handler) + + @property + def debug(self): + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + return self.__debug + + @debug.setter + def debug(self, value): + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + self.__debug = value + if self.__debug: + # if debug status is True, turn on debug logging + for _, logger in self.logger.items(): + logger.setLevel(logging.DEBUG) + # turn on httplib debug + httplib.HTTPConnection.debuglevel = 1 + else: + # if debug status is False, turn off debug logging, + # setting log level to default `logging.WARNING` + for _, logger in self.logger.items(): + logger.setLevel(logging.WARNING) + # turn off httplib debug + httplib.HTTPConnection.debuglevel = 0 + + @property + def logger_format(self): + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + return self.__logger_format + + @logger_format.setter + def logger_format(self, value): + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + self.__logger_format = value + self.logger_formatter = logging.Formatter(self.__logger_format) + + def get_api_key_with_prefix(self, identifier, alias=None): + """Gets API key (with prefix if set). + + :param identifier: The identifier of apiKey. + :param alias: The alternative identifier of apiKey. + :return: The token for api key authentication. + """ + if self.refresh_api_key_hook is not None: + self.refresh_api_key_hook(self) + key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None) + if key: + prefix = self.api_key_prefix.get(identifier) + if prefix: + return "%s %s" % (prefix, key) + else: + return key + + def get_basic_auth_token(self): + """Gets HTTP basic authentication header (string). + + :return: The token for basic HTTP authentication. + """ + username = "" + if self.username is not None: + username = self.username + password = "" + if self.password is not None: + password = self.password + return urllib3.util.make_headers( + basic_auth=username + ':' + password + ).get('authorization') + + def auth_settings(self): + """Gets Auth Settings dict for api client. + + :return: The Auth Settings information dict. + """ + auth = {} + if self.access_token is not None: + auth['petstore_auth'] = { + 'type': 'oauth2', + 'in': 'header', + 'key': 'Authorization', + 'value': 'Bearer ' + self.access_token + } + if 'api_key' in self.api_key: + auth['api_key'] = { + 'type': 'api_key', + 'in': 'header', + 'key': 'api_key', + 'value': self.get_api_key_with_prefix( + 'api_key', + ), + } + if 'api_key_query' in self.api_key: + auth['api_key_query'] = { + 'type': 'api_key', + 'in': 'query', + 'key': 'api_key_query', + 'value': self.get_api_key_with_prefix( + 'api_key_query', + ), + } + if self.username is not None and self.password is not None: + auth['http_basic_test'] = { + 'type': 'basic', + 'in': 'header', + 'key': 'Authorization', + 'value': self.get_basic_auth_token() + } + if self.access_token is not None: + auth['bearer_test'] = { + 'type': 'bearer', + 'in': 'header', + 'format': 'JWT', + 'key': 'Authorization', + 'value': 'Bearer ' + self.access_token + } + if self.signing_info is not None: + auth['http_signature_test'] = { + 'type': 'http-signature', + 'in': 'header', + 'key': 'Authorization', + 'value': None # Signature headers are calculated for every HTTP request + } + return auth + + def to_debug_report(self): + """Gets the essential information for debugging. + + :return: The report for debugging. + """ + return "Python SDK Debug Report:\n"\ + "OS: {env}\n"\ + "Python Version: {pyversion}\n"\ + "Version of the API: 1.0.0\n"\ + "SDK Package Version: 1.0.0".\ + format(env=sys.platform, pyversion=sys.version) + + def get_host_settings(self): + """Gets an array of host settings + + :return: An array of host settings + """ + return [ + { + 'url': "http://{server}.swagger.io:{port}/v2", + 'description': "petstore server", + 'variables': { + 'server': { + 'description': "No description provided", + 'default_value': "petstore", + 'enum_values': [ + "petstore", + "qa-petstore", + "dev-petstore" + ] + }, + 'port': { + 'description': "No description provided", + 'default_value': "80", + 'enum_values': [ + "80", + "8080" + ] + } + } + }, + { + 'url': "https://localhost:8080/{version}", + 'description': "The local server", + 'variables': { + 'version': { + 'description': "No description provided", + 'default_value': "v2", + 'enum_values': [ + "v1", + "v2" + ] + } + } + }, + { + 'url': "https://127.0.0.1/no_varaible", + 'description': "The local server without variables", + } + ] + + def get_host_from_settings(self, index, variables=None, servers=None): + """Gets host URL based on the index and variables + :param index: array index of the host settings + :param variables: hash of variable and the corresponding value + :param servers: an array of host settings or None + :return: URL based on host settings + """ + if index is None: + return self._base_path + + variables = {} if variables is None else variables + servers = self.get_host_settings() if servers is None else servers + + try: + server = servers[index] + except IndexError: + raise ValueError( + "Invalid index {0} when selecting the host settings. " + "Must be less than {1}".format(index, len(servers))) + + url = server['url'] + + # go through variables and replace placeholders + for variable_name, variable in server.get('variables', {}).items(): + used_value = variables.get( + variable_name, variable['default_value']) + + if 'enum_values' in variable \ + and used_value not in variable['enum_values']: + raise ValueError( + "The variable `{0}` in the host URL has invalid value " + "{1}. Must be {2}.".format( + variable_name, variables[variable_name], + variable['enum_values'])) + + url = url.replace("{" + variable_name + "}", used_value) + + return url + + @property + def host(self): + """Return generated host.""" + return self.get_host_from_settings(self.server_index, variables=self.server_variables) + + @host.setter + def host(self, value): + """Fix base path.""" + self._base_path = value + self.server_index = None diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/exceptions.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/exceptions.py new file mode 100755 index 000000000000..6c4ae9c4e02f --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/exceptions.py @@ -0,0 +1,166 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +class OpenApiException(Exception): + """The base exception class for all OpenAPIExceptions""" + + +class ApiTypeError(OpenApiException, TypeError): + def __init__(self, msg, path_to_item=None, valid_classes=None, + key_type=None) -> None: + """ Raises an exception for TypeErrors + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list): a list of keys an indices to get to the + current_item + None if unset + valid_classes (tuple): the primitive classes that current item + should be an instance of + None if unset + key_type (bool): False if our value is a value in a dict + True if it is a key in a dict + False if our item is an item in a list + None if unset + """ + self.path_to_item = path_to_item + self.valid_classes = valid_classes + self.key_type = key_type + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiTypeError, self).__init__(full_msg) + + +class ApiValueError(OpenApiException, ValueError): + def __init__(self, msg, path_to_item=None) -> None: + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list) the path to the exception in the + received_data dict. None if unset + """ + + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiValueError, self).__init__(full_msg) + + +class ApiAttributeError(OpenApiException, AttributeError): + def __init__(self, msg, path_to_item=None) -> None: + """ + Raised when an attribute reference or assignment fails. + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiAttributeError, self).__init__(full_msg) + + +class ApiKeyError(OpenApiException, KeyError): + def __init__(self, msg, path_to_item=None) -> None: + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiKeyError, self).__init__(full_msg) + + +class ApiException(OpenApiException): + + def __init__(self, status=None, reason=None, http_resp=None) -> None: + if http_resp: + self.status = http_resp.status + self.reason = http_resp.reason + self.body = http_resp.data + self.headers = http_resp.getheaders() + else: + self.status = status + self.reason = reason + self.body = None + self.headers = None + + def __str__(self): + """Custom error messages for exception""" + error_message = "({0})\n"\ + "Reason: {1}\n".format(self.status, self.reason) + if self.headers: + error_message += "HTTP response headers: {0}\n".format( + self.headers) + + if self.body: + error_message += "HTTP response body: {0}\n".format(self.body) + + return error_message + +class BadRequestException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None) -> None: + super(BadRequestException, self).__init__(status, reason, http_resp) + +class NotFoundException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None) -> None: + super(NotFoundException, self).__init__(status, reason, http_resp) + + +class UnauthorizedException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None) -> None: + super(UnauthorizedException, self).__init__(status, reason, http_resp) + + +class ForbiddenException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None) -> None: + super(ForbiddenException, self).__init__(status, reason, http_resp) + + +class ServiceException(ApiException): + + def __init__(self, status=None, reason=None, http_resp=None) -> None: + super(ServiceException, self).__init__(status, reason, http_resp) + + +def render_path(path_to_item): + """Returns a string representation of a path""" + result = "" + for pth in path_to_item: + if isinstance(pth, int): + result += "[{0}]".format(pth) + else: + result += "['{0}']".format(pth) + return result diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/__init__.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/__init__.py new file mode 100644 index 000000000000..b3a4d362afc6 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/__init__.py @@ -0,0 +1,91 @@ +# coding: utf-8 + +# flake8: noqa +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +# import models into model package +from petstore_api.models.additional_properties_any_type import AdditionalPropertiesAnyType +from petstore_api.models.additional_properties_class import AdditionalPropertiesClass +from petstore_api.models.additional_properties_object import AdditionalPropertiesObject +from petstore_api.models.additional_properties_with_description_only import AdditionalPropertiesWithDescriptionOnly +from petstore_api.models.all_of_with_single_ref import AllOfWithSingleRef +from petstore_api.models.animal import Animal +from petstore_api.models.any_of_color import AnyOfColor +from petstore_api.models.any_of_pig import AnyOfPig +from petstore_api.models.api_response import ApiResponse +from petstore_api.models.array_of_array_of_model import ArrayOfArrayOfModel +from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly +from petstore_api.models.array_of_number_only import ArrayOfNumberOnly +from petstore_api.models.array_test import ArrayTest +from petstore_api.models.basque_pig import BasquePig +from petstore_api.models.capitalization import Capitalization +from petstore_api.models.cat import Cat +from petstore_api.models.category import Category +from petstore_api.models.class_model import ClassModel +from petstore_api.models.client import Client +from petstore_api.models.color import Color +from petstore_api.models.creature import Creature +from petstore_api.models.creature_info import CreatureInfo +from petstore_api.models.danish_pig import DanishPig +from petstore_api.models.deprecated_object import DeprecatedObject +from petstore_api.models.dog import Dog +from petstore_api.models.dummy_model import DummyModel +from petstore_api.models.enum_arrays import EnumArrays +from petstore_api.models.enum_class import EnumClass +from petstore_api.models.enum_string1 import EnumString1 +from petstore_api.models.enum_string2 import EnumString2 +from petstore_api.models.enum_test import EnumTest +from petstore_api.models.file import File +from petstore_api.models.file_schema_test_class import FileSchemaTestClass +from petstore_api.models.foo import Foo +from petstore_api.models.foo_get_default_response import FooGetDefaultResponse +from petstore_api.models.format_test import FormatTest +from petstore_api.models.has_only_read_only import HasOnlyReadOnly +from petstore_api.models.health_check_result import HealthCheckResult +from petstore_api.models.inner_dict_with_property import InnerDictWithProperty +from petstore_api.models.int_or_string import IntOrString +from petstore_api.models.list import List +from petstore_api.models.map_of_array_of_model import MapOfArrayOfModel +from petstore_api.models.map_test import MapTest +from petstore_api.models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass +from petstore_api.models.model200_response import Model200Response +from petstore_api.models.model_return import ModelReturn +from petstore_api.models.name import Name +from petstore_api.models.nullable_class import NullableClass +from petstore_api.models.nullable_property import NullableProperty +from petstore_api.models.number_only import NumberOnly +from petstore_api.models.object_to_test_additional_properties import ObjectToTestAdditionalProperties +from petstore_api.models.object_with_deprecated_fields import ObjectWithDeprecatedFields +from petstore_api.models.one_of_enum_string import OneOfEnumString +from petstore_api.models.order import Order +from petstore_api.models.outer_composite import OuterComposite +from petstore_api.models.outer_enum import OuterEnum +from petstore_api.models.outer_enum_default_value import OuterEnumDefaultValue +from petstore_api.models.outer_enum_integer import OuterEnumInteger +from petstore_api.models.outer_enum_integer_default_value import OuterEnumIntegerDefaultValue +from petstore_api.models.outer_object_with_enum_property import OuterObjectWithEnumProperty +from petstore_api.models.parent import Parent +from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict +from petstore_api.models.pet import Pet +from petstore_api.models.pig import Pig +from petstore_api.models.property_name_collision import PropertyNameCollision +from petstore_api.models.read_only_first import ReadOnlyFirst +from petstore_api.models.self_reference_model import SelfReferenceModel +from petstore_api.models.single_ref_type import SingleRefType +from petstore_api.models.special_character_enum import SpecialCharacterEnum +from petstore_api.models.special_model_name import SpecialModelName +from petstore_api.models.special_name import SpecialName +from petstore_api.models.tag import Tag +from petstore_api.models.tiger import Tiger +from petstore_api.models.user import User +from petstore_api.models.with_nested_one_of import WithNestedOneOf diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/additional_properties_any_type.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/additional_properties_any_type.py new file mode 100644 index 000000000000..22dda9cd1174 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/additional_properties_any_type.py @@ -0,0 +1,84 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, StrictStr + +class AdditionalPropertiesAnyType(BaseModel): + """ + AdditionalPropertiesAnyType + """ + name: Optional[StrictStr] = None + additional_properties: Dict[str, Any] = {} + __properties = ["name"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> AdditionalPropertiesAnyType: + """Create an instance of AdditionalPropertiesAnyType from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> AdditionalPropertiesAnyType: + """Create an instance of AdditionalPropertiesAnyType from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return AdditionalPropertiesAnyType.parse_obj(obj) + + _obj = AdditionalPropertiesAnyType.parse_obj({ + "name": obj.get("name") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/additional_properties_class.py new file mode 100644 index 000000000000..77a275f8dd31 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/additional_properties_class.py @@ -0,0 +1,86 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, StrictStr + +class AdditionalPropertiesClass(BaseModel): + """ + AdditionalPropertiesClass + """ + map_property: Optional[Dict[str, StrictStr]] = None + map_of_map_property: Optional[Dict[str, Dict[str, StrictStr]]] = None + additional_properties: Dict[str, Any] = {} + __properties = ["map_property", "map_of_map_property"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> AdditionalPropertiesClass: + """Create an instance of AdditionalPropertiesClass from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> AdditionalPropertiesClass: + """Create an instance of AdditionalPropertiesClass from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return AdditionalPropertiesClass.parse_obj(obj) + + _obj = AdditionalPropertiesClass.parse_obj({ + "map_property": obj.get("map_property"), + "map_of_map_property": obj.get("map_of_map_property") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/additional_properties_object.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/additional_properties_object.py new file mode 100644 index 000000000000..7254315fc50e --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/additional_properties_object.py @@ -0,0 +1,84 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, StrictStr + +class AdditionalPropertiesObject(BaseModel): + """ + AdditionalPropertiesObject + """ + name: Optional[StrictStr] = None + additional_properties: Dict[str, Any] = {} + __properties = ["name"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> AdditionalPropertiesObject: + """Create an instance of AdditionalPropertiesObject from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> AdditionalPropertiesObject: + """Create an instance of AdditionalPropertiesObject from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return AdditionalPropertiesObject.parse_obj(obj) + + _obj = AdditionalPropertiesObject.parse_obj({ + "name": obj.get("name") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/additional_properties_with_description_only.py new file mode 100644 index 000000000000..59219a93c349 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/additional_properties_with_description_only.py @@ -0,0 +1,84 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, StrictStr + +class AdditionalPropertiesWithDescriptionOnly(BaseModel): + """ + AdditionalPropertiesWithDescriptionOnly + """ + name: Optional[StrictStr] = None + additional_properties: Dict[str, Any] = {} + __properties = ["name"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> AdditionalPropertiesWithDescriptionOnly: + """Create an instance of AdditionalPropertiesWithDescriptionOnly from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> AdditionalPropertiesWithDescriptionOnly: + """Create an instance of AdditionalPropertiesWithDescriptionOnly from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return AdditionalPropertiesWithDescriptionOnly.parse_obj(obj) + + _obj = AdditionalPropertiesWithDescriptionOnly.parse_obj({ + "name": obj.get("name") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/all_of_with_single_ref.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/all_of_with_single_ref.py new file mode 100644 index 000000000000..34eada9a625f --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/all_of_with_single_ref.py @@ -0,0 +1,87 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, Field, StrictStr +from petstore_api.models.single_ref_type import SingleRefType + +class AllOfWithSingleRef(BaseModel): + """ + AllOfWithSingleRef + """ + username: Optional[StrictStr] = None + single_ref_type: Optional[SingleRefType] = Field(None, alias="SingleRefType") + additional_properties: Dict[str, Any] = {} + __properties = ["username", "SingleRefType"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> AllOfWithSingleRef: + """Create an instance of AllOfWithSingleRef from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> AllOfWithSingleRef: + """Create an instance of AllOfWithSingleRef from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return AllOfWithSingleRef.parse_obj(obj) + + _obj = AllOfWithSingleRef.parse_obj({ + "username": obj.get("username"), + "single_ref_type": obj.get("SingleRefType") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/animal.py new file mode 100644 index 000000000000..678dfe222968 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/animal.py @@ -0,0 +1,100 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional, Union +from pydantic import BaseModel, Field, StrictStr + +class Animal(BaseModel): + """ + Animal + """ + class_name: StrictStr = Field(..., alias="className") + color: Optional[StrictStr] = 'red' + additional_properties: Dict[str, Any] = {} + __properties = ["className", "color"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + # JSON field name that stores the object type + __discriminator_property_name = 'className' + + # discriminator mappings + __discriminator_value_class_map = { + 'Cat': 'Cat', + 'Dog': 'Dog' + } + + @classmethod + def get_discriminator_value(cls, obj: dict) -> str: + """Returns the discriminator value (object type) of the data""" + discriminator_value = obj[cls.__discriminator_property_name] + if discriminator_value: + return cls.__discriminator_value_class_map.get(discriminator_value) + else: + return None + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Union(Cat, Dog): + """Create an instance of Animal from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Union(Cat, Dog): + """Create an instance of Animal from a dict""" + # look up the object type based on discriminator mapping + object_type = cls.get_discriminator_value(obj) + if object_type: + klass = globals()[object_type] + return klass.from_dict(obj) + else: + raise ValueError("Animal failed to lookup discriminator value from " + + json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name + + ", mapping: " + json.dumps(cls.__discriminator_value_class_map)) + +from petstore_api.models.cat import Cat +from petstore_api.models.dog import Dog +Animal.update_forward_refs() + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/any_of_color.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/any_of_color.py new file mode 100644 index 000000000000..e178a110e51a --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/any_of_color.py @@ -0,0 +1,161 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +from inspect import getfullargspec +import json +import pprint +import re # noqa: F401 + +from typing import List, Optional +from pydantic import BaseModel, Field, StrictStr, ValidationError, conint, conlist, constr, validator +from typing import Union, Any, List, TYPE_CHECKING +try: + from typing import Literal +except ImportError: + from typing_extensions import Literal +from pydantic import StrictStr, Field + +ANYOFCOLOR_ANY_OF_SCHEMAS = ["List[int]", "str"] + +class AnyOfColor(BaseModel): + """ + Any of RGB array, RGBA array, or hex string. + """ + + # data type: List[int] + anyof_schema_1_validator: Optional[conlist(conint(strict=True, le=255, ge=0), max_length=3, min_length=3)] = Field(None, description="RGB three element array with values 0-255.") + # data type: List[int] + anyof_schema_2_validator: Optional[conlist(conint(strict=True, le=255, ge=0), max_length=4, min_length=4)] = Field(None, description="RGBA four element array with values 0-255.") + # data type: str + anyof_schema_3_validator: Optional[constr(strict=True, max_length=7, min_length=7)] = Field(None, description="Hex color string, such as #00FF00.") + if TYPE_CHECKING: + actual_instance: Union[List[int], str] + else: + actual_instance: Any + any_of_schemas: List[str] = Literal["List[int]", "str"] + + """Pydantic configuration""" + model_config = { + "validate_assignment": True, + } + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") + if kwargs: + raise ValueError("If a position argument is used, keyword arguments cannot be used.") + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @validator('actual_instance') + def actual_instance_must_validate_anyof(cls, v): + instance = AnyOfColor.construct() + error_messages = [] + # validate data type: List[int] + try: + instance.anyof_schema_1_validator = v + return v + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # validate data type: List[int] + try: + instance.anyof_schema_2_validator = v + return v + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # validate data type: str + try: + instance.anyof_schema_3_validator = v + return v + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + if error_messages: + # no match + raise ValueError("No match found when setting the actual_instance in AnyOfColor with anyOf schemas: List[int], str. Details: " + ", ".join(error_messages)) + else: + return v + + @classmethod + def from_dict(cls, obj: dict) -> AnyOfColor: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> AnyOfColor: + """Returns the object represented by the json string""" + instance = AnyOfColor.construct() + error_messages = [] + # deserialize data into List[int] + try: + # validation + instance.anyof_schema_1_validator = json.loads(json_str) + # assign value to actual_instance + instance.actual_instance = instance.anyof_schema_1_validator + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into List[int] + try: + # validation + instance.anyof_schema_2_validator = json.loads(json_str) + # assign value to actual_instance + instance.actual_instance = instance.anyof_schema_2_validator + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into str + try: + # validation + instance.anyof_schema_3_validator = json.loads(json_str) + # assign value to actual_instance + instance.actual_instance = instance.anyof_schema_3_validator + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if error_messages: + # no match + raise ValueError("No match found when deserializing the JSON string into AnyOfColor with anyOf schemas: List[int], str. Details: " + ", ".join(error_messages)) + else: + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + to_json = getattr(self.actual_instance, "to_json", None) + if callable(to_json): + return self.actual_instance.to_json() + else: + return json.dumps(self.actual_instance) + + def to_dict(self) -> dict: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return "null" + + to_json = getattr(self.actual_instance, "to_json", None) + if callable(to_json): + return self.actual_instance.to_dict() + else: + return json.dumps(self.actual_instance) + + def to_str(self) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.dict()) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/any_of_pig.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/any_of_pig.py new file mode 100644 index 000000000000..1f5c819e7dfd --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/any_of_pig.py @@ -0,0 +1,140 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +from inspect import getfullargspec +import json +import pprint +import re # noqa: F401 + +from typing import Optional +from pydantic import BaseModel, Field, StrictStr, ValidationError, validator +from petstore_api.models.basque_pig import BasquePig +from petstore_api.models.danish_pig import DanishPig +from typing import Union, Any, List, TYPE_CHECKING +try: + from typing import Literal +except ImportError: + from typing_extensions import Literal +from pydantic import StrictStr, Field + +ANYOFPIG_ANY_OF_SCHEMAS = ["BasquePig", "DanishPig"] + +class AnyOfPig(BaseModel): + """ + AnyOfPig + """ + + # data type: BasquePig + anyof_schema_1_validator: Optional[BasquePig] = None + # data type: DanishPig + anyof_schema_2_validator: Optional[DanishPig] = None + if TYPE_CHECKING: + actual_instance: Union[BasquePig, DanishPig] + else: + actual_instance: Any + any_of_schemas: List[str] = Literal["BasquePig", "DanishPig"] + + """Pydantic configuration""" + model_config = { + "validate_assignment": True, + } + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") + if kwargs: + raise ValueError("If a position argument is used, keyword arguments cannot be used.") + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @validator('actual_instance') + def actual_instance_must_validate_anyof(cls, v): + instance = AnyOfPig.construct() + error_messages = [] + # validate data type: BasquePig + if not isinstance(v, BasquePig): + error_messages.append(f"Error! Input type `{type(v)}` is not `BasquePig`") + else: + return v + + # validate data type: DanishPig + if not isinstance(v, DanishPig): + error_messages.append(f"Error! Input type `{type(v)}` is not `DanishPig`") + else: + return v + + if error_messages: + # no match + raise ValueError("No match found when setting the actual_instance in AnyOfPig with anyOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) + else: + return v + + @classmethod + def from_dict(cls, obj: dict) -> AnyOfPig: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> AnyOfPig: + """Returns the object represented by the json string""" + instance = AnyOfPig.construct() + error_messages = [] + # anyof_schema_1_validator: Optional[BasquePig] = None + try: + instance.actual_instance = BasquePig.from_json(json_str) + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # anyof_schema_2_validator: Optional[DanishPig] = None + try: + instance.actual_instance = DanishPig.from_json(json_str) + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if error_messages: + # no match + raise ValueError("No match found when deserializing the JSON string into AnyOfPig with anyOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) + else: + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + to_json = getattr(self.actual_instance, "to_json", None) + if callable(to_json): + return self.actual_instance.to_json() + else: + return json.dumps(self.actual_instance) + + def to_dict(self) -> dict: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return "null" + + to_json = getattr(self.actual_instance, "to_json", None) + if callable(to_json): + return self.actual_instance.to_dict() + else: + return json.dumps(self.actual_instance) + + def to_str(self) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.dict()) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/api_response.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/api_response.py new file mode 100644 index 000000000000..3c176c73e294 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/api_response.py @@ -0,0 +1,88 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, StrictInt, StrictStr + +class ApiResponse(BaseModel): + """ + ApiResponse + """ + code: Optional[StrictInt] = None + type: Optional[StrictStr] = None + message: Optional[StrictStr] = None + additional_properties: Dict[str, Any] = {} + __properties = ["code", "type", "message"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> ApiResponse: + """Create an instance of ApiResponse from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> ApiResponse: + """Create an instance of ApiResponse from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return ApiResponse.parse_obj(obj) + + _obj = ApiResponse.parse_obj({ + "code": obj.get("code"), + "type": obj.get("type"), + "message": obj.get("message") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/array_of_array_of_model.py new file mode 100644 index 000000000000..1b6c9a6e1338 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/array_of_array_of_model.py @@ -0,0 +1,97 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, List, Optional +from pydantic import BaseModel, conlist +from petstore_api.models.tag import Tag + +class ArrayOfArrayOfModel(BaseModel): + """ + ArrayOfArrayOfModel + """ + another_property: Optional[conlist(conlist(Tag))] = None + additional_properties: Dict[str, Any] = {} + __properties = ["another_property"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> ArrayOfArrayOfModel: + """Create an instance of ArrayOfArrayOfModel from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of each item in another_property (list of list) + _items = [] + if self.another_property: + for _item in self.another_property: + if _item: + _items.append( + [_inner_item.to_dict() for _inner_item in _item if _inner_item is not None] + ) + _dict['another_property'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> ArrayOfArrayOfModel: + """Create an instance of ArrayOfArrayOfModel from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return ArrayOfArrayOfModel.parse_obj(obj) + + _obj = ArrayOfArrayOfModel.parse_obj({ + "another_property": [ + [Tag.from_dict(_inner_item) for _inner_item in _item] + for _item in obj.get("another_property") + ] if obj.get("another_property") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/array_of_array_of_number_only.py new file mode 100644 index 000000000000..8e908b531f5c --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/array_of_array_of_number_only.py @@ -0,0 +1,84 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, List, Optional +from pydantic import BaseModel, Field, StrictFloat, conlist + +class ArrayOfArrayOfNumberOnly(BaseModel): + """ + ArrayOfArrayOfNumberOnly + """ + array_array_number: Optional[conlist(conlist(StrictFloat))] = Field(None, alias="ArrayArrayNumber") + additional_properties: Dict[str, Any] = {} + __properties = ["ArrayArrayNumber"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> ArrayOfArrayOfNumberOnly: + """Create an instance of ArrayOfArrayOfNumberOnly from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> ArrayOfArrayOfNumberOnly: + """Create an instance of ArrayOfArrayOfNumberOnly from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return ArrayOfArrayOfNumberOnly.parse_obj(obj) + + _obj = ArrayOfArrayOfNumberOnly.parse_obj({ + "array_array_number": obj.get("ArrayArrayNumber") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/array_of_number_only.py new file mode 100644 index 000000000000..cf4fa2f1039e --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/array_of_number_only.py @@ -0,0 +1,84 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, List, Optional +from pydantic import BaseModel, Field, StrictFloat, conlist + +class ArrayOfNumberOnly(BaseModel): + """ + ArrayOfNumberOnly + """ + array_number: Optional[conlist(StrictFloat)] = Field(None, alias="ArrayNumber") + additional_properties: Dict[str, Any] = {} + __properties = ["ArrayNumber"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> ArrayOfNumberOnly: + """Create an instance of ArrayOfNumberOnly from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> ArrayOfNumberOnly: + """Create an instance of ArrayOfNumberOnly from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return ArrayOfNumberOnly.parse_obj(obj) + + _obj = ArrayOfNumberOnly.parse_obj({ + "array_number": obj.get("ArrayNumber") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/array_test.py new file mode 100644 index 000000000000..ba695c59d32a --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/array_test.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, List, Optional +from pydantic import BaseModel, StrictInt, StrictStr, conlist +from petstore_api.models.read_only_first import ReadOnlyFirst + +class ArrayTest(BaseModel): + """ + ArrayTest + """ + array_of_string: Optional[conlist(StrictStr, max_length=3, min_length=0)] = None + array_array_of_integer: Optional[conlist(conlist(StrictInt))] = None + array_array_of_model: Optional[conlist(conlist(ReadOnlyFirst))] = None + additional_properties: Dict[str, Any] = {} + __properties = ["array_of_string", "array_array_of_integer", "array_array_of_model"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> ArrayTest: + """Create an instance of ArrayTest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of each item in array_array_of_model (list of list) + _items = [] + if self.array_array_of_model: + for _item in self.array_array_of_model: + if _item: + _items.append( + [_inner_item.to_dict() for _inner_item in _item if _inner_item is not None] + ) + _dict['array_array_of_model'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> ArrayTest: + """Create an instance of ArrayTest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return ArrayTest.parse_obj(obj) + + _obj = ArrayTest.parse_obj({ + "array_of_string": obj.get("array_of_string"), + "array_array_of_integer": obj.get("array_array_of_integer"), + "array_array_of_model": [ + [ReadOnlyFirst.from_dict(_inner_item) for _inner_item in _item] + for _item in obj.get("array_array_of_model") + ] if obj.get("array_array_of_model") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/basque_pig.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/basque_pig.py new file mode 100644 index 000000000000..4738611803df --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/basque_pig.py @@ -0,0 +1,86 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict +from pydantic import BaseModel, Field, StrictStr + +class BasquePig(BaseModel): + """ + BasquePig + """ + class_name: StrictStr = Field(..., alias="className") + color: StrictStr = Field(...) + additional_properties: Dict[str, Any] = {} + __properties = ["className", "color"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> BasquePig: + """Create an instance of BasquePig from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> BasquePig: + """Create an instance of BasquePig from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return BasquePig.parse_obj(obj) + + _obj = BasquePig.parse_obj({ + "class_name": obj.get("className"), + "color": obj.get("color") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/capitalization.py new file mode 100644 index 000000000000..0b5393374277 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/capitalization.py @@ -0,0 +1,94 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, Field, StrictStr + +class Capitalization(BaseModel): + """ + Capitalization + """ + small_camel: Optional[StrictStr] = Field(None, alias="smallCamel") + capital_camel: Optional[StrictStr] = Field(None, alias="CapitalCamel") + small_snake: Optional[StrictStr] = Field(None, alias="small_Snake") + capital_snake: Optional[StrictStr] = Field(None, alias="Capital_Snake") + sca_eth_flow_points: Optional[StrictStr] = Field(None, alias="SCA_ETH_Flow_Points") + att_name: Optional[StrictStr] = Field(None, alias="ATT_NAME", description="Name of the pet ") + additional_properties: Dict[str, Any] = {} + __properties = ["smallCamel", "CapitalCamel", "small_Snake", "Capital_Snake", "SCA_ETH_Flow_Points", "ATT_NAME"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Capitalization: + """Create an instance of Capitalization from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Capitalization: + """Create an instance of Capitalization from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Capitalization.parse_obj(obj) + + _obj = Capitalization.parse_obj({ + "small_camel": obj.get("smallCamel"), + "capital_camel": obj.get("CapitalCamel"), + "small_snake": obj.get("small_Snake"), + "capital_snake": obj.get("Capital_Snake"), + "sca_eth_flow_points": obj.get("SCA_ETH_Flow_Points"), + "att_name": obj.get("ATT_NAME") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/cat.py new file mode 100644 index 000000000000..01bf3dea821b --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/cat.py @@ -0,0 +1,87 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import StrictBool +from petstore_api.models.animal import Animal + +class Cat(Animal): + """ + Cat + """ + declawed: Optional[StrictBool] = None + additional_properties: Dict[str, Any] = {} + __properties = ["className", "color", "declawed"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Cat: + """Create an instance of Cat from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Cat: + """Create an instance of Cat from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Cat.parse_obj(obj) + + _obj = Cat.parse_obj({ + "class_name": obj.get("className"), + "color": obj.get("color") if obj.get("color") is not None else 'red', + "declawed": obj.get("declawed") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/category.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/category.py new file mode 100644 index 000000000000..a8f297a19c64 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/category.py @@ -0,0 +1,86 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, Field, StrictInt, StrictStr + +class Category(BaseModel): + """ + Category + """ + id: Optional[StrictInt] = None + name: StrictStr = Field(...) + additional_properties: Dict[str, Any] = {} + __properties = ["id", "name"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Category: + """Create an instance of Category from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Category: + """Create an instance of Category from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Category.parse_obj(obj) + + _obj = Category.parse_obj({ + "id": obj.get("id"), + "name": obj.get("name") if obj.get("name") is not None else 'default-name' + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/circular_reference_model.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/circular_reference_model.py new file mode 100644 index 000000000000..9a3c62cfbe72 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/circular_reference_model.py @@ -0,0 +1,91 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, StrictInt + +class CircularReferenceModel(BaseModel): + """ + CircularReferenceModel + """ + size: Optional[StrictInt] = None + nested: Optional[FirstRef] = None + additional_properties: Dict[str, Any] = {} + __properties = ["size", "nested"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> CircularReferenceModel: + """Create an instance of CircularReferenceModel from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of nested + if self.nested: + _dict['nested'] = self.nested.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> CircularReferenceModel: + """Create an instance of CircularReferenceModel from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return CircularReferenceModel.parse_obj(obj) + + _obj = CircularReferenceModel.parse_obj({ + "size": obj.get("size"), + "nested": FirstRef.from_dict(obj.get("nested")) if obj.get("nested") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + +from petstore_api.models.first_ref import FirstRef +CircularReferenceModel.update_forward_refs() + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/class_model.py new file mode 100644 index 000000000000..34e526e1641b --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/class_model.py @@ -0,0 +1,84 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, Field, StrictStr + +class ClassModel(BaseModel): + """ + Model for testing model with \"_class\" property # noqa: E501 + """ + var_class: Optional[StrictStr] = Field(None, alias="_class") + additional_properties: Dict[str, Any] = {} + __properties = ["_class"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> ClassModel: + """Create an instance of ClassModel from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> ClassModel: + """Create an instance of ClassModel from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return ClassModel.parse_obj(obj) + + _obj = ClassModel.parse_obj({ + "var_class": obj.get("_class") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/client.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/client.py new file mode 100644 index 000000000000..dfc21947aa42 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/client.py @@ -0,0 +1,84 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, StrictStr + +class Client(BaseModel): + """ + Client + """ + client: Optional[StrictStr] = None + additional_properties: Dict[str, Any] = {} + __properties = ["client"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Client: + """Create an instance of Client from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Client: + """Create an instance of Client from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Client.parse_obj(obj) + + _obj = Client.parse_obj({ + "client": obj.get("client") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/color.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/color.py new file mode 100644 index 000000000000..a05243df89ee --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/color.py @@ -0,0 +1,177 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +from inspect import getfullargspec +import json +import pprint +import re # noqa: F401 + +from typing import Any, List, Optional +from pydantic import BaseModel, Field, StrictStr, ValidationError, conint, conlist, constr, validator +from typing import Union, Any, List, TYPE_CHECKING +try: + from typing import Literal +except ImportError: + from typing_extensions import Literal +from pydantic import StrictStr, Field + +COLOR_ONE_OF_SCHEMAS = ["List[int]", "str"] + +class Color(BaseModel): + """ + RGB array, RGBA array, or hex string. + """ + # data type: List[int] + oneof_schema_1_validator: Optional[conlist(conint(strict=True, le=255, ge=0), max_length=3, min_length=3)] = Field(None, description="RGB three element array with values 0-255.") + # data type: List[int] + oneof_schema_2_validator: Optional[conlist(conint(strict=True, le=255, ge=0), max_length=4, min_length=4)] = Field(None, description="RGBA four element array with values 0-255.") + # data type: str + oneof_schema_3_validator: Optional[constr(strict=True, max_length=7, min_length=7)] = Field(None, description="Hex color string, such as #00FF00.") + if TYPE_CHECKING: + actual_instance: Union[List[int], str] + else: + actual_instance: Any + + one_of_schemas: List[str] = Literal["List[int]", "str"] + + """Pydantic configuration""" + model_config = { + "validate_assignment": True, + } + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") + if kwargs: + raise ValueError("If a position argument is used, keyword arguments cannot be used.") + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @validator('actual_instance') + def actual_instance_must_validate_oneof(cls, v): + if v is None: + return v + + instance = Color.construct() + error_messages = [] + match = 0 + # validate data type: List[int] + try: + instance.oneof_schema_1_validator = v + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # validate data type: List[int] + try: + instance.oneof_schema_2_validator = v + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # validate data type: str + try: + instance.oneof_schema_3_validator = v + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + if match > 1: + # more than 1 match + raise ValueError("Multiple matches found when setting `actual_instance` in Color with oneOf schemas: List[int], str. Details: " + ", ".join(error_messages)) + elif match == 0: + # no match + raise ValueError("No match found when setting `actual_instance` in Color with oneOf schemas: List[int], str. Details: " + ", ".join(error_messages)) + else: + return v + + @classmethod + def from_dict(cls, obj: dict) -> Color: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> Color: + """Returns the object represented by the json string""" + instance = Color.construct() + if json_str is None: + return instance + + error_messages = [] + match = 0 + + # deserialize data into List[int] + try: + # validation + instance.oneof_schema_1_validator = json.loads(json_str) + # assign value to actual_instance + instance.actual_instance = instance.oneof_schema_1_validator + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into List[int] + try: + # validation + instance.oneof_schema_2_validator = json.loads(json_str) + # assign value to actual_instance + instance.actual_instance = instance.oneof_schema_2_validator + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into str + try: + # validation + instance.oneof_schema_3_validator = json.loads(json_str) + # assign value to actual_instance + instance.actual_instance = instance.oneof_schema_3_validator + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if match > 1: + # more than 1 match + raise ValueError("Multiple matches found when deserializing the JSON string into Color with oneOf schemas: List[int], str. Details: " + ", ".join(error_messages)) + elif match == 0: + # no match + raise ValueError("No match found when deserializing the JSON string into Color with oneOf schemas: List[int], str. Details: " + ", ".join(error_messages)) + else: + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + to_json = getattr(self.actual_instance, "to_json", None) + if callable(to_json): + return self.actual_instance.to_json() + else: + return json.dumps(self.actual_instance) + + def to_dict(self) -> dict: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + to_dict = getattr(self.actual_instance, "to_dict", None) + if callable(to_dict): + return self.actual_instance.to_dict() + else: + # primitive type + return self.actual_instance + + def to_str(self) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.dict()) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/creature.py new file mode 100644 index 000000000000..89f8d3a162c8 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/creature.py @@ -0,0 +1,90 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict +from pydantic import BaseModel, Field, StrictStr +from petstore_api.models.creature_info import CreatureInfo + +class Creature(BaseModel): + """ + Creature + """ + info: CreatureInfo = Field(...) + type: StrictStr = Field(...) + additional_properties: Dict[str, Any] = {} + __properties = ["info", "type"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Creature: + """Create an instance of Creature from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of info + if self.info: + _dict['info'] = self.info.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Creature: + """Create an instance of Creature from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Creature.parse_obj(obj) + + _obj = Creature.parse_obj({ + "info": CreatureInfo.from_dict(obj.get("info")) if obj.get("info") is not None else None, + "type": obj.get("type") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/creature_info.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/creature_info.py new file mode 100644 index 000000000000..1ff7145528d6 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/creature_info.py @@ -0,0 +1,84 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict +from pydantic import BaseModel, Field, StrictStr + +class CreatureInfo(BaseModel): + """ + CreatureInfo + """ + name: StrictStr = Field(...) + additional_properties: Dict[str, Any] = {} + __properties = ["name"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> CreatureInfo: + """Create an instance of CreatureInfo from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> CreatureInfo: + """Create an instance of CreatureInfo from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return CreatureInfo.parse_obj(obj) + + _obj = CreatureInfo.parse_obj({ + "name": obj.get("name") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/danish_pig.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/danish_pig.py new file mode 100644 index 000000000000..4fec4f6fb8a2 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/danish_pig.py @@ -0,0 +1,86 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict +from pydantic import BaseModel, Field, StrictInt, StrictStr + +class DanishPig(BaseModel): + """ + DanishPig + """ + class_name: StrictStr = Field(..., alias="className") + size: StrictInt = Field(...) + additional_properties: Dict[str, Any] = {} + __properties = ["className", "size"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> DanishPig: + """Create an instance of DanishPig from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> DanishPig: + """Create an instance of DanishPig from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return DanishPig.parse_obj(obj) + + _obj = DanishPig.parse_obj({ + "class_name": obj.get("className"), + "size": obj.get("size") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/deprecated_object.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/deprecated_object.py new file mode 100644 index 000000000000..ea1d52b15ccd --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/deprecated_object.py @@ -0,0 +1,84 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, StrictStr + +class DeprecatedObject(BaseModel): + """ + DeprecatedObject + """ + name: Optional[StrictStr] = None + additional_properties: Dict[str, Any] = {} + __properties = ["name"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> DeprecatedObject: + """Create an instance of DeprecatedObject from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> DeprecatedObject: + """Create an instance of DeprecatedObject from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return DeprecatedObject.parse_obj(obj) + + _obj = DeprecatedObject.parse_obj({ + "name": obj.get("name") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/dog.py new file mode 100644 index 000000000000..28bab5868275 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/dog.py @@ -0,0 +1,87 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import StrictStr +from petstore_api.models.animal import Animal + +class Dog(Animal): + """ + Dog + """ + breed: Optional[StrictStr] = None + additional_properties: Dict[str, Any] = {} + __properties = ["className", "color", "breed"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Dog: + """Create an instance of Dog from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Dog: + """Create an instance of Dog from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Dog.parse_obj(obj) + + _obj = Dog.parse_obj({ + "class_name": obj.get("className"), + "color": obj.get("color") if obj.get("color") is not None else 'red', + "breed": obj.get("breed") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/dummy_model.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/dummy_model.py new file mode 100644 index 000000000000..6085e77308fa --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/dummy_model.py @@ -0,0 +1,91 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, StrictStr + +class DummyModel(BaseModel): + """ + DummyModel + """ + category: Optional[StrictStr] = None + self_ref: Optional[SelfReferenceModel] = None + additional_properties: Dict[str, Any] = {} + __properties = ["category", "self_ref"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> DummyModel: + """Create an instance of DummyModel from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of self_ref + if self.self_ref: + _dict['self_ref'] = self.self_ref.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> DummyModel: + """Create an instance of DummyModel from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return DummyModel.parse_obj(obj) + + _obj = DummyModel.parse_obj({ + "category": obj.get("category"), + "self_ref": SelfReferenceModel.from_dict(obj.get("self_ref")) if obj.get("self_ref") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + +from petstore_api.models.self_reference_model import SelfReferenceModel +DummyModel.update_forward_refs() + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/enum_arrays.py new file mode 100644 index 000000000000..cae2015f7777 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/enum_arrays.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, List, Optional +from pydantic import BaseModel, StrictStr, conlist, validator + +class EnumArrays(BaseModel): + """ + EnumArrays + """ + just_symbol: Optional[StrictStr] = None + array_enum: Optional[conlist(StrictStr)] = None + additional_properties: Dict[str, Any] = {} + __properties = ["just_symbol", "array_enum"] + + @validator('just_symbol') + def just_symbol_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in ('>=', '$'): + raise ValueError("must be one of enum values ('>=', '$')") + return value + + @validator('array_enum') + def array_enum_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + for i in value: + if i not in ('fish', 'crab'): + raise ValueError("each list item must be one of ('fish', 'crab')") + return value + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> EnumArrays: + """Create an instance of EnumArrays from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> EnumArrays: + """Create an instance of EnumArrays from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return EnumArrays.parse_obj(obj) + + _obj = EnumArrays.parse_obj({ + "just_symbol": obj.get("just_symbol"), + "array_enum": obj.get("array_enum") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/enum_class.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/enum_class.py new file mode 100644 index 000000000000..f3037885ed67 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/enum_class.py @@ -0,0 +1,41 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import pprint +import re # noqa: F401 +from aenum import Enum, no_arg + + + + + +class EnumClass(str, Enum): + """ + EnumClass + """ + + """ + allowed enum values + """ + ABC = '_abc' + MINUS_EFG = '-efg' + LEFT_PARENTHESIS_XYZ_RIGHT_PARENTHESIS = '(xyz)' + + @classmethod + def from_json(cls, json_str: str) -> EnumClass: + """Create an instance of EnumClass from a JSON string""" + return EnumClass(json.loads(json_str)) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/enum_string1.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/enum_string1.py new file mode 100644 index 000000000000..8ced7d15629a --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/enum_string1.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import pprint +import re # noqa: F401 +from aenum import Enum, no_arg + + + + + +class EnumString1(str, Enum): + """ + EnumString1 + """ + + """ + allowed enum values + """ + A = 'a' + B = 'b' + + @classmethod + def from_json(cls, json_str: str) -> EnumString1: + """Create an instance of EnumString1 from a JSON string""" + return EnumString1(json.loads(json_str)) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/enum_string2.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/enum_string2.py new file mode 100644 index 000000000000..1ee338109101 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/enum_string2.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import pprint +import re # noqa: F401 +from aenum import Enum, no_arg + + + + + +class EnumString2(str, Enum): + """ + EnumString2 + """ + + """ + allowed enum values + """ + C = 'c' + D = 'd' + + @classmethod + def from_json(cls, json_str: str) -> EnumString2: + """Create an instance of EnumString2 from a JSON string""" + return EnumString2(json.loads(json_str)) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/enum_test.py new file mode 100644 index 000000000000..a0226d95eed3 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/enum_test.py @@ -0,0 +1,156 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, Field, StrictFloat, StrictInt, StrictStr, validator +from petstore_api.models.outer_enum import OuterEnum +from petstore_api.models.outer_enum_default_value import OuterEnumDefaultValue +from petstore_api.models.outer_enum_integer import OuterEnumInteger +from petstore_api.models.outer_enum_integer_default_value import OuterEnumIntegerDefaultValue + +class EnumTest(BaseModel): + """ + EnumTest + """ + enum_string: Optional[StrictStr] = None + enum_string_required: StrictStr = Field(...) + enum_integer_default: Optional[StrictInt] = 5 + enum_integer: Optional[StrictInt] = None + enum_number: Optional[StrictFloat] = None + outer_enum: Optional[OuterEnum] = Field(None, alias="outerEnum") + outer_enum_integer: Optional[OuterEnumInteger] = Field(None, alias="outerEnumInteger") + outer_enum_default_value: Optional[OuterEnumDefaultValue] = Field(None, alias="outerEnumDefaultValue") + outer_enum_integer_default_value: Optional[OuterEnumIntegerDefaultValue] = Field(None, alias="outerEnumIntegerDefaultValue") + additional_properties: Dict[str, Any] = {} + __properties = ["enum_string", "enum_string_required", "enum_integer_default", "enum_integer", "enum_number", "outerEnum", "outerEnumInteger", "outerEnumDefaultValue", "outerEnumIntegerDefaultValue"] + + @validator('enum_string') + def enum_string_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in ('UPPER', 'lower', ''): + raise ValueError("must be one of enum values ('UPPER', 'lower', '')") + return value + + @validator('enum_string_required') + def enum_string_required_validate_enum(cls, value): + """Validates the enum""" + if value not in ('UPPER', 'lower', ''): + raise ValueError("must be one of enum values ('UPPER', 'lower', '')") + return value + + @validator('enum_integer_default') + def enum_integer_default_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in (1, 5, 14): + raise ValueError("must be one of enum values (1, 5, 14)") + return value + + @validator('enum_integer') + def enum_integer_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in (1, -1): + raise ValueError("must be one of enum values (1, -1)") + return value + + @validator('enum_number') + def enum_number_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in (1.1, -1.2): + raise ValueError("must be one of enum values (1.1, -1.2)") + return value + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> EnumTest: + """Create an instance of EnumTest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + # set to None if outer_enum (nullable) is None + # and __fields_set__ contains the field + if self.outer_enum is None and "outer_enum" in self.__fields_set__: + _dict['outerEnum'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> EnumTest: + """Create an instance of EnumTest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return EnumTest.parse_obj(obj) + + _obj = EnumTest.parse_obj({ + "enum_string": obj.get("enum_string"), + "enum_string_required": obj.get("enum_string_required"), + "enum_integer_default": obj.get("enum_integer_default") if obj.get("enum_integer_default") is not None else 5, + "enum_integer": obj.get("enum_integer"), + "enum_number": obj.get("enum_number"), + "outer_enum": obj.get("outerEnum"), + "outer_enum_integer": obj.get("outerEnumInteger"), + "outer_enum_default_value": obj.get("outerEnumDefaultValue"), + "outer_enum_integer_default_value": obj.get("outerEnumIntegerDefaultValue") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/file.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/file.py new file mode 100644 index 000000000000..6702d83e6209 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/file.py @@ -0,0 +1,84 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, Field, StrictStr + +class File(BaseModel): + """ + Must be named `File` for test. # noqa: E501 + """ + source_uri: Optional[StrictStr] = Field(None, alias="sourceURI", description="Test capitalization") + additional_properties: Dict[str, Any] = {} + __properties = ["sourceURI"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> File: + """Create an instance of File from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> File: + """Create an instance of File from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return File.parse_obj(obj) + + _obj = File.parse_obj({ + "source_uri": obj.get("sourceURI") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/file_schema_test_class.py new file mode 100644 index 000000000000..86f565ac5e5f --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/file_schema_test_class.py @@ -0,0 +1,97 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, List, Optional +from pydantic import BaseModel, conlist +from petstore_api.models.file import File + +class FileSchemaTestClass(BaseModel): + """ + FileSchemaTestClass + """ + file: Optional[File] = None + files: Optional[conlist(File)] = None + additional_properties: Dict[str, Any] = {} + __properties = ["file", "files"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> FileSchemaTestClass: + """Create an instance of FileSchemaTestClass from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of file + if self.file: + _dict['file'] = self.file.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in files (list) + _items = [] + if self.files: + for _item in self.files: + if _item: + _items.append(_item.to_dict()) + _dict['files'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> FileSchemaTestClass: + """Create an instance of FileSchemaTestClass from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return FileSchemaTestClass.parse_obj(obj) + + _obj = FileSchemaTestClass.parse_obj({ + "file": File.from_dict(obj.get("file")) if obj.get("file") is not None else None, + "files": [File.from_dict(_item) for _item in obj.get("files")] if obj.get("files") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/first_ref.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/first_ref.py new file mode 100644 index 000000000000..3edf4c14bfaf --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/first_ref.py @@ -0,0 +1,91 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, StrictStr + +class FirstRef(BaseModel): + """ + FirstRef + """ + category: Optional[StrictStr] = None + self_ref: Optional[SecondRef] = None + additional_properties: Dict[str, Any] = {} + __properties = ["category", "self_ref"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> FirstRef: + """Create an instance of FirstRef from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of self_ref + if self.self_ref: + _dict['self_ref'] = self.self_ref.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> FirstRef: + """Create an instance of FirstRef from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return FirstRef.parse_obj(obj) + + _obj = FirstRef.parse_obj({ + "category": obj.get("category"), + "self_ref": SecondRef.from_dict(obj.get("self_ref")) if obj.get("self_ref") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + +from petstore_api.models.second_ref import SecondRef +FirstRef.update_forward_refs() + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/foo.py new file mode 100644 index 000000000000..b607b20b493a --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/foo.py @@ -0,0 +1,84 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, StrictStr + +class Foo(BaseModel): + """ + Foo + """ + bar: Optional[StrictStr] = 'bar' + additional_properties: Dict[str, Any] = {} + __properties = ["bar"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Foo: + """Create an instance of Foo from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Foo: + """Create an instance of Foo from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Foo.parse_obj(obj) + + _obj = Foo.parse_obj({ + "bar": obj.get("bar") if obj.get("bar") is not None else 'bar' + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/foo_get_default_response.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/foo_get_default_response.py new file mode 100644 index 000000000000..4814aa51bad5 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/foo_get_default_response.py @@ -0,0 +1,88 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel +from petstore_api.models.foo import Foo + +class FooGetDefaultResponse(BaseModel): + """ + FooGetDefaultResponse + """ + string: Optional[Foo] = None + additional_properties: Dict[str, Any] = {} + __properties = ["string"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> FooGetDefaultResponse: + """Create an instance of FooGetDefaultResponse from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of string + if self.string: + _dict['string'] = self.string.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> FooGetDefaultResponse: + """Create an instance of FooGetDefaultResponse from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return FooGetDefaultResponse.parse_obj(obj) + + _obj = FooGetDefaultResponse.parse_obj({ + "string": Foo.from_dict(obj.get("string")) if obj.get("string") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/format_test.py new file mode 100644 index 000000000000..a456b64abc7e --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/format_test.py @@ -0,0 +1,156 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from datetime import date, datetime +from typing import Any, Dict, Optional, Union +from pydantic import BaseModel, Field, StrictBytes, StrictInt, StrictStr, condecimal, confloat, conint, constr, validator + +class FormatTest(BaseModel): + """ + FormatTest + """ + integer: Optional[conint(strict=True, le=100, ge=10)] = None + int32: Optional[conint(strict=True, le=200, ge=20)] = None + int64: Optional[StrictInt] = None + number: confloat(le=543.2, ge=32.1, strict=True) = Field(...) + float: Optional[confloat(le=987.6, ge=54.3, strict=True)] = None + double: Optional[confloat(le=123.4, ge=67.8, strict=True)] = None + decimal: Optional[condecimal()] = None + string: Optional[constr(strict=True)] = None + string_with_double_quote_pattern: Optional[constr(strict=True)] = None + byte: Optional[Union[StrictBytes, StrictStr]] = None + binary: Optional[Union[StrictBytes, StrictStr]] = None + var_date: date = Field(..., alias="date") + date_time: Optional[datetime] = Field(None, alias="dateTime") + uuid: Optional[StrictStr] = None + password: constr(strict=True, max_length=64, min_length=10) = Field(...) + pattern_with_digits: Optional[constr(strict=True)] = Field(None, description="A string that is a 10 digit number. Can have leading zeros.") + pattern_with_digits_and_delimiter: Optional[constr(strict=True)] = Field(None, description="A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.") + additional_properties: Dict[str, Any] = {} + __properties = ["integer", "int32", "int64", "number", "float", "double", "decimal", "string", "string_with_double_quote_pattern", "byte", "binary", "date", "dateTime", "uuid", "password", "pattern_with_digits", "pattern_with_digits_and_delimiter"] + + @validator('string') + def string_validate_regular_expression(cls, value): + """Validates the regular expression""" + if value is None: + return value + + if not re.match(r"[a-z]", value ,re.IGNORECASE): + raise ValueError(r"must validate the regular expression /[a-z]/i") + return value + + @validator('string_with_double_quote_pattern') + def string_with_double_quote_pattern_validate_regular_expression(cls, value): + """Validates the regular expression""" + if value is None: + return value + + if not re.match(r"this is \"something\"", value): + raise ValueError(r"must validate the regular expression /this is \"something\"/") + return value + + @validator('pattern_with_digits') + def pattern_with_digits_validate_regular_expression(cls, value): + """Validates the regular expression""" + if value is None: + return value + + if not re.match(r"^\d{10}$", value): + raise ValueError(r"must validate the regular expression /^\d{10}$/") + return value + + @validator('pattern_with_digits_and_delimiter') + def pattern_with_digits_and_delimiter_validate_regular_expression(cls, value): + """Validates the regular expression""" + if value is None: + return value + + if not re.match(r"^image_\d{1,3}$", value ,re.IGNORECASE): + raise ValueError(r"must validate the regular expression /^image_\d{1,3}$/i") + return value + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> FormatTest: + """Create an instance of FormatTest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> FormatTest: + """Create an instance of FormatTest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return FormatTest.parse_obj(obj) + + _obj = FormatTest.parse_obj({ + "integer": obj.get("integer"), + "int32": obj.get("int32"), + "int64": obj.get("int64"), + "number": obj.get("number"), + "float": obj.get("float"), + "double": obj.get("double"), + "decimal": obj.get("decimal"), + "string": obj.get("string"), + "string_with_double_quote_pattern": obj.get("string_with_double_quote_pattern"), + "byte": obj.get("byte"), + "binary": obj.get("binary"), + "var_date": obj.get("date"), + "date_time": obj.get("dateTime"), + "uuid": obj.get("uuid"), + "password": obj.get("password"), + "pattern_with_digits": obj.get("pattern_with_digits"), + "pattern_with_digits_and_delimiter": obj.get("pattern_with_digits_and_delimiter") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/has_only_read_only.py new file mode 100644 index 000000000000..1b0116b2bbb5 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/has_only_read_only.py @@ -0,0 +1,88 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, StrictStr + +class HasOnlyReadOnly(BaseModel): + """ + HasOnlyReadOnly + """ + bar: Optional[StrictStr] = None + foo: Optional[StrictStr] = None + additional_properties: Dict[str, Any] = {} + __properties = ["bar", "foo"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> HasOnlyReadOnly: + """Create an instance of HasOnlyReadOnly from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "bar", + "foo", + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> HasOnlyReadOnly: + """Create an instance of HasOnlyReadOnly from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return HasOnlyReadOnly.parse_obj(obj) + + _obj = HasOnlyReadOnly.parse_obj({ + "bar": obj.get("bar"), + "foo": obj.get("foo") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/health_check_result.py new file mode 100644 index 000000000000..0beb041f523a --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/health_check_result.py @@ -0,0 +1,89 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, Field, StrictStr + +class HealthCheckResult(BaseModel): + """ + Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. # noqa: E501 + """ + nullable_message: Optional[StrictStr] = Field(None, alias="NullableMessage") + additional_properties: Dict[str, Any] = {} + __properties = ["NullableMessage"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> HealthCheckResult: + """Create an instance of HealthCheckResult from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + # set to None if nullable_message (nullable) is None + # and __fields_set__ contains the field + if self.nullable_message is None and "nullable_message" in self.__fields_set__: + _dict['NullableMessage'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> HealthCheckResult: + """Create an instance of HealthCheckResult from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return HealthCheckResult.parse_obj(obj) + + _obj = HealthCheckResult.parse_obj({ + "nullable_message": obj.get("NullableMessage") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/inner_dict_with_property.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/inner_dict_with_property.py new file mode 100644 index 000000000000..053eb4c2a5da --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/inner_dict_with_property.py @@ -0,0 +1,84 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, Field + +class InnerDictWithProperty(BaseModel): + """ + InnerDictWithProperty + """ + a_property: Optional[Dict[str, Any]] = Field(None, alias="aProperty") + additional_properties: Dict[str, Any] = {} + __properties = ["aProperty"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> InnerDictWithProperty: + """Create an instance of InnerDictWithProperty from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> InnerDictWithProperty: + """Create an instance of InnerDictWithProperty from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return InnerDictWithProperty.parse_obj(obj) + + _obj = InnerDictWithProperty.parse_obj({ + "a_property": obj.get("aProperty") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/int_or_string.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/int_or_string.py new file mode 100644 index 000000000000..e3420c4ae071 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/int_or_string.py @@ -0,0 +1,154 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +from inspect import getfullargspec +import json +import pprint +import re # noqa: F401 + +from typing import Any, List, Optional +from pydantic import BaseModel, Field, StrictStr, ValidationError, conint, validator +from typing import Union, Any, List, TYPE_CHECKING +try: + from typing import Literal +except ImportError: + from typing_extensions import Literal +from pydantic import StrictStr, Field + +INTORSTRING_ONE_OF_SCHEMAS = ["int", "str"] + +class IntOrString(BaseModel): + """ + IntOrString + """ + # data type: int + oneof_schema_1_validator: Optional[conint(strict=True, ge=10)] = None + # data type: str + oneof_schema_2_validator: Optional[StrictStr] = None + if TYPE_CHECKING: + actual_instance: Union[int, str] + else: + actual_instance: Any + + one_of_schemas: List[str] = Literal["int", "str"] + + """Pydantic configuration""" + model_config = { + "validate_assignment": True, + } + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") + if kwargs: + raise ValueError("If a position argument is used, keyword arguments cannot be used.") + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @validator('actual_instance') + def actual_instance_must_validate_oneof(cls, v): + instance = IntOrString.construct() + error_messages = [] + match = 0 + # validate data type: int + try: + instance.oneof_schema_1_validator = v + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # validate data type: str + try: + instance.oneof_schema_2_validator = v + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + if match > 1: + # more than 1 match + raise ValueError("Multiple matches found when setting `actual_instance` in IntOrString with oneOf schemas: int, str. Details: " + ", ".join(error_messages)) + elif match == 0: + # no match + raise ValueError("No match found when setting `actual_instance` in IntOrString with oneOf schemas: int, str. Details: " + ", ".join(error_messages)) + else: + return v + + @classmethod + def from_dict(cls, obj: dict) -> IntOrString: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> IntOrString: + """Returns the object represented by the json string""" + instance = IntOrString.construct() + error_messages = [] + match = 0 + + # deserialize data into int + try: + # validation + instance.oneof_schema_1_validator = json.loads(json_str) + # assign value to actual_instance + instance.actual_instance = instance.oneof_schema_1_validator + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into str + try: + # validation + instance.oneof_schema_2_validator = json.loads(json_str) + # assign value to actual_instance + instance.actual_instance = instance.oneof_schema_2_validator + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if match > 1: + # more than 1 match + raise ValueError("Multiple matches found when deserializing the JSON string into IntOrString with oneOf schemas: int, str. Details: " + ", ".join(error_messages)) + elif match == 0: + # no match + raise ValueError("No match found when deserializing the JSON string into IntOrString with oneOf schemas: int, str. Details: " + ", ".join(error_messages)) + else: + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + to_json = getattr(self.actual_instance, "to_json", None) + if callable(to_json): + return self.actual_instance.to_json() + else: + return json.dumps(self.actual_instance) + + def to_dict(self) -> dict: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + to_dict = getattr(self.actual_instance, "to_dict", None) + if callable(to_dict): + return self.actual_instance.to_dict() + else: + # primitive type + return self.actual_instance + + def to_str(self) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.dict()) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/list.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/list.py new file mode 100644 index 000000000000..4ca9ce45ae57 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/list.py @@ -0,0 +1,84 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, Field, StrictStr + +class List(BaseModel): + """ + List + """ + var_123_list: Optional[StrictStr] = Field(None, alias="123-list") + additional_properties: Dict[str, Any] = {} + __properties = ["123-list"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> List: + """Create an instance of List from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> List: + """Create an instance of List from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return List.parse_obj(obj) + + _obj = List.parse_obj({ + "var_123_list": obj.get("123-list") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/map_of_array_of_model.py new file mode 100644 index 000000000000..cdcbc232f988 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/map_of_array_of_model.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, List, Optional +from pydantic import BaseModel, Field, conlist +from petstore_api.models.tag import Tag + +class MapOfArrayOfModel(BaseModel): + """ + MapOfArrayOfModel + """ + shop_id_to_org_online_lip_map: Optional[Dict[str, conlist(Tag)]] = Field(None, alias="shopIdToOrgOnlineLipMap") + additional_properties: Dict[str, Any] = {} + __properties = ["shopIdToOrgOnlineLipMap"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> MapOfArrayOfModel: + """Create an instance of MapOfArrayOfModel from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of each value in shop_id_to_org_online_lip_map (dict of array) + _field_dict_of_array = {} + if self.shop_id_to_org_online_lip_map: + for _key in self.shop_id_to_org_online_lip_map: + if self.shop_id_to_org_online_lip_map[_key]: + _field_dict_of_array[_key] = [ + _item.to_dict() for _item in self.shop_id_to_org_online_lip_map[_key] + ] + _dict['shopIdToOrgOnlineLipMap'] = _field_dict_of_array + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> MapOfArrayOfModel: + """Create an instance of MapOfArrayOfModel from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return MapOfArrayOfModel.parse_obj(obj) + + _obj = MapOfArrayOfModel.parse_obj({ + "shop_id_to_org_online_lip_map": dict( + (_k, + [Tag.from_dict(_item) for _item in _v] + if _v is not None + else None + ) + for _k, _v in obj.get("shopIdToOrgOnlineLipMap").items() + ) + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/map_test.py new file mode 100644 index 000000000000..c2d729e9c9fd --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/map_test.py @@ -0,0 +1,100 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, StrictBool, StrictStr, validator + +class MapTest(BaseModel): + """ + MapTest + """ + map_map_of_string: Optional[Dict[str, Dict[str, StrictStr]]] = None + map_of_enum_string: Optional[Dict[str, StrictStr]] = None + direct_map: Optional[Dict[str, StrictBool]] = None + indirect_map: Optional[Dict[str, StrictBool]] = None + additional_properties: Dict[str, Any] = {} + __properties = ["map_map_of_string", "map_of_enum_string", "direct_map", "indirect_map"] + + @validator('map_of_enum_string') + def map_of_enum_string_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in ('UPPER', 'lower'): + raise ValueError("must be one of enum values ('UPPER', 'lower')") + return value + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> MapTest: + """Create an instance of MapTest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> MapTest: + """Create an instance of MapTest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return MapTest.parse_obj(obj) + + _obj = MapTest.parse_obj({ + "map_map_of_string": obj.get("map_map_of_string"), + "map_of_enum_string": obj.get("map_of_enum_string"), + "direct_map": obj.get("direct_map"), + "indirect_map": obj.get("indirect_map") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/mixed_properties_and_additional_properties_class.py new file mode 100644 index 000000000000..257f9a737395 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from datetime import datetime +from typing import Any, Dict, Optional +from pydantic import BaseModel, Field, StrictStr +from petstore_api.models.animal import Animal + +class MixedPropertiesAndAdditionalPropertiesClass(BaseModel): + """ + MixedPropertiesAndAdditionalPropertiesClass + """ + uuid: Optional[StrictStr] = None + date_time: Optional[datetime] = Field(None, alias="dateTime") + map: Optional[Dict[str, Animal]] = None + additional_properties: Dict[str, Any] = {} + __properties = ["uuid", "dateTime", "map"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> MixedPropertiesAndAdditionalPropertiesClass: + """Create an instance of MixedPropertiesAndAdditionalPropertiesClass from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of each value in map (dict) + _field_dict = {} + if self.map: + for _key in self.map: + if self.map[_key]: + _field_dict[_key] = self.map[_key].to_dict() + _dict['map'] = _field_dict + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> MixedPropertiesAndAdditionalPropertiesClass: + """Create an instance of MixedPropertiesAndAdditionalPropertiesClass from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return MixedPropertiesAndAdditionalPropertiesClass.parse_obj(obj) + + _obj = MixedPropertiesAndAdditionalPropertiesClass.parse_obj({ + "uuid": obj.get("uuid"), + "date_time": obj.get("dateTime"), + "map": dict( + (_k, Animal.from_dict(_v)) + for _k, _v in obj.get("map").items() + ) + if obj.get("map") is not None + else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/model200_response.py new file mode 100644 index 000000000000..d10d3e913b02 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/model200_response.py @@ -0,0 +1,86 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, Field, StrictInt, StrictStr + +class Model200Response(BaseModel): + """ + Model for testing model name starting with number # noqa: E501 + """ + name: Optional[StrictInt] = None + var_class: Optional[StrictStr] = Field(None, alias="class") + additional_properties: Dict[str, Any] = {} + __properties = ["name", "class"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Model200Response: + """Create an instance of Model200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Model200Response: + """Create an instance of Model200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Model200Response.parse_obj(obj) + + _obj = Model200Response.parse_obj({ + "name": obj.get("name"), + "var_class": obj.get("class") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/model_return.py new file mode 100644 index 000000000000..c7f18b149034 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/model_return.py @@ -0,0 +1,84 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, Field, StrictInt + +class ModelReturn(BaseModel): + """ + Model for testing reserved words # noqa: E501 + """ + var_return: Optional[StrictInt] = Field(None, alias="return") + additional_properties: Dict[str, Any] = {} + __properties = ["return"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> ModelReturn: + """Create an instance of ModelReturn from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> ModelReturn: + """Create an instance of ModelReturn from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return ModelReturn.parse_obj(obj) + + _obj = ModelReturn.parse_obj({ + "var_return": obj.get("return") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/name.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/name.py new file mode 100644 index 000000000000..483f75e148d6 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/name.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, Field, StrictInt, StrictStr + +class Name(BaseModel): + """ + Model for testing model name same as property name # noqa: E501 + """ + name: StrictInt = Field(...) + snake_case: Optional[StrictInt] = None + var_property: Optional[StrictStr] = Field(None, alias="property") + var_123_number: Optional[StrictInt] = Field(None, alias="123Number") + additional_properties: Dict[str, Any] = {} + __properties = ["name", "snake_case", "property", "123Number"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Name: + """Create an instance of Name from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "snake_case", + "var_123_number", + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Name: + """Create an instance of Name from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Name.parse_obj(obj) + + _obj = Name.parse_obj({ + "name": obj.get("name"), + "snake_case": obj.get("snake_case"), + "var_property": obj.get("property"), + "var_123_number": obj.get("123Number") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/nullable_class.py new file mode 100644 index 000000000000..52f9ad12be36 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/nullable_class.py @@ -0,0 +1,163 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from datetime import date, datetime +from typing import Any, Dict, List, Optional +from pydantic import BaseModel, Field, StrictBool, StrictFloat, StrictInt, StrictStr, conlist + +class NullableClass(BaseModel): + """ + NullableClass + """ + required_integer_prop: Optional[StrictInt] = Field(...) + integer_prop: Optional[StrictInt] = None + number_prop: Optional[StrictFloat] = None + boolean_prop: Optional[StrictBool] = None + string_prop: Optional[StrictStr] = None + date_prop: Optional[date] = None + datetime_prop: Optional[datetime] = None + array_nullable_prop: Optional[conlist(Dict[str, Any])] = None + array_and_items_nullable_prop: Optional[conlist(Dict[str, Any])] = None + array_items_nullable: Optional[conlist(Dict[str, Any])] = None + object_nullable_prop: Optional[Dict[str, Dict[str, Any]]] = None + object_and_items_nullable_prop: Optional[Dict[str, Dict[str, Any]]] = None + object_items_nullable: Optional[Dict[str, Dict[str, Any]]] = None + additional_properties: Dict[str, Any] = {} + __properties = ["required_integer_prop", "integer_prop", "number_prop", "boolean_prop", "string_prop", "date_prop", "datetime_prop", "array_nullable_prop", "array_and_items_nullable_prop", "array_items_nullable", "object_nullable_prop", "object_and_items_nullable_prop", "object_items_nullable"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> NullableClass: + """Create an instance of NullableClass from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + # set to None if required_integer_prop (nullable) is None + # and __fields_set__ contains the field + if self.required_integer_prop is None and "required_integer_prop" in self.__fields_set__: + _dict['required_integer_prop'] = None + + # set to None if integer_prop (nullable) is None + # and __fields_set__ contains the field + if self.integer_prop is None and "integer_prop" in self.__fields_set__: + _dict['integer_prop'] = None + + # set to None if number_prop (nullable) is None + # and __fields_set__ contains the field + if self.number_prop is None and "number_prop" in self.__fields_set__: + _dict['number_prop'] = None + + # set to None if boolean_prop (nullable) is None + # and __fields_set__ contains the field + if self.boolean_prop is None and "boolean_prop" in self.__fields_set__: + _dict['boolean_prop'] = None + + # set to None if string_prop (nullable) is None + # and __fields_set__ contains the field + if self.string_prop is None and "string_prop" in self.__fields_set__: + _dict['string_prop'] = None + + # set to None if date_prop (nullable) is None + # and __fields_set__ contains the field + if self.date_prop is None and "date_prop" in self.__fields_set__: + _dict['date_prop'] = None + + # set to None if datetime_prop (nullable) is None + # and __fields_set__ contains the field + if self.datetime_prop is None and "datetime_prop" in self.__fields_set__: + _dict['datetime_prop'] = None + + # set to None if array_nullable_prop (nullable) is None + # and __fields_set__ contains the field + if self.array_nullable_prop is None and "array_nullable_prop" in self.__fields_set__: + _dict['array_nullable_prop'] = None + + # set to None if array_and_items_nullable_prop (nullable) is None + # and __fields_set__ contains the field + if self.array_and_items_nullable_prop is None and "array_and_items_nullable_prop" in self.__fields_set__: + _dict['array_and_items_nullable_prop'] = None + + # set to None if object_nullable_prop (nullable) is None + # and __fields_set__ contains the field + if self.object_nullable_prop is None and "object_nullable_prop" in self.__fields_set__: + _dict['object_nullable_prop'] = None + + # set to None if object_and_items_nullable_prop (nullable) is None + # and __fields_set__ contains the field + if self.object_and_items_nullable_prop is None and "object_and_items_nullable_prop" in self.__fields_set__: + _dict['object_and_items_nullable_prop'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> NullableClass: + """Create an instance of NullableClass from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return NullableClass.parse_obj(obj) + + _obj = NullableClass.parse_obj({ + "required_integer_prop": obj.get("required_integer_prop"), + "integer_prop": obj.get("integer_prop"), + "number_prop": obj.get("number_prop"), + "boolean_prop": obj.get("boolean_prop"), + "string_prop": obj.get("string_prop"), + "date_prop": obj.get("date_prop"), + "datetime_prop": obj.get("datetime_prop"), + "array_nullable_prop": obj.get("array_nullable_prop"), + "array_and_items_nullable_prop": obj.get("array_and_items_nullable_prop"), + "array_items_nullable": obj.get("array_items_nullable"), + "object_nullable_prop": obj.get("object_nullable_prop"), + "object_and_items_nullable_prop": obj.get("object_and_items_nullable_prop"), + "object_items_nullable": obj.get("object_items_nullable") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/nullable_property.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/nullable_property.py new file mode 100644 index 000000000000..3cbde9fd5406 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/nullable_property.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, Field, StrictInt, constr, validator + +class NullableProperty(BaseModel): + """ + NullableProperty + """ + id: StrictInt = Field(...) + name: Optional[constr(strict=True)] = Field(...) + additional_properties: Dict[str, Any] = {} + __properties = ["id", "name"] + + @validator('name') + def name_validate_regular_expression(cls, value): + """Validates the regular expression""" + if value is None: + return value + + if not re.match(r"^[A-Z].*", value): + raise ValueError(r"must validate the regular expression /^[A-Z].*/") + return value + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> NullableProperty: + """Create an instance of NullableProperty from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + # set to None if name (nullable) is None + # and __fields_set__ contains the field + if self.name is None and "name" in self.__fields_set__: + _dict['name'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> NullableProperty: + """Create an instance of NullableProperty from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return NullableProperty.parse_obj(obj) + + _obj = NullableProperty.parse_obj({ + "id": obj.get("id"), + "name": obj.get("name") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/number_only.py new file mode 100644 index 000000000000..9d9f9ed9df08 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/number_only.py @@ -0,0 +1,84 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, Field, StrictFloat + +class NumberOnly(BaseModel): + """ + NumberOnly + """ + just_number: Optional[StrictFloat] = Field(None, alias="JustNumber") + additional_properties: Dict[str, Any] = {} + __properties = ["JustNumber"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> NumberOnly: + """Create an instance of NumberOnly from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> NumberOnly: + """Create an instance of NumberOnly from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return NumberOnly.parse_obj(obj) + + _obj = NumberOnly.parse_obj({ + "just_number": obj.get("JustNumber") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/object_to_test_additional_properties.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/object_to_test_additional_properties.py new file mode 100644 index 000000000000..ff8f56fa9d6e --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/object_to_test_additional_properties.py @@ -0,0 +1,84 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, Field, StrictBool + +class ObjectToTestAdditionalProperties(BaseModel): + """ + Minimal object # noqa: E501 + """ + var_property: Optional[StrictBool] = Field(False, alias="property", description="Property") + additional_properties: Dict[str, Any] = {} + __properties = ["property"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> ObjectToTestAdditionalProperties: + """Create an instance of ObjectToTestAdditionalProperties from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> ObjectToTestAdditionalProperties: + """Create an instance of ObjectToTestAdditionalProperties from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return ObjectToTestAdditionalProperties.parse_obj(obj) + + _obj = ObjectToTestAdditionalProperties.parse_obj({ + "var_property": obj.get("property") if obj.get("property") is not None else False + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/object_with_deprecated_fields.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/object_with_deprecated_fields.py new file mode 100644 index 000000000000..c2236b329861 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/object_with_deprecated_fields.py @@ -0,0 +1,94 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, List, Optional +from pydantic import BaseModel, Field, StrictFloat, StrictStr, conlist +from petstore_api.models.deprecated_object import DeprecatedObject + +class ObjectWithDeprecatedFields(BaseModel): + """ + ObjectWithDeprecatedFields + """ + uuid: Optional[StrictStr] = None + id: Optional[StrictFloat] = None + deprecated_ref: Optional[DeprecatedObject] = Field(None, alias="deprecatedRef") + bars: Optional[conlist(StrictStr)] = None + additional_properties: Dict[str, Any] = {} + __properties = ["uuid", "id", "deprecatedRef", "bars"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> ObjectWithDeprecatedFields: + """Create an instance of ObjectWithDeprecatedFields from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of deprecated_ref + if self.deprecated_ref: + _dict['deprecatedRef'] = self.deprecated_ref.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> ObjectWithDeprecatedFields: + """Create an instance of ObjectWithDeprecatedFields from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return ObjectWithDeprecatedFields.parse_obj(obj) + + _obj = ObjectWithDeprecatedFields.parse_obj({ + "uuid": obj.get("uuid"), + "id": obj.get("id"), + "deprecated_ref": DeprecatedObject.from_dict(obj.get("deprecatedRef")) if obj.get("deprecatedRef") is not None else None, + "bars": obj.get("bars") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/one_of_enum_string.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/one_of_enum_string.py new file mode 100644 index 000000000000..ab6c7a72586a --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/one_of_enum_string.py @@ -0,0 +1,148 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +from inspect import getfullargspec +import json +import pprint +import re # noqa: F401 + +from typing import Any, List, Optional +from pydantic import BaseModel, Field, StrictStr, ValidationError, validator +from petstore_api.models.enum_string1 import EnumString1 +from petstore_api.models.enum_string2 import EnumString2 +from typing import Union, Any, List, TYPE_CHECKING +try: + from typing import Literal +except ImportError: + from typing_extensions import Literal +from pydantic import StrictStr, Field + +ONEOFENUMSTRING_ONE_OF_SCHEMAS = ["EnumString1", "EnumString2"] + +class OneOfEnumString(BaseModel): + """ + oneOf enum strings + """ + # data type: EnumString1 + oneof_schema_1_validator: Optional[EnumString1] = None + # data type: EnumString2 + oneof_schema_2_validator: Optional[EnumString2] = None + if TYPE_CHECKING: + actual_instance: Union[EnumString1, EnumString2] + else: + actual_instance: Any + + one_of_schemas: List[str] = Literal["EnumString1", "EnumString2"] + + """Pydantic configuration""" + model_config = { + "validate_assignment": True, + } + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") + if kwargs: + raise ValueError("If a position argument is used, keyword arguments cannot be used.") + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @validator('actual_instance') + def actual_instance_must_validate_oneof(cls, v): + instance = OneOfEnumString.construct() + error_messages = [] + match = 0 + # validate data type: EnumString1 + if not isinstance(v, EnumString1): + error_messages.append(f"Error! Input type `{type(v)}` is not `EnumString1`") + else: + match += 1 + # validate data type: EnumString2 + if not isinstance(v, EnumString2): + error_messages.append(f"Error! Input type `{type(v)}` is not `EnumString2`") + else: + match += 1 + if match > 1: + # more than 1 match + raise ValueError("Multiple matches found when setting `actual_instance` in OneOfEnumString with oneOf schemas: EnumString1, EnumString2. Details: " + ", ".join(error_messages)) + elif match == 0: + # no match + raise ValueError("No match found when setting `actual_instance` in OneOfEnumString with oneOf schemas: EnumString1, EnumString2. Details: " + ", ".join(error_messages)) + else: + return v + + @classmethod + def from_dict(cls, obj: dict) -> OneOfEnumString: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> OneOfEnumString: + """Returns the object represented by the json string""" + instance = OneOfEnumString.construct() + error_messages = [] + match = 0 + + # deserialize data into EnumString1 + try: + instance.actual_instance = EnumString1.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into EnumString2 + try: + instance.actual_instance = EnumString2.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if match > 1: + # more than 1 match + raise ValueError("Multiple matches found when deserializing the JSON string into OneOfEnumString with oneOf schemas: EnumString1, EnumString2. Details: " + ", ".join(error_messages)) + elif match == 0: + # no match + raise ValueError("No match found when deserializing the JSON string into OneOfEnumString with oneOf schemas: EnumString1, EnumString2. Details: " + ", ".join(error_messages)) + else: + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + to_json = getattr(self.actual_instance, "to_json", None) + if callable(to_json): + return self.actual_instance.to_json() + else: + return json.dumps(self.actual_instance) + + def to_dict(self) -> dict: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + to_dict = getattr(self.actual_instance, "to_dict", None) + if callable(to_dict): + return self.actual_instance.to_dict() + else: + # primitive type + return self.actual_instance + + def to_str(self) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.dict()) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/order.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/order.py new file mode 100644 index 000000000000..8e6b41dfbc18 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/order.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from datetime import datetime +from typing import Any, Dict, Optional +from pydantic import BaseModel, Field, StrictBool, StrictInt, StrictStr, validator + +class Order(BaseModel): + """ + Order + """ + id: Optional[StrictInt] = None + pet_id: Optional[StrictInt] = Field(None, alias="petId") + quantity: Optional[StrictInt] = None + ship_date: Optional[datetime] = Field(None, alias="shipDate") + status: Optional[StrictStr] = Field(None, description="Order Status") + complete: Optional[StrictBool] = False + additional_properties: Dict[str, Any] = {} + __properties = ["id", "petId", "quantity", "shipDate", "status", "complete"] + + @validator('status') + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in ('placed', 'approved', 'delivered'): + raise ValueError("must be one of enum values ('placed', 'approved', 'delivered')") + return value + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Order: + """Create an instance of Order from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Order: + """Create an instance of Order from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Order.parse_obj(obj) + + _obj = Order.parse_obj({ + "id": obj.get("id"), + "pet_id": obj.get("petId"), + "quantity": obj.get("quantity"), + "ship_date": obj.get("shipDate"), + "status": obj.get("status"), + "complete": obj.get("complete") if obj.get("complete") is not None else False + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/outer_composite.py new file mode 100644 index 000000000000..478c1b53622b --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/outer_composite.py @@ -0,0 +1,88 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, StrictBool, StrictFloat, StrictStr + +class OuterComposite(BaseModel): + """ + OuterComposite + """ + my_number: Optional[StrictFloat] = None + my_string: Optional[StrictStr] = None + my_boolean: Optional[StrictBool] = None + additional_properties: Dict[str, Any] = {} + __properties = ["my_number", "my_string", "my_boolean"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> OuterComposite: + """Create an instance of OuterComposite from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> OuterComposite: + """Create an instance of OuterComposite from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return OuterComposite.parse_obj(obj) + + _obj = OuterComposite.parse_obj({ + "my_number": obj.get("my_number"), + "my_string": obj.get("my_string"), + "my_boolean": obj.get("my_boolean") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/outer_enum.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/outer_enum.py new file mode 100644 index 000000000000..bfb06a008b56 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/outer_enum.py @@ -0,0 +1,41 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import pprint +import re # noqa: F401 +from aenum import Enum, no_arg + + + + + +class OuterEnum(str, Enum): + """ + OuterEnum + """ + + """ + allowed enum values + """ + PLACED = 'placed' + APPROVED = 'approved' + DELIVERED = 'delivered' + + @classmethod + def from_json(cls, json_str: str) -> OuterEnum: + """Create an instance of OuterEnum from a JSON string""" + return OuterEnum(json.loads(json_str)) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/outer_enum_default_value.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/outer_enum_default_value.py new file mode 100644 index 000000000000..807c36f0fe5f --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/outer_enum_default_value.py @@ -0,0 +1,41 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import pprint +import re # noqa: F401 +from aenum import Enum, no_arg + + + + + +class OuterEnumDefaultValue(str, Enum): + """ + OuterEnumDefaultValue + """ + + """ + allowed enum values + """ + PLACED = 'placed' + APPROVED = 'approved' + DELIVERED = 'delivered' + + @classmethod + def from_json(cls, json_str: str) -> OuterEnumDefaultValue: + """Create an instance of OuterEnumDefaultValue from a JSON string""" + return OuterEnumDefaultValue(json.loads(json_str)) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/outer_enum_integer.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/outer_enum_integer.py new file mode 100644 index 000000000000..77ae46fa7059 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/outer_enum_integer.py @@ -0,0 +1,41 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import pprint +import re # noqa: F401 +from aenum import Enum, no_arg + + + + + +class OuterEnumInteger(int, Enum): + """ + OuterEnumInteger + """ + + """ + allowed enum values + """ + NUMBER_0 = 0 + NUMBER_1 = 1 + NUMBER_2 = 2 + + @classmethod + def from_json(cls, json_str: str) -> OuterEnumInteger: + """Create an instance of OuterEnumInteger from a JSON string""" + return OuterEnumInteger(json.loads(json_str)) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/outer_enum_integer_default_value.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/outer_enum_integer_default_value.py new file mode 100644 index 000000000000..36381197bb71 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/outer_enum_integer_default_value.py @@ -0,0 +1,42 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import pprint +import re # noqa: F401 +from aenum import Enum, no_arg + + + + + +class OuterEnumIntegerDefaultValue(int, Enum): + """ + OuterEnumIntegerDefaultValue + """ + + """ + allowed enum values + """ + NUMBER_MINUS_1 = -1 + NUMBER_0 = 0 + NUMBER_1 = 1 + NUMBER_2 = 2 + + @classmethod + def from_json(cls, json_str: str) -> OuterEnumIntegerDefaultValue: + """Create an instance of OuterEnumIntegerDefaultValue from a JSON string""" + return OuterEnumIntegerDefaultValue(json.loads(json_str)) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/outer_object_with_enum_property.py new file mode 100644 index 000000000000..8d7ad9f5c6d2 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/outer_object_with_enum_property.py @@ -0,0 +1,93 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, Field +from petstore_api.models.outer_enum import OuterEnum +from petstore_api.models.outer_enum_integer import OuterEnumInteger + +class OuterObjectWithEnumProperty(BaseModel): + """ + OuterObjectWithEnumProperty + """ + str_value: Optional[OuterEnum] = None + value: OuterEnumInteger = Field(...) + additional_properties: Dict[str, Any] = {} + __properties = ["str_value", "value"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> OuterObjectWithEnumProperty: + """Create an instance of OuterObjectWithEnumProperty from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + # set to None if str_value (nullable) is None + # and __fields_set__ contains the field + if self.str_value is None and "str_value" in self.__fields_set__: + _dict['str_value'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> OuterObjectWithEnumProperty: + """Create an instance of OuterObjectWithEnumProperty from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return OuterObjectWithEnumProperty.parse_obj(obj) + + _obj = OuterObjectWithEnumProperty.parse_obj({ + "str_value": obj.get("str_value"), + "value": obj.get("value") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/parent.py new file mode 100644 index 000000000000..f06c8c6f94e4 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/parent.py @@ -0,0 +1,97 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, Field +from petstore_api.models.inner_dict_with_property import InnerDictWithProperty + +class Parent(BaseModel): + """ + Parent + """ + optional_dict: Optional[Dict[str, InnerDictWithProperty]] = Field(None, alias="optionalDict") + additional_properties: Dict[str, Any] = {} + __properties = ["optionalDict"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Parent: + """Create an instance of Parent from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of each value in optional_dict (dict) + _field_dict = {} + if self.optional_dict: + for _key in self.optional_dict: + if self.optional_dict[_key]: + _field_dict[_key] = self.optional_dict[_key].to_dict() + _dict['optionalDict'] = _field_dict + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Parent: + """Create an instance of Parent from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Parent.parse_obj(obj) + + _obj = Parent.parse_obj({ + "optional_dict": dict( + (_k, InnerDictWithProperty.from_dict(_v)) + for _k, _v in obj.get("optionalDict").items() + ) + if obj.get("optionalDict") is not None + else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/parent_with_optional_dict.py new file mode 100644 index 000000000000..229a0b5f6e23 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/parent_with_optional_dict.py @@ -0,0 +1,97 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, Field +from petstore_api.models.inner_dict_with_property import InnerDictWithProperty + +class ParentWithOptionalDict(BaseModel): + """ + ParentWithOptionalDict + """ + optional_dict: Optional[Dict[str, InnerDictWithProperty]] = Field(None, alias="optionalDict") + additional_properties: Dict[str, Any] = {} + __properties = ["optionalDict"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> ParentWithOptionalDict: + """Create an instance of ParentWithOptionalDict from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of each value in optional_dict (dict) + _field_dict = {} + if self.optional_dict: + for _key in self.optional_dict: + if self.optional_dict[_key]: + _field_dict[_key] = self.optional_dict[_key].to_dict() + _dict['optionalDict'] = _field_dict + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> ParentWithOptionalDict: + """Create an instance of ParentWithOptionalDict from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return ParentWithOptionalDict.parse_obj(obj) + + _obj = ParentWithOptionalDict.parse_obj({ + "optional_dict": dict( + (_k, InnerDictWithProperty.from_dict(_v)) + for _k, _v in obj.get("optionalDict").items() + ) + if obj.get("optionalDict") is not None + else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/pet.py new file mode 100644 index 000000000000..dee18eb28c9c --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/pet.py @@ -0,0 +1,116 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, List, Optional +from pydantic import BaseModel, Field, StrictInt, StrictStr, conlist, validator +from petstore_api.models.category import Category +from petstore_api.models.tag import Tag + +class Pet(BaseModel): + """ + Pet + """ + id: Optional[StrictInt] = None + category: Optional[Category] = None + name: StrictStr = Field(...) + photo_urls: conlist(StrictStr, min_length=0) = Field(..., alias="photoUrls") + tags: Optional[conlist(Tag)] = None + status: Optional[StrictStr] = Field(None, description="pet status in the store") + additional_properties: Dict[str, Any] = {} + __properties = ["id", "category", "name", "photoUrls", "tags", "status"] + + @validator('status') + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in ('available', 'pending', 'sold'): + raise ValueError("must be one of enum values ('available', 'pending', 'sold')") + return value + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Pet: + """Create an instance of Pet from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of category + if self.category: + _dict['category'] = self.category.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in tags (list) + _items = [] + if self.tags: + for _item in self.tags: + if _item: + _items.append(_item.to_dict()) + _dict['tags'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Pet: + """Create an instance of Pet from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Pet.parse_obj(obj) + + _obj = Pet.parse_obj({ + "id": obj.get("id"), + "category": Category.from_dict(obj.get("category")) if obj.get("category") is not None else None, + "name": obj.get("name"), + "photo_urls": obj.get("photoUrls"), + "tags": [Tag.from_dict(_item) for _item in obj.get("tags")] if obj.get("tags") is not None else None, + "status": obj.get("status") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/pig.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/pig.py new file mode 100644 index 000000000000..7ceaec51ee85 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/pig.py @@ -0,0 +1,166 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +from inspect import getfullargspec +import json +import pprint +import re # noqa: F401 + +from typing import Any, List, Optional +from pydantic import BaseModel, Field, StrictStr, ValidationError, validator +from petstore_api.models.basque_pig import BasquePig +from petstore_api.models.danish_pig import DanishPig +from typing import Union, Any, List, TYPE_CHECKING +try: + from typing import Literal +except ImportError: + from typing_extensions import Literal +from pydantic import StrictStr, Field + +PIG_ONE_OF_SCHEMAS = ["BasquePig", "DanishPig"] + +class Pig(BaseModel): + """ + Pig + """ + # data type: BasquePig + oneof_schema_1_validator: Optional[BasquePig] = None + # data type: DanishPig + oneof_schema_2_validator: Optional[DanishPig] = None + if TYPE_CHECKING: + actual_instance: Union[BasquePig, DanishPig] + else: + actual_instance: Any + + one_of_schemas: List[str] = Literal["BasquePig", "DanishPig"] + + """Pydantic configuration""" + model_config = { + "validate_assignment": True, + } + + discriminator_value_class_map = { + } + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") + if kwargs: + raise ValueError("If a position argument is used, keyword arguments cannot be used.") + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @validator('actual_instance') + def actual_instance_must_validate_oneof(cls, v): + instance = Pig.construct() + error_messages = [] + match = 0 + # validate data type: BasquePig + if not isinstance(v, BasquePig): + error_messages.append(f"Error! Input type `{type(v)}` is not `BasquePig`") + else: + match += 1 + # validate data type: DanishPig + if not isinstance(v, DanishPig): + error_messages.append(f"Error! Input type `{type(v)}` is not `DanishPig`") + else: + match += 1 + if match > 1: + # more than 1 match + raise ValueError("Multiple matches found when setting `actual_instance` in Pig with oneOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) + elif match == 0: + # no match + raise ValueError("No match found when setting `actual_instance` in Pig with oneOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) + else: + return v + + @classmethod + def from_dict(cls, obj: dict) -> Pig: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> Pig: + """Returns the object represented by the json string""" + instance = Pig.construct() + error_messages = [] + match = 0 + + # use oneOf discriminator to lookup the data type + _data_type = json.loads(json_str).get("className") + if not _data_type: + raise ValueError("Failed to lookup data type from the field `className` in the input.") + + # check if data type is `BasquePig` + if _data_type == "BasquePig": + instance.actual_instance = BasquePig.from_json(json_str) + return instance + + # check if data type is `DanishPig` + if _data_type == "DanishPig": + instance.actual_instance = DanishPig.from_json(json_str) + return instance + + # deserialize data into BasquePig + try: + instance.actual_instance = BasquePig.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into DanishPig + try: + instance.actual_instance = DanishPig.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if match > 1: + # more than 1 match + raise ValueError("Multiple matches found when deserializing the JSON string into Pig with oneOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) + elif match == 0: + # no match + raise ValueError("No match found when deserializing the JSON string into Pig with oneOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) + else: + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + to_json = getattr(self.actual_instance, "to_json", None) + if callable(to_json): + return self.actual_instance.to_json() + else: + return json.dumps(self.actual_instance) + + def to_dict(self) -> dict: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + to_dict = getattr(self.actual_instance, "to_dict", None) + if callable(to_dict): + return self.actual_instance.to_dict() + else: + # primitive type + return self.actual_instance + + def to_str(self) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.dict()) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/property_name_collision.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/property_name_collision.py new file mode 100644 index 000000000000..0bc34c0540c2 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/property_name_collision.py @@ -0,0 +1,88 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, Field, StrictStr + +class PropertyNameCollision(BaseModel): + """ + PropertyNameCollision + """ + underscore_type: Optional[StrictStr] = Field(None, alias="_type") + type: Optional[StrictStr] = None + type_with_underscore: Optional[StrictStr] = Field(None, alias="type_") + additional_properties: Dict[str, Any] = {} + __properties = ["_type", "type", "type_"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> PropertyNameCollision: + """Create an instance of PropertyNameCollision from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> PropertyNameCollision: + """Create an instance of PropertyNameCollision from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return PropertyNameCollision.parse_obj(obj) + + _obj = PropertyNameCollision.parse_obj({ + "underscore_type": obj.get("_type"), + "type": obj.get("type"), + "type_with_underscore": obj.get("type_") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/read_only_first.py new file mode 100644 index 000000000000..b158341ff4c8 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/read_only_first.py @@ -0,0 +1,87 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, StrictStr + +class ReadOnlyFirst(BaseModel): + """ + ReadOnlyFirst + """ + bar: Optional[StrictStr] = None + baz: Optional[StrictStr] = None + additional_properties: Dict[str, Any] = {} + __properties = ["bar", "baz"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> ReadOnlyFirst: + """Create an instance of ReadOnlyFirst from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "bar", + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> ReadOnlyFirst: + """Create an instance of ReadOnlyFirst from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return ReadOnlyFirst.parse_obj(obj) + + _obj = ReadOnlyFirst.parse_obj({ + "bar": obj.get("bar"), + "baz": obj.get("baz") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/second_ref.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/second_ref.py new file mode 100644 index 000000000000..f4583d5fd584 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/second_ref.py @@ -0,0 +1,91 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, StrictStr + +class SecondRef(BaseModel): + """ + SecondRef + """ + category: Optional[StrictStr] = None + circular_ref: Optional[CircularReferenceModel] = None + additional_properties: Dict[str, Any] = {} + __properties = ["category", "circular_ref"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> SecondRef: + """Create an instance of SecondRef from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of circular_ref + if self.circular_ref: + _dict['circular_ref'] = self.circular_ref.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> SecondRef: + """Create an instance of SecondRef from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return SecondRef.parse_obj(obj) + + _obj = SecondRef.parse_obj({ + "category": obj.get("category"), + "circular_ref": CircularReferenceModel.from_dict(obj.get("circular_ref")) if obj.get("circular_ref") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + +from petstore_api.models.circular_reference_model import CircularReferenceModel +SecondRef.update_forward_refs() + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/self_reference_model.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/self_reference_model.py new file mode 100644 index 000000000000..fb6699d8ca33 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/self_reference_model.py @@ -0,0 +1,91 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, StrictInt + +class SelfReferenceModel(BaseModel): + """ + SelfReferenceModel + """ + size: Optional[StrictInt] = None + nested: Optional[DummyModel] = None + additional_properties: Dict[str, Any] = {} + __properties = ["size", "nested"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> SelfReferenceModel: + """Create an instance of SelfReferenceModel from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of nested + if self.nested: + _dict['nested'] = self.nested.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> SelfReferenceModel: + """Create an instance of SelfReferenceModel from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return SelfReferenceModel.parse_obj(obj) + + _obj = SelfReferenceModel.parse_obj({ + "size": obj.get("size"), + "nested": DummyModel.from_dict(obj.get("nested")) if obj.get("nested") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + +from petstore_api.models.dummy_model import DummyModel +SelfReferenceModel.update_forward_refs() + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/single_ref_type.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/single_ref_type.py new file mode 100644 index 000000000000..7edec4bb32cc --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/single_ref_type.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import pprint +import re # noqa: F401 +from aenum import Enum, no_arg + + + + + +class SingleRefType(str, Enum): + """ + SingleRefType + """ + + """ + allowed enum values + """ + ADMIN = 'admin' + USER = 'user' + + @classmethod + def from_json(cls, json_str: str) -> SingleRefType: + """Create an instance of SingleRefType from a JSON string""" + return SingleRefType(json.loads(json_str)) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/special_character_enum.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/special_character_enum.py new file mode 100644 index 000000000000..14b8a7e3fd67 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/special_character_enum.py @@ -0,0 +1,48 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import pprint +import re # noqa: F401 +from aenum import Enum, no_arg + + + + + +class SpecialCharacterEnum(str, Enum): + """ + SpecialCharacterEnum + """ + + """ + allowed enum values + """ + ENUM_456 = '456' + ENUM_123ABC = '123abc' + UNDERSCORE = '_' + SPACE = ' ' + AMPERSAND = '&' + DOLLAR = '$' + GREATER_THAN_EQUAL = '>=' + THIS_IS_EXCLAMATION = 'this_is_!' + IMPORT = 'import' + HELLO_WORLD = ' hello world ' + + @classmethod + def from_json(cls, json_str: str) -> SpecialCharacterEnum: + """Create an instance of SpecialCharacterEnum from a JSON string""" + return SpecialCharacterEnum(json.loads(json_str)) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/special_model_name.py new file mode 100644 index 000000000000..9d4671a535e8 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/special_model_name.py @@ -0,0 +1,84 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, Field, StrictInt + +class SpecialModelName(BaseModel): + """ + SpecialModelName + """ + special_property_name: Optional[StrictInt] = Field(None, alias="$special[property.name]") + additional_properties: Dict[str, Any] = {} + __properties = ["$special[property.name]"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> SpecialModelName: + """Create an instance of SpecialModelName from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> SpecialModelName: + """Create an instance of SpecialModelName from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return SpecialModelName.parse_obj(obj) + + _obj = SpecialModelName.parse_obj({ + "special_property_name": obj.get("$special[property.name]") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/special_name.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/special_name.py new file mode 100644 index 000000000000..0c1db5f7d2ec --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/special_name.py @@ -0,0 +1,102 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, Field, StrictInt, StrictStr, validator +from petstore_api.models.category import Category + +class SpecialName(BaseModel): + """ + SpecialName + """ + var_property: Optional[StrictInt] = Field(None, alias="property") + var_async: Optional[Category] = Field(None, alias="async") + var_schema: Optional[StrictStr] = Field(None, alias="schema", description="pet status in the store") + additional_properties: Dict[str, Any] = {} + __properties = ["property", "async", "schema"] + + @validator('var_schema') + def var_schema_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in ('available', 'pending', 'sold'): + raise ValueError("must be one of enum values ('available', 'pending', 'sold')") + return value + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> SpecialName: + """Create an instance of SpecialName from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of var_async + if self.var_async: + _dict['async'] = self.var_async.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> SpecialName: + """Create an instance of SpecialName from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return SpecialName.parse_obj(obj) + + _obj = SpecialName.parse_obj({ + "var_property": obj.get("property"), + "var_async": Category.from_dict(obj.get("async")) if obj.get("async") is not None else None, + "var_schema": obj.get("schema") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/tag.py new file mode 100644 index 000000000000..76347c44fe18 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/tag.py @@ -0,0 +1,86 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, StrictInt, StrictStr + +class Tag(BaseModel): + """ + Tag + """ + id: Optional[StrictInt] = None + name: Optional[StrictStr] = None + additional_properties: Dict[str, Any] = {} + __properties = ["id", "name"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Tag: + """Create an instance of Tag from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Tag: + """Create an instance of Tag from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Tag.parse_obj(obj) + + _obj = Tag.parse_obj({ + "id": obj.get("id"), + "name": obj.get("name") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/tiger.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/tiger.py new file mode 100644 index 000000000000..7c1c35949194 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/tiger.py @@ -0,0 +1,84 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, StrictStr + +class Tiger(BaseModel): + """ + Tiger + """ + skill: Optional[StrictStr] = None + additional_properties: Dict[str, Any] = {} + __properties = ["skill"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Tiger: + """Create an instance of Tiger from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Tiger: + """Create an instance of Tiger from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Tiger.parse_obj(obj) + + _obj = Tiger.parse_obj({ + "skill": obj.get("skill") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/user.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/user.py new file mode 100644 index 000000000000..c4791674d1b1 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/user.py @@ -0,0 +1,98 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, Field, StrictInt, StrictStr + +class User(BaseModel): + """ + User + """ + id: Optional[StrictInt] = None + username: Optional[StrictStr] = None + first_name: Optional[StrictStr] = Field(None, alias="firstName") + last_name: Optional[StrictStr] = Field(None, alias="lastName") + email: Optional[StrictStr] = None + password: Optional[StrictStr] = None + phone: Optional[StrictStr] = None + user_status: Optional[StrictInt] = Field(None, alias="userStatus", description="User Status") + additional_properties: Dict[str, Any] = {} + __properties = ["id", "username", "firstName", "lastName", "email", "password", "phone", "userStatus"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> User: + """Create an instance of User from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> User: + """Create an instance of User from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return User.parse_obj(obj) + + _obj = User.parse_obj({ + "id": obj.get("id"), + "username": obj.get("username"), + "first_name": obj.get("firstName"), + "last_name": obj.get("lastName"), + "email": obj.get("email"), + "password": obj.get("password"), + "phone": obj.get("phone"), + "user_status": obj.get("userStatus") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/with_nested_one_of.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/with_nested_one_of.py new file mode 100644 index 000000000000..3dc7c65504c6 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/models/with_nested_one_of.py @@ -0,0 +1,96 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, StrictInt +from petstore_api.models.one_of_enum_string import OneOfEnumString +from petstore_api.models.pig import Pig + +class WithNestedOneOf(BaseModel): + """ + WithNestedOneOf + """ + size: Optional[StrictInt] = None + nested_pig: Optional[Pig] = None + nested_oneof_enum_string: Optional[OneOfEnumString] = None + additional_properties: Dict[str, Any] = {} + __properties = ["size", "nested_pig", "nested_oneof_enum_string"] + + """Pydantic configuration""" + model_config = { + "populate_by_name": True, + "validate_assignment": True, + } + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> WithNestedOneOf: + """Create an instance of WithNestedOneOf from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of nested_pig + if self.nested_pig: + _dict['nested_pig'] = self.nested_pig.to_dict() + # override the default output from pydantic by calling `to_dict()` of nested_oneof_enum_string + if self.nested_oneof_enum_string: + _dict['nested_oneof_enum_string'] = self.nested_oneof_enum_string.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> WithNestedOneOf: + """Create an instance of WithNestedOneOf from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return WithNestedOneOf.parse_obj(obj) + + _obj = WithNestedOneOf.parse_obj({ + "size": obj.get("size"), + "nested_pig": Pig.from_dict(obj.get("nested_pig")) if obj.get("nested_pig") is not None else None, + "nested_oneof_enum_string": OneOfEnumString.from_dict(obj.get("nested_oneof_enum_string")) if obj.get("nested_oneof_enum_string") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/py.typed b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/py.typed new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/rest.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/rest.py new file mode 100755 index 000000000000..df9aca008048 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/rest.py @@ -0,0 +1,303 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import io +import json +import logging +import re +import ssl + +from urllib.parse import urlencode, quote_plus +import urllib3 + +from petstore_api.exceptions import ApiException, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, ApiValueError, BadRequestException + + +logger = logging.getLogger(__name__) + + +class RESTResponse(io.IOBase): + + def __init__(self, resp) -> None: + self.urllib3_response = resp + self.status = resp.status + self.reason = resp.reason + self.data = resp.data + + def getheaders(self): + """Returns a dictionary of the response headers.""" + return self.urllib3_response.headers + + def getheader(self, name, default=None): + """Returns a given response header.""" + return self.urllib3_response.headers.get(name, default) + + +class RESTClientObject: + + def __init__(self, configuration, pools_size=4, maxsize=None) -> None: + # urllib3.PoolManager will pass all kw parameters to connectionpool + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501 + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501 + # maxsize is the number of requests to host that are allowed in parallel # noqa: E501 + # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501 + + # cert_reqs + if configuration.verify_ssl: + cert_reqs = ssl.CERT_REQUIRED + else: + cert_reqs = ssl.CERT_NONE + + addition_pool_args = {} + if configuration.assert_hostname is not None: + addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 + + if configuration.retries is not None: + addition_pool_args['retries'] = configuration.retries + + if configuration.tls_server_name: + addition_pool_args['server_hostname'] = configuration.tls_server_name + + + if configuration.socket_options is not None: + addition_pool_args['socket_options'] = configuration.socket_options + + if maxsize is None: + if configuration.connection_pool_maxsize is not None: + maxsize = configuration.connection_pool_maxsize + else: + maxsize = 4 + + # https pool manager + if configuration.proxy: + self.pool_manager = urllib3.ProxyManager( + num_pools=pools_size, + maxsize=maxsize, + cert_reqs=cert_reqs, + ca_certs=configuration.ssl_ca_cert, + cert_file=configuration.cert_file, + key_file=configuration.key_file, + proxy_url=configuration.proxy, + proxy_headers=configuration.proxy_headers, + **addition_pool_args + ) + else: + self.pool_manager = urllib3.PoolManager( + num_pools=pools_size, + maxsize=maxsize, + cert_reqs=cert_reqs, + ca_certs=configuration.ssl_ca_cert, + cert_file=configuration.cert_file, + key_file=configuration.key_file, + **addition_pool_args + ) + + def request(self, method, url, query_params=None, headers=None, + body=None, post_params=None, _preload_content=True, + _request_timeout=None): + """Perform requests. + + :param method: http request method + :param url: http request url + :param query_params: query parameters in the url + :param headers: http request headers + :param body: request json body, for `application/json` + :param post_params: request post parameters, + `application/x-www-form-urlencoded` + and `multipart/form-data` + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + """ + method = method.upper() + assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', + 'PATCH', 'OPTIONS'] + + if post_params and body: + raise ApiValueError( + "body parameter cannot be used with post_params parameter." + ) + + post_params = post_params or {} + headers = headers or {} + # url already contains the URL query string + # so reset query_params to empty dict + query_params = {} + + timeout = None + if _request_timeout: + if isinstance(_request_timeout, (int,float)): # noqa: E501,F821 + timeout = urllib3.Timeout(total=_request_timeout) + elif (isinstance(_request_timeout, tuple) and + len(_request_timeout) == 2): + timeout = urllib3.Timeout( + connect=_request_timeout[0], read=_request_timeout[1]) + + try: + # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` + if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: + + # no content type provided or payload is json + if not headers.get('Content-Type') or re.search('json', headers['Content-Type'], re.IGNORECASE): + request_body = None + if body is not None: + request_body = json.dumps(body) + r = self.pool_manager.request( + method, url, + body=request_body, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 + r = self.pool_manager.request( + method, url, + fields=post_params, + encode_multipart=False, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + elif headers['Content-Type'] == 'multipart/form-data': + # must del headers['Content-Type'], or the correct + # Content-Type which generated by urllib3 will be + # overwritten. + del headers['Content-Type'] + r = self.pool_manager.request( + method, url, + fields=post_params, + encode_multipart=True, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + # Pass a `string` parameter directly in the body to support + # other content types than Json when `body` argument is + # provided in serialized form + elif isinstance(body, str) or isinstance(body, bytes): + request_body = body + r = self.pool_manager.request( + method, url, + body=request_body, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + else: + # Cannot generate the request from given parameters + msg = """Cannot prepare a request message for provided + arguments. Please check that your arguments match + declared content type.""" + raise ApiException(status=0, reason=msg) + # For `GET`, `HEAD` + else: + r = self.pool_manager.request(method, url, + fields={}, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + except urllib3.exceptions.SSLError as e: + msg = "{0}\n{1}".format(type(e).__name__, str(e)) + raise ApiException(status=0, reason=msg) + + if _preload_content: + r = RESTResponse(r) + + # log response body + logger.debug("response body: %s", r.data) + + if not 200 <= r.status <= 299: + if r.status == 400: + raise BadRequestException(http_resp=r) + + if r.status == 401: + raise UnauthorizedException(http_resp=r) + + if r.status == 403: + raise ForbiddenException(http_resp=r) + + if r.status == 404: + raise NotFoundException(http_resp=r) + + if 500 <= r.status <= 599: + raise ServiceException(http_resp=r) + + raise ApiException(http_resp=r) + + return r + + def get_request(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + return self.request("GET", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + + def head_request(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + return self.request("HEAD", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + + def options_request(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("OPTIONS", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def delete_request(self, url, headers=None, query_params=None, body=None, + _preload_content=True, _request_timeout=None): + return self.request("DELETE", url, + headers=headers, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def post_request(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("POST", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def put_request(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("PUT", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def patch_request(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("PATCH", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/signing.py b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/signing.py new file mode 100644 index 000000000000..ec4d7d2a67fd --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/petstore_api/signing.py @@ -0,0 +1,413 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from base64 import b64encode +from Crypto.IO import PEM, PKCS8 +from Crypto.Hash import SHA256, SHA512 +from Crypto.PublicKey import RSA, ECC +from Crypto.Signature import PKCS1_v1_5, pss, DSS +from email.utils import formatdate +import json +import os +import re +from time import time +from urllib.parse import urlencode, urlparse + +# The constants below define a subset of HTTP headers that can be included in the +# HTTP signature scheme. Additional headers may be included in the signature. + +# The '(request-target)' header is a calculated field that includes the HTTP verb, +# the URL path and the URL query. +HEADER_REQUEST_TARGET = '(request-target)' +# The time when the HTTP signature was generated. +HEADER_CREATED = '(created)' +# The time when the HTTP signature expires. The API server should reject HTTP requests +# that have expired. +HEADER_EXPIRES = '(expires)' +# The 'Host' header. +HEADER_HOST = 'Host' +# The 'Date' header. +HEADER_DATE = 'Date' +# When the 'Digest' header is included in the HTTP signature, the client automatically +# computes the digest of the HTTP request body, per RFC 3230. +HEADER_DIGEST = 'Digest' +# The 'Authorization' header is automatically generated by the client. It includes +# the list of signed headers and a base64-encoded signature. +HEADER_AUTHORIZATION = 'Authorization' + +# The constants below define the cryptographic schemes for the HTTP signature scheme. +SCHEME_HS2019 = 'hs2019' +SCHEME_RSA_SHA256 = 'rsa-sha256' +SCHEME_RSA_SHA512 = 'rsa-sha512' + +# The constants below define the signature algorithms that can be used for the HTTP +# signature scheme. +ALGORITHM_RSASSA_PSS = 'RSASSA-PSS' +ALGORITHM_RSASSA_PKCS1v15 = 'RSASSA-PKCS1-v1_5' + +ALGORITHM_ECDSA_MODE_FIPS_186_3 = 'fips-186-3' +ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979 = 'deterministic-rfc6979' +ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS = { + ALGORITHM_ECDSA_MODE_FIPS_186_3, + ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979 +} + +# The cryptographic hash algorithm for the message signature. +HASH_SHA256 = 'sha256' +HASH_SHA512 = 'sha512' + + +class HttpSigningConfiguration: + """The configuration parameters for the HTTP signature security scheme. + The HTTP signature security scheme is used to sign HTTP requests with a private key + which is in possession of the API client. + An 'Authorization' header is calculated by creating a hash of select headers, + and optionally the body of the HTTP request, then signing the hash value using + a private key. The 'Authorization' header is added to outbound HTTP requests. + + :param key_id: A string value specifying the identifier of the cryptographic key, + when signing HTTP requests. + :param signing_scheme: A string value specifying the signature scheme, when + signing HTTP requests. + Supported value are hs2019, rsa-sha256, rsa-sha512. + Avoid using rsa-sha256, rsa-sha512 as they are deprecated. These values are + available for server-side applications that only support the older + HTTP signature algorithms. + :param private_key_path: A string value specifying the path of the file containing + a private key. The private key is used to sign HTTP requests. + :param private_key_passphrase: A string value specifying the passphrase to decrypt + the private key. + :param signed_headers: A list of strings. Each value is the name of a HTTP header + that must be included in the HTTP signature calculation. + The two special signature headers '(request-target)' and '(created)' SHOULD be + included in SignedHeaders. + The '(created)' header expresses when the signature was created. + The '(request-target)' header is a concatenation of the lowercased :method, an + ASCII space, and the :path pseudo-headers. + When signed_headers is not specified, the client defaults to a single value, + '(created)', in the list of HTTP headers. + When SignedHeaders contains the 'Digest' value, the client performs the + following operations: + 1. Calculate a digest of request body, as specified in RFC3230, section 4.3.2. + 2. Set the 'Digest' header in the request body. + 3. Include the 'Digest' header and value in the HTTP signature. + :param signing_algorithm: A string value specifying the signature algorithm, when + signing HTTP requests. + Supported values are: + 1. For RSA keys: RSASSA-PSS, RSASSA-PKCS1-v1_5. + 2. For ECDSA keys: fips-186-3, deterministic-rfc6979. + If None, the signing algorithm is inferred from the private key. + The default signing algorithm for RSA keys is RSASSA-PSS. + The default signing algorithm for ECDSA keys is fips-186-3. + :param hash_algorithm: The hash algorithm for the signature. Supported values are + sha256 and sha512. + If the signing_scheme is rsa-sha256, the hash algorithm must be set + to None or sha256. + If the signing_scheme is rsa-sha512, the hash algorithm must be set + to None or sha512. + :param signature_max_validity: The signature max validity, expressed as + a datetime.timedelta value. It must be a positive value. + """ + def __init__(self, key_id, signing_scheme, private_key_path, + private_key_passphrase=None, + signed_headers=None, + signing_algorithm=None, + hash_algorithm=None, + signature_max_validity=None) -> None: + self.key_id = key_id + if signing_scheme not in {SCHEME_HS2019, SCHEME_RSA_SHA256, SCHEME_RSA_SHA512}: + raise Exception("Unsupported security scheme: {0}".format(signing_scheme)) + self.signing_scheme = signing_scheme + if not os.path.exists(private_key_path): + raise Exception("Private key file does not exist") + self.private_key_path = private_key_path + self.private_key_passphrase = private_key_passphrase + self.signing_algorithm = signing_algorithm + self.hash_algorithm = hash_algorithm + if signing_scheme == SCHEME_RSA_SHA256: + if self.hash_algorithm is None: + self.hash_algorithm = HASH_SHA256 + elif self.hash_algorithm != HASH_SHA256: + raise Exception("Hash algorithm must be sha256 when security scheme is %s" % + SCHEME_RSA_SHA256) + elif signing_scheme == SCHEME_RSA_SHA512: + if self.hash_algorithm is None: + self.hash_algorithm = HASH_SHA512 + elif self.hash_algorithm != HASH_SHA512: + raise Exception("Hash algorithm must be sha512 when security scheme is %s" % + SCHEME_RSA_SHA512) + elif signing_scheme == SCHEME_HS2019: + if self.hash_algorithm is None: + self.hash_algorithm = HASH_SHA256 + elif self.hash_algorithm not in {HASH_SHA256, HASH_SHA512}: + raise Exception("Invalid hash algorithm") + if signature_max_validity is not None and signature_max_validity.total_seconds() < 0: + raise Exception("The signature max validity must be a positive value") + self.signature_max_validity = signature_max_validity + # If the user has not provided any signed_headers, the default must be set to '(created)', + # as specified in the 'HTTP signature' standard. + if signed_headers is None or len(signed_headers) == 0: + signed_headers = [HEADER_CREATED] + if self.signature_max_validity is None and HEADER_EXPIRES in signed_headers: + raise Exception( + "Signature max validity must be set when " + "'(expires)' signature parameter is specified") + if len(signed_headers) != len(set(signed_headers)): + raise Exception("Cannot have duplicates in the signed_headers parameter") + if HEADER_AUTHORIZATION in signed_headers: + raise Exception("'Authorization' header cannot be included in signed headers") + self.signed_headers = signed_headers + self.private_key = None + """The private key used to sign HTTP requests. + Initialized when the PEM-encoded private key is loaded from a file. + """ + self.host = None + """The host name, optionally followed by a colon and TCP port number. + """ + self._load_private_key() + + def get_http_signature_headers(self, resource_path, method, headers, body, query_params): + """Create a cryptographic message signature for the HTTP request and add the signed headers. + + :param resource_path : A string representation of the HTTP request resource path. + :param method: A string representation of the HTTP request method, e.g. GET, POST. + :param headers: A dict containing the HTTP request headers. + :param body: The object representing the HTTP request body. + :param query_params: A string representing the HTTP request query parameters. + :return: A dict of HTTP headers that must be added to the outbound HTTP request. + """ + if method is None: + raise Exception("HTTP method must be set") + if resource_path is None: + raise Exception("Resource path must be set") + + signed_headers_list, request_headers_dict = self._get_signed_header_info( + resource_path, method, headers, body, query_params) + + header_items = [ + "{0}: {1}".format(key.lower(), value) for key, value in signed_headers_list] + string_to_sign = "\n".join(header_items) + + digest, digest_prefix = self._get_message_digest(string_to_sign.encode()) + b64_signed_msg = self._sign_digest(digest) + + request_headers_dict[HEADER_AUTHORIZATION] = self._get_authorization_header( + signed_headers_list, b64_signed_msg) + + return request_headers_dict + + def get_public_key(self): + """Returns the public key object associated with the private key. + """ + pubkey = None + if isinstance(self.private_key, RSA.RsaKey): + pubkey = self.private_key.publickey() + elif isinstance(self.private_key, ECC.EccKey): + pubkey = self.private_key.public_key() + return pubkey + + def _load_private_key(self): + """Load the private key used to sign HTTP requests. + The private key is used to sign HTTP requests as defined in + https://datatracker.ietf.org/doc/draft-cavage-http-signatures/. + """ + if self.private_key is not None: + return + with open(self.private_key_path, 'r') as f: + pem_data = f.read() + # Verify PEM Pre-Encapsulation Boundary + r = re.compile(r"\s*-----BEGIN (.*)-----\s+") + m = r.match(pem_data) + if not m: + raise ValueError("Not a valid PEM pre boundary") + pem_header = m.group(1) + if pem_header == 'RSA PRIVATE KEY': + self.private_key = RSA.importKey(pem_data, self.private_key_passphrase) + elif pem_header == 'EC PRIVATE KEY': + self.private_key = ECC.import_key(pem_data, self.private_key_passphrase) + elif pem_header in {'PRIVATE KEY', 'ENCRYPTED PRIVATE KEY'}: + # Key is in PKCS8 format, which is capable of holding many different + # types of private keys, not just EC keys. + (key_binary, pem_header, is_encrypted) = \ + PEM.decode(pem_data, self.private_key_passphrase) + (oid, privkey, params) = \ + PKCS8.unwrap(key_binary, passphrase=self.private_key_passphrase) + if oid == '1.2.840.10045.2.1': + self.private_key = ECC.import_key(pem_data, self.private_key_passphrase) + else: + raise Exception("Unsupported key: {0}. OID: {1}".format(pem_header, oid)) + else: + raise Exception("Unsupported key: {0}".format(pem_header)) + # Validate the specified signature algorithm is compatible with the private key. + if self.signing_algorithm is not None: + supported_algs = None + if isinstance(self.private_key, RSA.RsaKey): + supported_algs = {ALGORITHM_RSASSA_PSS, ALGORITHM_RSASSA_PKCS1v15} + elif isinstance(self.private_key, ECC.EccKey): + supported_algs = ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS + if supported_algs is not None and self.signing_algorithm not in supported_algs: + raise Exception( + "Signing algorithm {0} is not compatible with private key".format( + self.signing_algorithm)) + + def _get_signed_header_info(self, resource_path, method, headers, body, query_params): + """Build the HTTP headers (name, value) that need to be included in + the HTTP signature scheme. + + :param resource_path : A string representation of the HTTP request resource path. + :param method: A string representation of the HTTP request method, e.g. GET, POST. + :param headers: A dict containing the HTTP request headers. + :param body: The object (e.g. a dict) representing the HTTP request body. + :param query_params: A string representing the HTTP request query parameters. + :return: A tuple containing two dict objects: + The first dict contains the HTTP headers that are used to calculate + the HTTP signature. + The second dict contains the HTTP headers that must be added to + the outbound HTTP request. + """ + + if body is None: + body = '' + else: + body = body.to_json() + + # Build the '(request-target)' HTTP signature parameter. + target_host = urlparse(self.host).netloc + target_path = urlparse(self.host).path + request_target = method.lower() + " " + target_path + resource_path + if query_params: + request_target += "?" + urlencode(query_params) + + # Get UNIX time, e.g. seconds since epoch, not including leap seconds. + now = time() + # Format date per RFC 7231 section-7.1.1.2. An example is: + # Date: Wed, 21 Oct 2015 07:28:00 GMT + cdate = formatdate(timeval=now, localtime=False, usegmt=True) + # The '(created)' value MUST be a Unix timestamp integer value. + # Subsecond precision is not supported. + created = int(now) + if self.signature_max_validity is not None: + expires = now + self.signature_max_validity.total_seconds() + + signed_headers_list = [] + request_headers_dict = {} + for hdr_key in self.signed_headers: + hdr_key = hdr_key.lower() + if hdr_key == HEADER_REQUEST_TARGET: + value = request_target + elif hdr_key == HEADER_CREATED: + value = '{0}'.format(created) + elif hdr_key == HEADER_EXPIRES: + value = '{0}'.format(expires) + elif hdr_key == HEADER_DATE.lower(): + value = cdate + request_headers_dict[HEADER_DATE] = '{0}'.format(cdate) + elif hdr_key == HEADER_DIGEST.lower(): + request_body = body.encode() + body_digest, digest_prefix = self._get_message_digest(request_body) + b64_body_digest = b64encode(body_digest.digest()) + value = digest_prefix + b64_body_digest.decode('ascii') + request_headers_dict[HEADER_DIGEST] = '{0}{1}'.format( + digest_prefix, b64_body_digest.decode('ascii')) + elif hdr_key == HEADER_HOST.lower(): + value = target_host + request_headers_dict[HEADER_HOST] = '{0}'.format(target_host) + else: + value = next((v for k, v in headers.items() if k.lower() == hdr_key), None) + if value is None: + raise Exception( + "Cannot sign HTTP request. " + "Request does not contain the '{0}' header".format(hdr_key)) + signed_headers_list.append((hdr_key, value)) + + return signed_headers_list, request_headers_dict + + def _get_message_digest(self, data): + """Calculates and returns a cryptographic digest of a specified HTTP request. + + :param data: The string representation of the date to be hashed with a cryptographic hash. + :return: A tuple of (digest, prefix). + The digest is a hashing object that contains the cryptographic digest of + the HTTP request. + The prefix is a string that identifies the cryptographic hash. It is used + to generate the 'Digest' header as specified in RFC 3230. + """ + if self.hash_algorithm == HASH_SHA512: + digest = SHA512.new() + prefix = 'SHA-512=' + elif self.hash_algorithm == HASH_SHA256: + digest = SHA256.new() + prefix = 'SHA-256=' + else: + raise Exception("Unsupported hash algorithm: {0}".format(self.hash_algorithm)) + digest.update(data) + return digest, prefix + + def _sign_digest(self, digest): + """Signs a message digest with a private key specified in the signing_info. + + :param digest: A hashing object that contains the cryptographic digest of the HTTP request. + :return: A base-64 string representing the cryptographic signature of the input digest. + """ + sig_alg = self.signing_algorithm + if isinstance(self.private_key, RSA.RsaKey): + if sig_alg is None or sig_alg == ALGORITHM_RSASSA_PSS: + # RSASSA-PSS in Section 8.1 of RFC8017. + signature = pss.new(self.private_key).sign(digest) + elif sig_alg == ALGORITHM_RSASSA_PKCS1v15: + # RSASSA-PKCS1-v1_5 in Section 8.2 of RFC8017. + signature = PKCS1_v1_5.new(self.private_key).sign(digest) + else: + raise Exception("Unsupported signature algorithm: {0}".format(sig_alg)) + elif isinstance(self.private_key, ECC.EccKey): + if sig_alg is None: + sig_alg = ALGORITHM_ECDSA_MODE_FIPS_186_3 + if sig_alg in ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS: + # draft-ietf-httpbis-message-signatures-00 does not specify the ECDSA encoding. + # Issue: https://github.com/w3c-ccg/http-signatures/issues/107 + signature = DSS.new(key=self.private_key, mode=sig_alg, + encoding='der').sign(digest) + else: + raise Exception("Unsupported signature algorithm: {0}".format(sig_alg)) + else: + raise Exception("Unsupported private key: {0}".format(type(self.private_key))) + return b64encode(signature) + + def _get_authorization_header(self, signed_headers, signed_msg): + """Calculates and returns the value of the 'Authorization' header when signing HTTP requests. + + :param signed_headers : A list of tuples. Each value is the name of a HTTP header that + must be included in the HTTP signature calculation. + :param signed_msg: A base-64 encoded string representation of the signature. + :return: The string value of the 'Authorization' header, representing the signature + of the HTTP request. + """ + created_ts = None + expires_ts = None + for k, v in signed_headers: + if k == HEADER_CREATED: + created_ts = v + elif k == HEADER_EXPIRES: + expires_ts = v + lower_keys = [k.lower() for k, v in signed_headers] + headers_value = " ".join(lower_keys) + + auth_str = "Signature keyId=\"{0}\",algorithm=\"{1}\",".format( + self.key_id, self.signing_scheme) + if created_ts is not None: + auth_str = auth_str + "created={0},".format(created_ts) + if expires_ts is not None: + auth_str = auth_str + "expires={0},".format(expires_ts) + auth_str = auth_str + "headers=\"{0}\",signature=\"{1}\"".format( + headers_value, signed_msg.decode('ascii')) + + return auth_str diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/pom.xml b/samples/openapi3/client/petstore/python-pydantic-v2/pom.xml new file mode 100755 index 000000000000..726a0f11727e --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/pom.xml @@ -0,0 +1,46 @@ + + 4.0.0 + org.openapitools + PythonPydanticV2PetstoreTests + pom + 1.0-SNAPSHOT + Python OpenAPI3 Petstore Client + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + test + integration-test + + exec + + + make + + test-all + + + + + + + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/pyproject.toml b/samples/openapi3/client/petstore/python-pydantic-v2/pyproject.toml new file mode 100644 index 000000000000..43dc7e2fef11 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/pyproject.toml @@ -0,0 +1,32 @@ +[tool.poetry] +name = "petstore_api" +version = "1.0.0" +description = "OpenAPI Petstore" +authors = ["OpenAPI Generator Community "] +license = "Apache-2.0" +readme = "README.md" +repository = "https://github.com/GIT_USER_ID/GIT_REPO_ID" +keywords = ["OpenAPI", "OpenAPI-Generator", "OpenAPI Petstore"] +include = ["petstore_api/py.typed"] + +[tool.poetry.dependencies] +python = "^3.7" + +urllib3 = ">= 1.25.3" +python-dateutil = ">=2.8.2" +pem = ">= 19.3.0" +pycryptodome = ">= 3.9.0" +pydantic = ">=2" +aenum = ">=3.1.11" + +[tool.poetry.dev-dependencies] +pytest = ">=7.2.1" +tox = ">=3.9.0" +flake8 = ">=4.0.0" + +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[tool.pylint.'MESSAGES CONTROL'] +extension-pkg-whitelist = "pydantic" diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/requirements.txt b/samples/openapi3/client/petstore/python-pydantic-v2/requirements.txt new file mode 100755 index 000000000000..358a78535383 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/requirements.txt @@ -0,0 +1,5 @@ +python_dateutil >= 2.5.3 +setuptools >= 21.0.0 +urllib3 >= 1.25.3, < 2.1.0 +pydantic >= 2 +aenum >= 3.1.11 diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/setup.cfg b/samples/openapi3/client/petstore/python-pydantic-v2/setup.cfg new file mode 100755 index 000000000000..11433ee875ab --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/setup.cfg @@ -0,0 +1,2 @@ +[flake8] +max-line-length=99 diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/setup.py b/samples/openapi3/client/petstore/python-pydantic-v2/setup.py new file mode 100755 index 000000000000..2b1403fa17f7 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/setup.py @@ -0,0 +1,52 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from setuptools import setup, find_packages # noqa: H301 + +# To install the library, run the following +# +# python setup.py install +# +# prerequisite: setuptools +# http://pypi.python.org/pypi/setuptools +NAME = "petstore-api" +VERSION = "1.0.0" +PYTHON_REQUIRES = ">=3.7" +REQUIRES = [ + "urllib3 >= 1.25.3, < 2.1.0", + "python-dateutil", + "pem>=19.3.0", + "pycryptodome>=3.9.0", + "pydantic >= 2", + "aenum" +] + +setup( + name=NAME, + version=VERSION, + description="OpenAPI Petstore", + author="OpenAPI Generator community", + author_email="team@openapitools.org", + url="", + keywords=["OpenAPI", "OpenAPI-Generator", "OpenAPI Petstore"], + install_requires=REQUIRES, + packages=find_packages(exclude=["test", "tests"]), + include_package_data=True, + license="Apache-2.0", + long_description_content_type='text/markdown', + long_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: \" \\ + """, # noqa: E501 + package_data={"petstore_api": ["py.typed"]}, +) diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test-requirements.txt b/samples/openapi3/client/petstore/python-pydantic-v2/test-requirements.txt new file mode 100755 index 000000000000..8fc452fe6edd --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test-requirements.txt @@ -0,0 +1,4 @@ +pytest~=7.1.3 +pytest-cov>=2.8.1 +pytest-randomly>=3.12.0 +pycryptodome>=3.9.0 diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/__init__.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/__init__.py new file mode 100755 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_additional_properties_any_type.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_additional_properties_any_type.py new file mode 100644 index 000000000000..c2c9c7c58069 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_additional_properties_any_type.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +import unittest +import datetime + +import petstore_api +from petstore_api.models.additional_properties_any_type import AdditionalPropertiesAnyType # noqa: E501 +from petstore_api.rest import ApiException + +class TestAdditionalPropertiesAnyType(unittest.TestCase): + """AdditionalPropertiesAnyType unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test AdditionalPropertiesAnyType + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `AdditionalPropertiesAnyType` + """ + model = petstore_api.models.additional_properties_any_type.AdditionalPropertiesAnyType() # noqa: E501 + if include_optional : + return AdditionalPropertiesAnyType( + name = '' + ) + else : + return AdditionalPropertiesAnyType( + ) + """ + + def testAdditionalPropertiesAnyType(self): + """Test AdditionalPropertiesAnyType""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_additional_properties_class.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_additional_properties_class.py new file mode 100644 index 000000000000..e3b48bedd571 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_additional_properties_class.py @@ -0,0 +1,61 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +import unittest +import datetime + +import petstore_api +from petstore_api.models.additional_properties_class import AdditionalPropertiesClass # noqa: E501 +from petstore_api.rest import ApiException + +class TestAdditionalPropertiesClass(unittest.TestCase): + """AdditionalPropertiesClass unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test AdditionalPropertiesClass + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `AdditionalPropertiesClass` + """ + model = petstore_api.models.additional_properties_class.AdditionalPropertiesClass() # noqa: E501 + if include_optional : + return AdditionalPropertiesClass( + map_property = { + 'key' : '' + }, + map_of_map_property = { + 'key' : { + 'key' : '' + } + } + ) + else : + return AdditionalPropertiesClass( + ) + """ + + def testAdditionalPropertiesClass(self): + """Test AdditionalPropertiesClass""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_additional_properties_object.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_additional_properties_object.py new file mode 100644 index 000000000000..b68a8fda5790 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_additional_properties_object.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +import unittest +import datetime + +import petstore_api +from petstore_api.models.additional_properties_object import AdditionalPropertiesObject # noqa: E501 +from petstore_api.rest import ApiException + +class TestAdditionalPropertiesObject(unittest.TestCase): + """AdditionalPropertiesObject unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test AdditionalPropertiesObject + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `AdditionalPropertiesObject` + """ + model = petstore_api.models.additional_properties_object.AdditionalPropertiesObject() # noqa: E501 + if include_optional : + return AdditionalPropertiesObject( + name = '' + ) + else : + return AdditionalPropertiesObject( + ) + """ + + def testAdditionalPropertiesObject(self): + """Test AdditionalPropertiesObject""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_additional_properties_with_description_only.py new file mode 100644 index 000000000000..d5166dfe1342 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_additional_properties_with_description_only.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +import unittest +import datetime + +import petstore_api +from petstore_api.models.additional_properties_with_description_only import AdditionalPropertiesWithDescriptionOnly # noqa: E501 +from petstore_api.rest import ApiException + +class TestAdditionalPropertiesWithDescriptionOnly(unittest.TestCase): + """AdditionalPropertiesWithDescriptionOnly unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test AdditionalPropertiesWithDescriptionOnly + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `AdditionalPropertiesWithDescriptionOnly` + """ + model = petstore_api.models.additional_properties_with_description_only.AdditionalPropertiesWithDescriptionOnly() # noqa: E501 + if include_optional : + return AdditionalPropertiesWithDescriptionOnly( + name = '' + ) + else : + return AdditionalPropertiesWithDescriptionOnly( + ) + """ + + def testAdditionalPropertiesWithDescriptionOnly(self): + """Test AdditionalPropertiesWithDescriptionOnly""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_all_of_with_single_ref.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_all_of_with_single_ref.py new file mode 100644 index 000000000000..ee761ef82d0a --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_all_of_with_single_ref.py @@ -0,0 +1,52 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.all_of_with_single_ref import AllOfWithSingleRef # noqa: E501 +from petstore_api.rest import ApiException + +class TestAllOfWithSingleRef(unittest.TestCase): + """AllOfWithSingleRef unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test AllOfWithSingleRef + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.all_of_with_single_ref.AllOfWithSingleRef() # noqa: E501 + if include_optional : + return AllOfWithSingleRef( + username = '', + single_ref_type = None + ) + else : + return AllOfWithSingleRef( + ) + + def testAllOfWithSingleRef(self): + """Test AllOfWithSingleRef""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_animal.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_animal.py new file mode 100644 index 000000000000..d209151de678 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_animal.py @@ -0,0 +1,53 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.animal import Animal # noqa: E501 +from petstore_api.rest import ApiException + +class TestAnimal(unittest.TestCase): + """Animal unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test Animal + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.animal.Animal() # noqa: E501 + if include_optional : + return Animal( + class_name = '', + color = 'red' + ) + else : + return Animal( + class_name = '', + ) + + def testAnimal(self): + """Test Animal""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_another_fake_api.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_another_fake_api.py new file mode 100644 index 000000000000..d95798cfc5a4 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_another_fake_api.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api +from petstore_api.api.another_fake_api import AnotherFakeApi # noqa: E501 +from petstore_api.rest import ApiException + + +class TestAnotherFakeApi(unittest.TestCase): + """AnotherFakeApi unit test stubs""" + + def setUp(self): + self.api = petstore_api.api.another_fake_api.AnotherFakeApi() # noqa: E501 + + def tearDown(self): + pass + + def test_call_123_test_special_tags(self): + """Test case for call_123_test_special_tags + + To test special tags # noqa: E501 + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_any_of_color.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_any_of_color.py new file mode 100644 index 000000000000..2a97cfef7526 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_any_of_color.py @@ -0,0 +1,53 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.any_of_color import AnyOfColor # noqa: E501 +from petstore_api.rest import ApiException + +class TestAnyOfColor(unittest.TestCase): + """AnyOfColor unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test AnyOfColor + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `AnyOfColor` + """ + model = petstore_api.models.any_of_color.AnyOfColor() # noqa: E501 + if include_optional : + return AnyOfColor( + ) + else : + return AnyOfColor( + ) + """ + + def testAnyOfColor(self): + """Test AnyOfColor""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_any_of_pig.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_any_of_pig.py new file mode 100644 index 000000000000..f041e5f9d6f7 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_any_of_pig.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.any_of_pig import AnyOfPig # noqa: E501 +from petstore_api.rest import ApiException + +class TestAnyOfPig(unittest.TestCase): + """AnyOfPig unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testAnyOfPig(self): + """Test AnyOfPig""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_api_response.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_api_response.py new file mode 100644 index 000000000000..95efd33bce57 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_api_response.py @@ -0,0 +1,53 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.api_response import ApiResponse # noqa: E501 +from petstore_api.rest import ApiException + +class TestApiResponse(unittest.TestCase): + """ApiResponse unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test ApiResponse + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.api_response.ApiResponse() # noqa: E501 + if include_optional : + return ApiResponse( + code = 56, + type = '', + message = '' + ) + else : + return ApiResponse( + ) + + def testApiResponse(self): + """Test ApiResponse""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_array_of_array_of_model.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_array_of_array_of_model.py new file mode 100644 index 000000000000..1072a19255de --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_array_of_array_of_model.py @@ -0,0 +1,60 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +import unittest +import datetime + +import petstore_api +from petstore_api.models.array_of_array_of_model import ArrayOfArrayOfModel # noqa: E501 +from petstore_api.rest import ApiException + +class TestArrayOfArrayOfModel(unittest.TestCase): + """ArrayOfArrayOfModel unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test ArrayOfArrayOfModel + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `ArrayOfArrayOfModel` + """ + model = petstore_api.models.array_of_array_of_model.ArrayOfArrayOfModel() # noqa: E501 + if include_optional : + return ArrayOfArrayOfModel( + shop_id_to_org_online_lip_map = [ + [ + petstore_api.models.tag.Tag( + id = 56, + name = '', ) + ] + ] + ) + else : + return ArrayOfArrayOfModel( + ) + """ + + def testArrayOfArrayOfModel(self): + """Test ArrayOfArrayOfModel""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_array_of_array_of_number_only.py new file mode 100644 index 000000000000..001b4e565737 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_array_of_array_of_number_only.py @@ -0,0 +1,55 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly # noqa: E501 +from petstore_api.rest import ApiException + +class TestArrayOfArrayOfNumberOnly(unittest.TestCase): + """ArrayOfArrayOfNumberOnly unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test ArrayOfArrayOfNumberOnly + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.array_of_array_of_number_only.ArrayOfArrayOfNumberOnly() # noqa: E501 + if include_optional : + return ArrayOfArrayOfNumberOnly( + array_array_number = [ + [ + 1.337 + ] + ] + ) + else : + return ArrayOfArrayOfNumberOnly( + ) + + def testArrayOfArrayOfNumberOnly(self): + """Test ArrayOfArrayOfNumberOnly""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_array_of_number_only.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_array_of_number_only.py new file mode 100644 index 000000000000..a35703ae0dac --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_array_of_number_only.py @@ -0,0 +1,53 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.array_of_number_only import ArrayOfNumberOnly # noqa: E501 +from petstore_api.rest import ApiException + +class TestArrayOfNumberOnly(unittest.TestCase): + """ArrayOfNumberOnly unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test ArrayOfNumberOnly + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.array_of_number_only.ArrayOfNumberOnly() # noqa: E501 + if include_optional : + return ArrayOfNumberOnly( + array_number = [ + 1.337 + ] + ) + else : + return ArrayOfNumberOnly( + ) + + def testArrayOfNumberOnly(self): + """Test ArrayOfNumberOnly""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_array_test.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_array_test.py new file mode 100644 index 000000000000..8327e415adcd --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_array_test.py @@ -0,0 +1,65 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.array_test import ArrayTest # noqa: E501 +from petstore_api.rest import ApiException + +class TestArrayTest(unittest.TestCase): + """ArrayTest unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test ArrayTest + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.array_test.ArrayTest() # noqa: E501 + if include_optional : + return ArrayTest( + array_of_string = [ + '' + ], + array_array_of_integer = [ + [ + 56 + ] + ], + array_array_of_model = [ + [ + petstore_api.models.read_only_first.ReadOnlyFirst( + bar = '', + baz = '', ) + ] + ] + ) + else : + return ArrayTest( + ) + + def testArrayTest(self): + """Test ArrayTest""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_basque_pig.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_basque_pig.py new file mode 100644 index 000000000000..26e2a845a95c --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_basque_pig.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.basque_pig import BasquePig # noqa: E501 +from petstore_api.rest import ApiException + +class TestBasquePig(unittest.TestCase): + """BasquePig unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test BasquePig + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.basque_pig.BasquePig() # noqa: E501 + if include_optional : + return BasquePig( + class_name = '', + color = '' + ) + else : + return BasquePig( + class_name = '', + color = '', + ) + + def testBasquePig(self): + """Test BasquePig""" + #inst_req_only = self.make_instance(include_optional=False) + #inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_capitalization.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_capitalization.py new file mode 100644 index 000000000000..c7a9721dbc00 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_capitalization.py @@ -0,0 +1,56 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.capitalization import Capitalization # noqa: E501 +from petstore_api.rest import ApiException + +class TestCapitalization(unittest.TestCase): + """Capitalization unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test Capitalization + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.capitalization.Capitalization() # noqa: E501 + if include_optional : + return Capitalization( + small_camel = '', + capital_camel = '', + small_snake = '', + capital_snake = '', + sca_eth_flow_points = '', + att_name = '' + ) + else : + return Capitalization( + ) + + def testCapitalization(self): + """Test Capitalization""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_cat.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_cat.py new file mode 100644 index 000000000000..e04566b1aafd --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_cat.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.cat import Cat # noqa: E501 +from petstore_api.rest import ApiException + +class TestCat(unittest.TestCase): + """Cat unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testCat(self): + """Test Cat""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_category.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_category.py new file mode 100644 index 000000000000..14848fcebcd2 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_category.py @@ -0,0 +1,53 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.category import Category # noqa: E501 +from petstore_api.rest import ApiException + +class TestCategory(unittest.TestCase): + """Category unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test Category + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.category.Category() # noqa: E501 + if include_optional : + return Category( + id = 56, + name = 'default-name' + ) + else : + return Category( + name = 'default-name', + ) + + def testCategory(self): + """Test Category""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_class_model.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_class_model.py new file mode 100644 index 000000000000..511843f2dcfd --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_class_model.py @@ -0,0 +1,51 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.class_model import ClassModel # noqa: E501 +from petstore_api.rest import ApiException + +class TestClassModel(unittest.TestCase): + """ClassModel unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test ClassModel + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.class_model.ClassModel() # noqa: E501 + if include_optional : + return ClassModel( + _class = '' + ) + else : + return ClassModel( + ) + + def testClassModel(self): + """Test ClassModel""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_client.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_client.py new file mode 100644 index 000000000000..9209bb2c3f03 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_client.py @@ -0,0 +1,51 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.client import Client # noqa: E501 +from petstore_api.rest import ApiException + +class TestClient(unittest.TestCase): + """Client unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test Client + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.client.Client() # noqa: E501 + if include_optional : + return Client( + client = '' + ) + else : + return Client( + ) + + def testClient(self): + """Test Client""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_color.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_color.py new file mode 100644 index 000000000000..9a7aabfea253 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_color.py @@ -0,0 +1,53 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.color import Color # noqa: E501 +from petstore_api.rest import ApiException + +class TestColor(unittest.TestCase): + """Color unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test Color + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `Color` + """ + model = petstore_api.models.color.Color() # noqa: E501 + if include_optional : + return Color( + ) + else : + return Color( + ) + """ + + def testColor(self): + """Test Color""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_configuration.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_configuration.py new file mode 100755 index 000000000000..d41ffa63ba8a --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_configuration.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + OpenAPI spec version: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api +from petstore_api import Configuration # noqa: E501 +from petstore_api.rest import ApiException + + +class TestConfiguration(unittest.TestCase): + """Configuration unit test stubs""" + + def setUp(self): + self.config= Configuration() + + def tearDown(self): + pass + + def test_configuration(self): + """Test configuration + + Test host settings # noqa: E501 + """ + host_settings = self.config.get_host_settings() + + self.assertEqual('http://{server}.swagger.io:{port}/v2', host_settings[0]['url']) + self.assertEqual('petstore', host_settings[0]['variables']['server']['default_value']) + + self.assertEqual('https://localhost:8080/{version}', host_settings[1]['url']) + self.assertEqual('v2', host_settings[1]['variables']['version']['default_value']) + + def test_get_host_from_settings(self): + """ Test get_host_from_settings + + Test get URL from host settings + """ + self.assertEqual("http://petstore.swagger.io:80/v2", self.config.get_host_from_settings(0)) + self.assertEqual("http://petstore.swagger.io:8080/v2", self.config.get_host_from_settings(0, {'port': '8080'})) + self.assertEqual("http://dev-petstore.swagger.io:8080/v2", self.config.get_host_from_settings(0, {'server': 'dev-petstore', 'port': '8080'})) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_creature.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_creature.py new file mode 100644 index 000000000000..66b3e088cbbf --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_creature.py @@ -0,0 +1,59 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +import unittest +import datetime + +import petstore_api +from petstore_api.models.creature import Creature # noqa: E501 +from petstore_api.rest import ApiException + +class TestCreature(unittest.TestCase): + """Creature unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test Creature + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `Creature` + """ + model = petstore_api.models.creature.Creature() # noqa: E501 + if include_optional : + return Creature( + info = petstore_api.models.creature_info.CreatureInfo( + name = '', ), + type = '' + ) + else : + return Creature( + info = petstore_api.models.creature_info.CreatureInfo( + name = '', ), + type = '', + ) + """ + + def testCreature(self): + """Test Creature""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_creature_info.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_creature_info.py new file mode 100644 index 000000000000..0a85d5ffe7b2 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_creature_info.py @@ -0,0 +1,55 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +import unittest +import datetime + +import petstore_api +from petstore_api.models.creature_info import CreatureInfo # noqa: E501 +from petstore_api.rest import ApiException + +class TestCreatureInfo(unittest.TestCase): + """CreatureInfo unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test CreatureInfo + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `CreatureInfo` + """ + model = petstore_api.models.creature_info.CreatureInfo() # noqa: E501 + if include_optional : + return CreatureInfo( + name = '' + ) + else : + return CreatureInfo( + name = '', + ) + """ + + def testCreatureInfo(self): + """Test CreatureInfo""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_danish_pig.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_danish_pig.py new file mode 100644 index 000000000000..0d850ae94f41 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_danish_pig.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.danish_pig import DanishPig # noqa: E501 +from petstore_api.rest import ApiException + +class TestDanishPig(unittest.TestCase): + """DanishPig unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test DanishPig + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.danish_pig.DanishPig() # noqa: E501 + if include_optional : + return DanishPig( + class_name = '', + size = 56 + ) + else : + return DanishPig( + class_name = '', + size = 56, + ) + + def testDanishPig(self): + """Test DanishPig""" + #inst_req_only = self.make_instance(include_optional=False) + #inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_default_api.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_default_api.py new file mode 100644 index 000000000000..50e7c57bd0bf --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_default_api.py @@ -0,0 +1,39 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api +from petstore_api.api.default_api import DefaultApi # noqa: E501 +from petstore_api.rest import ApiException + + +class TestDefaultApi(unittest.TestCase): + """DefaultApi unit test stubs""" + + def setUp(self): + self.api = petstore_api.api.default_api.DefaultApi() # noqa: E501 + + def tearDown(self): + pass + + def test_foo_get(self): + """Test case for foo_get + + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_deprecated_object.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_deprecated_object.py new file mode 100644 index 000000000000..50257271cd72 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_deprecated_object.py @@ -0,0 +1,51 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.deprecated_object import DeprecatedObject # noqa: E501 +from petstore_api.rest import ApiException + +class TestDeprecatedObject(unittest.TestCase): + """DeprecatedObject unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test DeprecatedObject + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.deprecated_object.DeprecatedObject() # noqa: E501 + if include_optional : + return DeprecatedObject( + name = '' + ) + else : + return DeprecatedObject( + ) + + def testDeprecatedObject(self): + """Test DeprecatedObject""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_dog.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_dog.py new file mode 100644 index 000000000000..af75161287e1 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_dog.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.dog import Dog # noqa: E501 +from petstore_api.rest import ApiException + +class TestDog(unittest.TestCase): + """Dog unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testDog(self): + """Test Dog""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_dummy_model.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_dummy_model.py new file mode 100644 index 000000000000..d6562c58bc2d --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_dummy_model.py @@ -0,0 +1,58 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.dummy_model import DummyModel # noqa: E501 +from petstore_api.rest import ApiException + +class TestDummyModel(unittest.TestCase): + """DummyModel unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test DummyModel + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `DummyModel` + """ + model = petstore_api.models.dummy_model.DummyModel() # noqa: E501 + if include_optional : + return DummyModel( + category = '', + self_ref = petstore_api.models.self_reference_model.Self-Reference-Model( + size = 56, + nested = petstore_api.models.dummy_model.Dummy-Model( + category = '', ), ) + ) + else : + return DummyModel( + ) + """ + + def testDummyModel(self): + """Test DummyModel""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_enum_arrays.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_enum_arrays.py new file mode 100644 index 000000000000..52cc98601bc0 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_enum_arrays.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.enum_arrays import EnumArrays # noqa: E501 +from petstore_api.rest import ApiException + +class TestEnumArrays(unittest.TestCase): + """EnumArrays unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test EnumArrays + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.enum_arrays.EnumArrays() # noqa: E501 + if include_optional : + return EnumArrays( + just_symbol = '>=', + array_enum = [ + 'fish' + ] + ) + else : + return EnumArrays( + ) + + def testEnumArrays(self): + """Test EnumArrays""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_enum_class.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_enum_class.py new file mode 100644 index 000000000000..9d7a81272cd2 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_enum_class.py @@ -0,0 +1,36 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.enum_class import EnumClass # noqa: E501 +from petstore_api.rest import ApiException + +class TestEnumClass(unittest.TestCase): + """EnumClass unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testEnumClass(self): + """Test EnumClass""" + # inst = EnumClass() + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_enum_string1.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_enum_string1.py new file mode 100644 index 000000000000..9dbe9eb44fb8 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_enum_string1.py @@ -0,0 +1,36 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +import unittest +import datetime + +import petstore_api +from petstore_api.models.enum_string1 import EnumString1 # noqa: E501 +from petstore_api.rest import ApiException + +class TestEnumString1(unittest.TestCase): + """EnumString1 unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testEnumString1(self): + """Test EnumString1""" + # inst = EnumString1() + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_enum_string2.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_enum_string2.py new file mode 100644 index 000000000000..4ec0ffcd86c7 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_enum_string2.py @@ -0,0 +1,36 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +import unittest +import datetime + +import petstore_api +from petstore_api.models.enum_string2 import EnumString2 # noqa: E501 +from petstore_api.rest import ApiException + +class TestEnumString2(unittest.TestCase): + """EnumString2 unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testEnumString2(self): + """Test EnumString2""" + # inst = EnumString2() + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_enum_test.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_enum_test.py new file mode 100644 index 000000000000..afb342ae9341 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_enum_test.py @@ -0,0 +1,59 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.enum_test import EnumTest # noqa: E501 +from petstore_api.rest import ApiException + +class TestEnumTest(unittest.TestCase): + """EnumTest unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test EnumTest + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.enum_test.EnumTest() # noqa: E501 + if include_optional : + return EnumTest( + enum_string = 'UPPER', + enum_string_required = 'UPPER', + enum_integer = 1, + enum_number = 1.1, + outer_enum = 'placed', + outer_enum_integer = 2, + outer_enum_default_value = 'placed', + outer_enum_integer_default_value = 0 + ) + else : + return EnumTest( + enum_string_required = 'UPPER', + ) + + def testEnumTest(self): + """Test EnumTest""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_fake_api.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_fake_api.py new file mode 100644 index 000000000000..cf074093f90d --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_fake_api.py @@ -0,0 +1,146 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +try: + from unittest.mock import patch +except ImportError: + from mock import patch + +import petstore_api +from petstore_api.api.fake_api import FakeApi # noqa: E501 + + +class TestFakeApi(unittest.TestCase): + """FakeApi unit test stubs""" + + def setUp(self): + self.api = petstore_api.api.fake_api.FakeApi() # noqa: E501 + + def tearDown(self): + pass + + def test_fake_health_get(self): + """Test case for fake_health_get + + Health check endpoint # noqa: E501 + """ + pass + + def test_fake_http_signature_test(self): + """Test case for fake_http_signature_test + + test http signature authentication # noqa: E501 + """ + pass + + def test_fake_outer_boolean_serialize(self): + """Test case for fake_outer_boolean_serialize + + """ + pass + + def test_fake_outer_composite_serialize(self): + """Test case for fake_outer_composite_serialize + + """ + pass + + def test_fake_outer_number_serialize(self): + """Test case for fake_outer_number_serialize + + """ + pass + + def test_fake_outer_string_serialize(self): + """Test case for fake_outer_string_serialize + + """ + pass + + def test_test_body_with_file_schema(self): + """Test case for test_body_with_file_schema + + """ + pass + + def test_test_body_with_query_params(self): + """Test case for test_body_with_query_params + + """ + pass + + def test_test_client_model(self): + """Test case for test_client_model + + To test \"client\" model # noqa: E501 + """ + pass + + def test_test_endpoint_parameters(self): + """Test case for test_endpoint_parameters + + Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501 + """ + pass + + def test_test_enum_parameters(self): + """Test case for test_enum_parameters + + To test enum parameters # noqa: E501 + """ + pass + + def test_test_group_parameters(self): + """Test case for test_group_parameters + + Fake endpoint to test group parameters (optional) # noqa: E501 + """ + pass + + def test_test_inline_additional_properties(self): + """Test case for test_inline_additional_properties + + test inline additionalProperties # noqa: E501 + """ + pass + + def test_test_json_form_data(self): + """Test case for test_json_form_data + + test json serialization of form data # noqa: E501 + """ + pass + + def test_test_query_parameter_collection_format(self): + """Test case for test_query_parameter_collection_format + + """ + pass + + def test_headers_parameter(self): + """Test case for the _headers are passed by the user + + To test any optional parameter # noqa: E501 + """ + api = petstore_api.api.PetApi() + with patch("petstore_api.api_client.ApiClient.call_api") as mock_method: + value_headers = {"Header1": "value1"} + api.find_pets_by_status(["available"], _headers=value_headers) + args, _ = mock_method.call_args + self.assertEqual(args, ('/pet/findByStatus', 'GET', {}, [('status', ['available'])], {'Accept': 'application/json', 'Header1': 'value1'}) +) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_fake_classname_tags123_api.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_fake_classname_tags123_api.py new file mode 100644 index 000000000000..f54e0d06644f --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_fake_classname_tags123_api.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api +from petstore_api.api.fake_classname_tags_123_api import FakeClassnameTags123Api # noqa: E501 +from petstore_api.rest import ApiException + + +class TestFakeClassnameTags123Api(unittest.TestCase): + """FakeClassnameTags123Api unit test stubs""" + + def setUp(self): + self.api = petstore_api.api.fake_classname_tags_123_api.FakeClassnameTags123Api() # noqa: E501 + + def tearDown(self): + pass + + def test_test_classname(self): + """Test case for test_classname + + To test class name in snake case # noqa: E501 + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_fake_classname_tags_123_api.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_fake_classname_tags_123_api.py new file mode 100644 index 000000000000..f54e0d06644f --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_fake_classname_tags_123_api.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api +from petstore_api.api.fake_classname_tags_123_api import FakeClassnameTags123Api # noqa: E501 +from petstore_api.rest import ApiException + + +class TestFakeClassnameTags123Api(unittest.TestCase): + """FakeClassnameTags123Api unit test stubs""" + + def setUp(self): + self.api = petstore_api.api.fake_classname_tags_123_api.FakeClassnameTags123Api() # noqa: E501 + + def tearDown(self): + pass + + def test_test_classname(self): + """Test case for test_classname + + To test class name in snake case # noqa: E501 + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_file.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_file.py new file mode 100644 index 000000000000..3c9b91972d91 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_file.py @@ -0,0 +1,51 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.file import File # noqa: E501 +from petstore_api.rest import ApiException + +class TestFile(unittest.TestCase): + """File unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test File + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.file.File() # noqa: E501 + if include_optional : + return File( + source_uri = '' + ) + else : + return File( + ) + + def testFile(self): + """Test File""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_file_schema_test_class.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_file_schema_test_class.py new file mode 100644 index 000000000000..2834ddc05413 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_file_schema_test_class.py @@ -0,0 +1,56 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.file_schema_test_class import FileSchemaTestClass # noqa: E501 +from petstore_api.rest import ApiException + +class TestFileSchemaTestClass(unittest.TestCase): + """FileSchemaTestClass unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test FileSchemaTestClass + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.file_schema_test_class.FileSchemaTestClass() # noqa: E501 + if include_optional : + return FileSchemaTestClass( + file = petstore_api.models.file.File( + source_uri = '', ), + files = [ + petstore_api.models.file.File( + source_uri = '', ) + ] + ) + else : + return FileSchemaTestClass( + ) + + def testFileSchemaTestClass(self): + """Test FileSchemaTestClass""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_foo.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_foo.py new file mode 100644 index 000000000000..f592b1c37018 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_foo.py @@ -0,0 +1,51 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.foo import Foo # noqa: E501 +from petstore_api.rest import ApiException + +class TestFoo(unittest.TestCase): + """Foo unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test Foo + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.foo.Foo() # noqa: E501 + if include_optional : + return Foo( + bar = 'bar' + ) + else : + return Foo( + ) + + def testFoo(self): + """Test Foo""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_foo_get_default_response.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_foo_get_default_response.py new file mode 100644 index 000000000000..d2cadc258d8e --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_foo_get_default_response.py @@ -0,0 +1,52 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.foo_get_default_response import FooGetDefaultResponse # noqa: E501 +from petstore_api.rest import ApiException + +class TestFooGetDefaultResponse(unittest.TestCase): + """FooGetDefaultResponse unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test FooGetDefaultResponse + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.foo_get_default_response.FooGetDefaultResponse() # noqa: E501 + if include_optional : + return FooGetDefaultResponse( + string = petstore_api.models.foo.Foo( + bar = 'bar', ) + ) + else : + return FooGetDefaultResponse( + ) + + def testFooGetDefaultResponse(self): + """Test FooGetDefaultResponse""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_format_test.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_format_test.py new file mode 100644 index 000000000000..6038ab41357b --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_format_test.py @@ -0,0 +1,71 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.format_test import FormatTest # noqa: E501 +from petstore_api.rest import ApiException + +class TestFormatTest(unittest.TestCase): + """FormatTest unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test FormatTest + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.format_test.FormatTest() # noqa: E501 + if include_optional : + return FormatTest( + integer = 10, + int32 = 20, + int64 = 56, + number = 132.1, + float = 54.3, + double = 67.8, + decimal = 1, + string = 'a', + byte = bytes("someting", 'utf-8'), + binary = bytes(b'blah'), + date = datetime.datetime.strptime('1975-12-30', '%Y-%m-%d').date(), + date_time = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), + uuid = '72f98069-206d-4f12-9f12-3d1e525a8e84', + password = '0123456789', + pattern_with_digits = '0480728880', + pattern_with_digits_and_delimiter = 'image_480' + ) + else : + return FormatTest( + number = 122.1, + byte = bytes("someting", 'utf-8'), + date = datetime.datetime.strptime('1975-12-30', '%Y-%m-%d').date(), + password = '0123456789', + ) + + def testFormatTest(self): + """Test FormatTest""" + inst_req_only = self.make_instance(include_optional=False) + # TODO + #inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_has_only_read_only.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_has_only_read_only.py new file mode 100644 index 000000000000..2a8d2df6a0f8 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_has_only_read_only.py @@ -0,0 +1,52 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.has_only_read_only import HasOnlyReadOnly # noqa: E501 +from petstore_api.rest import ApiException + +class TestHasOnlyReadOnly(unittest.TestCase): + """HasOnlyReadOnly unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test HasOnlyReadOnly + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.has_only_read_only.HasOnlyReadOnly() # noqa: E501 + if include_optional : + return HasOnlyReadOnly( + bar = '', + foo = '' + ) + else : + return HasOnlyReadOnly( + ) + + def testHasOnlyReadOnly(self): + """Test HasOnlyReadOnly""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_health_check_result.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_health_check_result.py new file mode 100644 index 000000000000..21c52053ea22 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_health_check_result.py @@ -0,0 +1,51 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.health_check_result import HealthCheckResult # noqa: E501 +from petstore_api.rest import ApiException + +class TestHealthCheckResult(unittest.TestCase): + """HealthCheckResult unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test HealthCheckResult + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.health_check_result.HealthCheckResult() # noqa: E501 + if include_optional : + return HealthCheckResult( + nullable_message = '' + ) + else : + return HealthCheckResult( + ) + + def testHealthCheckResult(self): + """Test HealthCheckResult""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_inner_dict_with_property.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_inner_dict_with_property.py new file mode 100644 index 000000000000..8a63b70d5524 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_inner_dict_with_property.py @@ -0,0 +1,56 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.inner_dict_with_property import InnerDictWithProperty # noqa: E501 +from petstore_api.rest import ApiException + +class TestInnerDictWithProperty(unittest.TestCase): + """InnerDictWithProperty unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test InnerDictWithProperty + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `InnerDictWithProperty` + """ + model = petstore_api.models.inner_dict_with_property.InnerDictWithProperty() # noqa: E501 + if include_optional : + return InnerDictWithProperty( + a_property = None + ) + else : + return InnerDictWithProperty( + ) + """ + + def testInnerDictWithProperty(self): + """Test InnerDictWithProperty""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_int_or_string.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_int_or_string.py new file mode 100644 index 000000000000..0de76602cb69 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_int_or_string.py @@ -0,0 +1,53 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +import unittest +import datetime + +import petstore_api +from petstore_api.models.int_or_string import IntOrString # noqa: E501 +from petstore_api.rest import ApiException + +class TestIntOrString(unittest.TestCase): + """IntOrString unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test IntOrString + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `IntOrString` + """ + model = petstore_api.models.int_or_string.IntOrString() # noqa: E501 + if include_optional : + return IntOrString( + ) + else : + return IntOrString( + ) + """ + + def testIntOrString(self): + """Test IntOrString""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_list.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_list.py new file mode 100644 index 000000000000..4c603a5e9b1e --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_list.py @@ -0,0 +1,51 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.list import List # noqa: E501 +from petstore_api.rest import ApiException + +class TestList(unittest.TestCase): + """List unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test List + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.list.List() # noqa: E501 + if include_optional : + return List( + _123_list = '' + ) + else : + return List( + ) + + def testList(self): + """Test List""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_map_of_array_of_model.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_map_of_array_of_model.py new file mode 100644 index 000000000000..31ad486f5c03 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_map_of_array_of_model.py @@ -0,0 +1,60 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +import unittest +import datetime + +import petstore_api +from petstore_api.models.map_of_array_of_model import MapOfArrayOfModel # noqa: E501 +from petstore_api.rest import ApiException + +class TestMapOfArrayOfModel(unittest.TestCase): + """MapOfArrayOfModel unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test MapOfArrayOfModel + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `MapOfArrayOfModel` + """ + model = petstore_api.models.map_of_array_of_model.MapOfArrayOfModel() # noqa: E501 + if include_optional : + return MapOfArrayOfModel( + shop_id_to_org_online_lip_map = { + 'key' : [ + petstore_api.models.tag.Tag( + id = 56, + name = '', ) + ] + } + ) + else : + return MapOfArrayOfModel( + ) + """ + + def testMapOfArrayOfModel(self): + """Test MapOfArrayOfModel""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_map_test.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_map_test.py new file mode 100644 index 000000000000..5e11fed312ad --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_map_test.py @@ -0,0 +1,65 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.map_test import MapTest # noqa: E501 +from petstore_api.rest import ApiException + +class TestMapTest(unittest.TestCase): + """MapTest unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test MapTest + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.map_test.MapTest() # noqa: E501 + if include_optional : + return MapTest( + map_map_of_string = { + 'key' : { + 'key' : '' + } + }, + map_of_enum_string = { + 'UPPER' : 'UPPER' + }, + direct_map = { + 'key' : True + }, + indirect_map = { + 'key' : True + } + ) + else : + return MapTest( + ) + + def testMapTest(self): + """Test MapTest""" + # TODO + #inst_req_only = self.make_instance(include_optional=False) + #inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_mixed_properties_and_additional_properties_class.py new file mode 100644 index 000000000000..d217b1143656 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_mixed_properties_and_additional_properties_class.py @@ -0,0 +1,57 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass # noqa: E501 +from petstore_api.rest import ApiException + +class TestMixedPropertiesAndAdditionalPropertiesClass(unittest.TestCase): + """MixedPropertiesAndAdditionalPropertiesClass unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test MixedPropertiesAndAdditionalPropertiesClass + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.mixed_properties_and_additional_properties_class.MixedPropertiesAndAdditionalPropertiesClass() # noqa: E501 + if include_optional : + return MixedPropertiesAndAdditionalPropertiesClass( + uuid = '', + date_time = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), + map = { + 'key' : petstore_api.models.animal.Animal( + class_name = '', + color = 'red', ) + } + ) + else : + return MixedPropertiesAndAdditionalPropertiesClass( + ) + + def testMixedPropertiesAndAdditionalPropertiesClass(self): + """Test MixedPropertiesAndAdditionalPropertiesClass""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_model200_response.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_model200_response.py new file mode 100644 index 000000000000..f7e9677e0074 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_model200_response.py @@ -0,0 +1,52 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.model200_response import Model200Response # noqa: E501 +from petstore_api.rest import ApiException + +class TestModel200Response(unittest.TestCase): + """Model200Response unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test Model200Response + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.model200_response.Model200Response() # noqa: E501 + if include_optional : + return Model200Response( + name = 56, + _class = '' + ) + else : + return Model200Response( + ) + + def testModel200Response(self): + """Test Model200Response""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_model_return.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_model_return.py new file mode 100644 index 000000000000..b0f9d9c4f7f9 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_model_return.py @@ -0,0 +1,51 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.model_return import ModelReturn # noqa: E501 +from petstore_api.rest import ApiException + +class TestModelReturn(unittest.TestCase): + """ModelReturn unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test ModelReturn + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.model_return.ModelReturn() # noqa: E501 + if include_optional : + return ModelReturn( + _return = 56 + ) + else : + return ModelReturn( + ) + + def testModelReturn(self): + """Test ModelReturn""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_name.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_name.py new file mode 100644 index 000000000000..bbf11fd231ea --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_name.py @@ -0,0 +1,55 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.name import Name # noqa: E501 +from petstore_api.rest import ApiException + +class TestName(unittest.TestCase): + """Name unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test Name + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.name.Name() # noqa: E501 + if include_optional : + return Name( + name = 56, + snake_case = 56, + _property = '', + _123_number = 56 + ) + else : + return Name( + name = 56, + ) + + def testName(self): + """Test Name""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_nullable_class.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_nullable_class.py new file mode 100644 index 000000000000..7aa59f46bbd8 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_nullable_class.py @@ -0,0 +1,77 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.nullable_class import NullableClass # noqa: E501 +from petstore_api.rest import ApiException + +class TestNullableClass(unittest.TestCase): + """NullableClass unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test NullableClass + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.nullable_class.NullableClass() # noqa: E501 + if include_optional : + return NullableClass( + required_integer_prop = 56, + integer_prop = 56, + number_prop = 1.337, + boolean_prop = True, + string_prop = '', + date_prop = datetime.datetime.strptime('1975-12-30', '%Y-%m-%d').date(), + datetime_prop = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), + array_nullable_prop = [ + None + ], + array_and_items_nullable_prop = [ + None + ], + array_items_nullable = [ + None + ], + object_nullable_prop = { + 'key' : None + }, + object_and_items_nullable_prop = { + 'key' : None + }, + object_items_nullable = { + 'key' : None + } + ) + else : + return NullableClass( + required_integer_prop = 56 + ) + + def testNullableClass(self): + """Test NullableClass""" + # TODO + #inst_req_only = self.make_instance(include_optional=False) + #inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_nullable_property.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_nullable_property.py new file mode 100644 index 000000000000..34129457b1d7 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_nullable_property.py @@ -0,0 +1,57 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +import unittest +import datetime + +import petstore_api +from petstore_api.models.nullable_property import NullableProperty # noqa: E501 +from petstore_api.rest import ApiException + +class TestNullableProperty(unittest.TestCase): + """NullableProperty unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test NullableProperty + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `NullableProperty` + """ + model = petstore_api.models.nullable_property.NullableProperty() # noqa: E501 + if include_optional : + return NullableProperty( + id = 56, + name = 'AUR,rZ#UM/?R,Fp^l6$ARjbhJk C>' + ) + else : + return NullableProperty( + id = 56, + name = 'AUR,rZ#UM/?R,Fp^l6$ARjbhJk C>', + ) + """ + + def testNullableProperty(self): + """Test NullableProperty""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_number_only.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_number_only.py new file mode 100644 index 000000000000..776946c3d774 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_number_only.py @@ -0,0 +1,51 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.number_only import NumberOnly # noqa: E501 +from petstore_api.rest import ApiException + +class TestNumberOnly(unittest.TestCase): + """NumberOnly unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test NumberOnly + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.number_only.NumberOnly() # noqa: E501 + if include_optional : + return NumberOnly( + just_number = 1.337 + ) + else : + return NumberOnly( + ) + + def testNumberOnly(self): + """Test NumberOnly""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_object_to_test_additional_properties.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_object_to_test_additional_properties.py new file mode 100644 index 000000000000..f1f354cad251 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_object_to_test_additional_properties.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +import unittest +import datetime + +import petstore_api +from petstore_api.models.object_to_test_additional_properties import ObjectToTestAdditionalProperties # noqa: E501 +from petstore_api.rest import ApiException + +class TestObjectToTestAdditionalProperties(unittest.TestCase): + """ObjectToTestAdditionalProperties unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test ObjectToTestAdditionalProperties + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `ObjectToTestAdditionalProperties` + """ + model = petstore_api.models.object_to_test_additional_properties.ObjectToTestAdditionalProperties() # noqa: E501 + if include_optional : + return ObjectToTestAdditionalProperties( + var_property = True + ) + else : + return ObjectToTestAdditionalProperties( + ) + """ + + def testObjectToTestAdditionalProperties(self): + """Test ObjectToTestAdditionalProperties""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_object_with_deprecated_fields.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_object_with_deprecated_fields.py new file mode 100644 index 000000000000..e0cbf3e98a51 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_object_with_deprecated_fields.py @@ -0,0 +1,57 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.object_with_deprecated_fields import ObjectWithDeprecatedFields # noqa: E501 +from petstore_api.rest import ApiException + +class TestObjectWithDeprecatedFields(unittest.TestCase): + """ObjectWithDeprecatedFields unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test ObjectWithDeprecatedFields + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.object_with_deprecated_fields.ObjectWithDeprecatedFields() # noqa: E501 + if include_optional : + return ObjectWithDeprecatedFields( + uuid = '', + id = 1.337, + deprecated_ref = petstore_api.models.deprecated_object.DeprecatedObject( + name = '', ), + bars = [ + 'bar' + ] + ) + else : + return ObjectWithDeprecatedFields( + ) + + def testObjectWithDeprecatedFields(self): + """Test ObjectWithDeprecatedFields""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_one_of_enum_string.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_one_of_enum_string.py new file mode 100644 index 000000000000..ed959c1479c2 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_one_of_enum_string.py @@ -0,0 +1,53 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +import unittest +import datetime + +import petstore_api +from petstore_api.models.one_of_enum_string import OneOfEnumString # noqa: E501 +from petstore_api.rest import ApiException + +class TestOneOfEnumString(unittest.TestCase): + """OneOfEnumString unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test OneOfEnumString + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `OneOfEnumString` + """ + model = petstore_api.models.one_of_enum_string.OneOfEnumString() # noqa: E501 + if include_optional : + return OneOfEnumString( + ) + else : + return OneOfEnumString( + ) + """ + + def testOneOfEnumString(self): + """Test OneOfEnumString""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_order.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_order.py new file mode 100644 index 000000000000..d6ec36f83a0d --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_order.py @@ -0,0 +1,56 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.order import Order # noqa: E501 +from petstore_api.rest import ApiException + +class TestOrder(unittest.TestCase): + """Order unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test Order + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.order.Order() # noqa: E501 + if include_optional : + return Order( + id = 56, + pet_id = 56, + quantity = 56, + ship_date = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), + status = 'placed', + complete = True + ) + else : + return Order( + ) + + def testOrder(self): + """Test Order""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_outer_composite.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_outer_composite.py new file mode 100644 index 000000000000..c6fd58849377 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_outer_composite.py @@ -0,0 +1,53 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.outer_composite import OuterComposite # noqa: E501 +from petstore_api.rest import ApiException + +class TestOuterComposite(unittest.TestCase): + """OuterComposite unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test OuterComposite + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.outer_composite.OuterComposite() # noqa: E501 + if include_optional : + return OuterComposite( + my_number = 1.337, + my_string = '', + my_boolean = True + ) + else : + return OuterComposite( + ) + + def testOuterComposite(self): + """Test OuterComposite""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_outer_enum.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_outer_enum.py new file mode 100644 index 000000000000..aa195260019e --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_outer_enum.py @@ -0,0 +1,36 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.outer_enum import OuterEnum # noqa: E501 +from petstore_api.rest import ApiException + +class TestOuterEnum(unittest.TestCase): + """OuterEnum unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testOuterEnum(self): + """Test OuterEnum""" + inst = OuterEnum("placed") + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_outer_enum_default_value.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_outer_enum_default_value.py new file mode 100644 index 000000000000..f8fba3bd79ad --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_outer_enum_default_value.py @@ -0,0 +1,36 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.outer_enum_default_value import OuterEnumDefaultValue # noqa: E501 +from petstore_api.rest import ApiException + +class TestOuterEnumDefaultValue(unittest.TestCase): + """OuterEnumDefaultValue unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testOuterEnumDefaultValue(self): + """Test OuterEnumDefaultValue""" + # inst = OuterEnumDefaultValue() + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_outer_enum_integer.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_outer_enum_integer.py new file mode 100644 index 000000000000..ce1e47c61b14 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_outer_enum_integer.py @@ -0,0 +1,36 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.outer_enum_integer import OuterEnumInteger # noqa: E501 +from petstore_api.rest import ApiException + +class TestOuterEnumInteger(unittest.TestCase): + """OuterEnumInteger unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testOuterEnumInteger(self): + """Test OuterEnumInteger""" + # inst = OuterEnumInteger() + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_outer_enum_integer_default_value.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_outer_enum_integer_default_value.py new file mode 100644 index 000000000000..f0b707fca778 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_outer_enum_integer_default_value.py @@ -0,0 +1,50 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.outer_enum_integer_default_value import OuterEnumIntegerDefaultValue # noqa: E501 +from petstore_api.rest import ApiException + +class TestOuterEnumIntegerDefaultValue(unittest.TestCase): + """OuterEnumIntegerDefaultValue unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test OuterEnumIntegerDefaultValue + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.outer_enum_integer_default_value.OuterEnumIntegerDefaultValue() # noqa: E501 + if include_optional : + return OuterEnumIntegerDefaultValue( + ) + else : + return OuterEnumIntegerDefaultValue( + ) + + def testOuterEnumIntegerDefaultValue(self): + """Test OuterEnumIntegerDefaultValue""" + #inst_req_only = self.make_instance(include_optional=False) + #inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_outer_object_with_enum_property.py new file mode 100644 index 000000000000..35258d5d74ac --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_outer_object_with_enum_property.py @@ -0,0 +1,52 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.outer_object_with_enum_property import OuterObjectWithEnumProperty # noqa: E501 +from petstore_api.rest import ApiException + +class TestOuterObjectWithEnumProperty(unittest.TestCase): + """OuterObjectWithEnumProperty unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test OuterObjectWithEnumProperty + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.outer_object_with_enum_property.OuterObjectWithEnumProperty() # noqa: E501 + if include_optional : + return OuterObjectWithEnumProperty( + value = 2 + ) + else : + return OuterObjectWithEnumProperty( + value = 2, + ) + + def testOuterObjectWithEnumProperty(self): + """Test OuterObjectWithEnumProperty""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_parent.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_parent.py new file mode 100644 index 000000000000..2a74505f08a1 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_parent.py @@ -0,0 +1,57 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +import unittest +import datetime + +import petstore_api +from petstore_api.models.parent import Parent # noqa: E501 +from petstore_api.rest import ApiException + +class TestParent(unittest.TestCase): + """Parent unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test Parent + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `Parent` + """ + model = petstore_api.models.parent.Parent() # noqa: E501 + if include_optional : + return Parent( + optional_dict = { + 'key' : petstore_api.models.inner_dict_with_property.InnerDictWithProperty( + a_property = petstore_api.models.a_property.aProperty(), ) + } + ) + else : + return Parent( + ) + """ + + def testParent(self): + """Test Parent""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_parent_with_optional_dict.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_parent_with_optional_dict.py new file mode 100644 index 000000000000..25b769e3d390 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_parent_with_optional_dict.py @@ -0,0 +1,59 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict # noqa: E501 +from petstore_api.rest import ApiException + +class TestParentWithOptionalDict(unittest.TestCase): + """ParentWithOptionalDict unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test ParentWithOptionalDict + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `ParentWithOptionalDict` + """ + model = petstore_api.models.parent_with_optional_dict.ParentWithOptionalDict() # noqa: E501 + if include_optional : + return ParentWithOptionalDict( + optional_dict = { + 'key' : petstore_api.models.inner_dict_with_property.InnerDictWithProperty( + a_property = petstore_api.models.a_property.aProperty(), ) + } + ) + else : + return ParentWithOptionalDict( + ) + """ + + def testParentWithOptionalDict(self): + """Test ParentWithOptionalDict""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_pet.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_pet.py new file mode 100644 index 000000000000..6d3fd2f35b04 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_pet.py @@ -0,0 +1,68 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.pet import Pet # noqa: E501 +from petstore_api.rest import ApiException + +class TestPet(unittest.TestCase): + """Pet unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test Pet + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.pet.Pet() # noqa: E501 + if include_optional : + return Pet( + id = 56, + category = petstore_api.models.category.Category( + id = 56, + name = 'default-name', ), + name = 'doggie', + photo_urls = [ + '' + ], + tags = [ + petstore_api.models.tag.Tag( + id = 56, + name = '', ) + ], + status = 'available' + ) + else : + return Pet( + name = 'doggie', + photo_urls = [ + '' + ], + ) + + def testPet(self): + """Test Pet""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_pet_api.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_pet_api.py new file mode 100644 index 000000000000..77665df879f1 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_pet_api.py @@ -0,0 +1,96 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api +from petstore_api.api.pet_api import PetApi # noqa: E501 +from petstore_api.rest import ApiException + + +class TestPetApi(unittest.TestCase): + """PetApi unit test stubs""" + + def setUp(self): + self.api = petstore_api.api.pet_api.PetApi() # noqa: E501 + + def tearDown(self): + pass + + def test_add_pet(self): + """Test case for add_pet + + Add a new pet to the store # noqa: E501 + """ + pass + + def test_delete_pet(self): + """Test case for delete_pet + + Deletes a pet # noqa: E501 + """ + pass + + def test_find_pets_by_status(self): + """Test case for find_pets_by_status + + Finds Pets by status # noqa: E501 + """ + pass + + def test_find_pets_by_tags(self): + """Test case for find_pets_by_tags + + Finds Pets by tags # noqa: E501 + """ + pass + + def test_get_pet_by_id(self): + """Test case for get_pet_by_id + + Find pet by ID # noqa: E501 + """ + pass + + def test_update_pet(self): + """Test case for update_pet + + Update an existing pet # noqa: E501 + """ + pass + + def test_update_pet_with_form(self): + """Test case for update_pet_with_form + + Updates a pet in the store with form data # noqa: E501 + """ + pass + + def test_upload_file(self): + """Test case for upload_file + + uploads an image # noqa: E501 + """ + pass + + def test_upload_file_with_required_file(self): + """Test case for upload_file_with_required_file + + uploads an image (required) # noqa: E501 + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_pig.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_pig.py new file mode 100644 index 000000000000..95e99f35a738 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_pig.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.pig import Pig # noqa: E501 +from petstore_api.rest import ApiException + +class TestPig(unittest.TestCase): + """Pig unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testPig(self): + """Test Pig""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_property_name_collision.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_property_name_collision.py new file mode 100644 index 000000000000..04ab956f191d --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_property_name_collision.py @@ -0,0 +1,56 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +import unittest +import datetime + +import petstore_api +from petstore_api.models.property_name_collision import PropertyNameCollision # noqa: E501 +from petstore_api.rest import ApiException + +class TestPropertyNameCollision(unittest.TestCase): + """PropertyNameCollision unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test PropertyNameCollision + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `PropertyNameCollision` + """ + model = petstore_api.models.property_name_collision.PropertyNameCollision() # noqa: E501 + if include_optional : + return PropertyNameCollision( + underscoreType = '', + type = '', + typeWithUnderscore = '' + ) + else : + return PropertyNameCollision( + ) + """ + + def testPropertyNameCollision(self): + """Test PropertyNameCollision""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_read_only_first.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_read_only_first.py new file mode 100644 index 000000000000..310e4b1aebbe --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_read_only_first.py @@ -0,0 +1,52 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.read_only_first import ReadOnlyFirst # noqa: E501 +from petstore_api.rest import ApiException + +class TestReadOnlyFirst(unittest.TestCase): + """ReadOnlyFirst unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test ReadOnlyFirst + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.read_only_first.ReadOnlyFirst() # noqa: E501 + if include_optional : + return ReadOnlyFirst( + bar = '', + baz = '' + ) + else : + return ReadOnlyFirst( + ) + + def testReadOnlyFirst(self): + """Test ReadOnlyFirst""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_self_reference_model.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_self_reference_model.py new file mode 100644 index 000000000000..b3dd7ada2b2a --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_self_reference_model.py @@ -0,0 +1,60 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.self_reference_model import SelfReferenceModel # noqa: E501 +from petstore_api.rest import ApiException + +class TestSelfReferenceModel(unittest.TestCase): + """SelfReferenceModel unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test SelfReferenceModel + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `SelfReferenceModel` + """ + model = petstore_api.models.self_reference_model.SelfReferenceModel() # noqa: E501 + if include_optional : + return SelfReferenceModel( + size = 56, + nested = petstore_api.models.dummy_model.Dummy-Model( + category = '', + self_ref = petstore_api.models.self_reference_model.Self-Reference-Model( + size = 56, + nested = petstore_api.models.dummy_model.Dummy-Model( + category = '', ), ), ) + ) + else : + return SelfReferenceModel( + ) + """ + + def testSelfReferenceModel(self): + """Test SelfReferenceModel""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_single_ref_type.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_single_ref_type.py new file mode 100644 index 000000000000..888a1a7b6da3 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_single_ref_type.py @@ -0,0 +1,50 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.single_ref_type import SingleRefType # noqa: E501 +from petstore_api.rest import ApiException + +class TestSingleRefType(unittest.TestCase): + """SingleRefType unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test SingleRefType + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.single_ref_type.SingleRefType() # noqa: E501 + if include_optional : + return SingleRefType( + ) + else : + return SingleRefType( + ) + + def testSingleRefType(self): + """Test SingleRefType""" + #inst_req_only = self.make_instance(include_optional=False) + #inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_special_character_enum.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_special_character_enum.py new file mode 100644 index 000000000000..028f55599e49 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_special_character_enum.py @@ -0,0 +1,36 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.special_character_enum import SpecialCharacterEnum # noqa: E501 +from petstore_api.rest import ApiException + +class TestSpecialCharacterEnum(unittest.TestCase): + """SpecialCharacterEnum unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testSpecialCharacterEnum(self): + """Test SpecialCharacterEnum""" + # inst = SpecialCharacterEnum() + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_special_model_name.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_special_model_name.py new file mode 100644 index 000000000000..eb487cd42fc1 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_special_model_name.py @@ -0,0 +1,51 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.special_model_name import SpecialModelName # noqa: E501 +from petstore_api.rest import ApiException + +class TestSpecialModelName(unittest.TestCase): + """SpecialModelName unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test SpecialModelName + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.special_model_name.SpecialModelName() # noqa: E501 + if include_optional : + return SpecialModelName( + special_property_name = 56 + ) + else : + return SpecialModelName( + ) + + def testSpecialModelName(self): + """Test SpecialModelName""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_special_name.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_special_name.py new file mode 100644 index 000000000000..1f4287871a8e --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_special_name.py @@ -0,0 +1,58 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.special_name import SpecialName # noqa: E501 +from petstore_api.rest import ApiException + +class TestSpecialName(unittest.TestCase): + """SpecialName unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test SpecialName + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `SpecialName` + """ + model = petstore_api.models.special_name.SpecialName() # noqa: E501 + if include_optional : + return SpecialName( + var_property = 56, + var_async = petstore_api.models.category.Category( + id = 56, + name = 'default-name', ), + status = 'available' + ) + else : + return SpecialName( + ) + """ + + def testSpecialName(self): + """Test SpecialName""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_store_api.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_store_api.py new file mode 100644 index 000000000000..81848d24a67e --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_store_api.py @@ -0,0 +1,61 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api +from petstore_api.api.store_api import StoreApi # noqa: E501 +from petstore_api.rest import ApiException + + +class TestStoreApi(unittest.TestCase): + """StoreApi unit test stubs""" + + def setUp(self): + self.api = petstore_api.api.store_api.StoreApi() # noqa: E501 + + def tearDown(self): + pass + + def test_delete_order(self): + """Test case for delete_order + + Delete purchase order by ID # noqa: E501 + """ + pass + + def test_get_inventory(self): + """Test case for get_inventory + + Returns pet inventories by status # noqa: E501 + """ + pass + + def test_get_order_by_id(self): + """Test case for get_order_by_id + + Find purchase order by ID # noqa: E501 + """ + pass + + def test_place_order(self): + """Test case for place_order + + Place an order for a pet # noqa: E501 + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_tag.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_tag.py new file mode 100644 index 000000000000..9680300032f1 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_tag.py @@ -0,0 +1,52 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.tag import Tag # noqa: E501 +from petstore_api.rest import ApiException + +class TestTag(unittest.TestCase): + """Tag unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test Tag + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.tag.Tag() # noqa: E501 + if include_optional : + return Tag( + id = 56, + name = '' + ) + else : + return Tag( + ) + + def testTag(self): + """Test Tag""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_tiger.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_tiger.py new file mode 100644 index 000000000000..83c91cea1a0d --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_tiger.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +import unittest +import datetime + +import petstore_api +from petstore_api.models.tiger import Tiger # noqa: E501 +from petstore_api.rest import ApiException + +class TestTiger(unittest.TestCase): + """Tiger unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test Tiger + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `Tiger` + """ + model = petstore_api.models.tiger.Tiger() # noqa: E501 + if include_optional : + return Tiger( + skill = '' + ) + else : + return Tiger( + ) + """ + + def testTiger(self): + """Test Tiger""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_user.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_user.py new file mode 100644 index 000000000000..174c8e06be5d --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_user.py @@ -0,0 +1,58 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.user import User # noqa: E501 +from petstore_api.rest import ApiException + +class TestUser(unittest.TestCase): + """User unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test User + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.user.User() # noqa: E501 + if include_optional : + return User( + id = 56, + username = '', + first_name = '', + last_name = '', + email = '', + password = '', + phone = '', + user_status = 56 + ) + else : + return User( + ) + + def testUser(self): + """Test User""" + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_user_api.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_user_api.py new file mode 100644 index 000000000000..6df730fba2b1 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_user_api.py @@ -0,0 +1,89 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api +from petstore_api.api.user_api import UserApi # noqa: E501 +from petstore_api.rest import ApiException + + +class TestUserApi(unittest.TestCase): + """UserApi unit test stubs""" + + def setUp(self): + self.api = petstore_api.api.user_api.UserApi() # noqa: E501 + + def tearDown(self): + pass + + def test_create_user(self): + """Test case for create_user + + Create user # noqa: E501 + """ + pass + + def test_create_users_with_array_input(self): + """Test case for create_users_with_array_input + + Creates list of users with given input array # noqa: E501 + """ + pass + + def test_create_users_with_list_input(self): + """Test case for create_users_with_list_input + + Creates list of users with given input array # noqa: E501 + """ + pass + + def test_delete_user(self): + """Test case for delete_user + + Delete user # noqa: E501 + """ + pass + + def test_get_user_by_name(self): + """Test case for get_user_by_name + + Get user by user name # noqa: E501 + """ + pass + + def test_login_user(self): + """Test case for login_user + + Logs user into the system # noqa: E501 + """ + pass + + def test_logout_user(self): + """Test case for logout_user + + Logs out current logged in user session # noqa: E501 + """ + pass + + def test_update_user(self): + """Test case for update_user + + Updated user # noqa: E501 + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test/test_with_nested_one_of.py b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_with_nested_one_of.py new file mode 100644 index 000000000000..994004dd7ab7 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test/test_with_nested_one_of.py @@ -0,0 +1,52 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest +import datetime + +import petstore_api +from petstore_api.models.with_nested_one_of import WithNestedOneOf # noqa: E501 +from petstore_api.rest import ApiException + +class TestWithNestedOneOf(unittest.TestCase): + """WithNestedOneOf unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test WithNestedOneOf + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # model = petstore_api.models.with_nested_one_of.WithNestedOneOf() # noqa: E501 + if include_optional : + return WithNestedOneOf( + size = 56, + nested_pig = None + ) + else : + return WithNestedOneOf( + ) + + def testWithNestedOneOf(self): + """Test WithNestedOneOf""" + #inst_req_only = self.make_instance(include_optional=False) + #inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/test_python3.sh b/samples/openapi3/client/petstore/python-pydantic-v2/test_python3.sh new file mode 100755 index 000000000000..f617f3adfa64 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/test_python3.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +REQUIREMENTS_FILE=dev-requirements.txt +REQUIREMENTS_OUT=dev-requirements.txt.log +SETUP_OUT=*.egg-info +VENV=venv +DEACTIVE=false + +export LC_ALL=en_US.UTF-8 +export LANG=en_US.UTF-8 + +### set virtualenv +if [ -z "$VIRTUAL_ENV" ]; then + virtualenv $VENV --always-copy + source $VENV/bin/activate + DEACTIVE=true +fi + +### install dependencies +pip install -r $REQUIREMENTS_FILE | tee -a $REQUIREMENTS_OUT + +### run tests +tox || exit 1 + +### static analysis of code +#flake8 --show-source petstore_api/ + +### deactivate virtualenv +#if [ $DEACTIVE == true ]; then +# deactivate +#fi diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/testfiles/pix.gif b/samples/openapi3/client/petstore/python-pydantic-v2/testfiles/pix.gif new file mode 100644 index 000000000000..f191b280ce91 Binary files /dev/null and b/samples/openapi3/client/petstore/python-pydantic-v2/testfiles/pix.gif differ diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/tests/__init__.py b/samples/openapi3/client/petstore/python-pydantic-v2/tests/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_api_client.py b/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_api_client.py new file mode 100644 index 000000000000..318545d6e8f5 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_api_client.py @@ -0,0 +1,261 @@ +# coding: utf-8 + +# flake8: noqa + +""" +Run the tests. +$ pip install -U pytest +$ cd OpenAPIetstore-python +$ pytest +""" + +import os +import time +import atexit +import weakref +import unittest +from dateutil.parser import parse + +import petstore_api +import petstore_api.configuration + +HOST = 'http://petstore.swagger.io/v2' + + +class ApiClientTests(unittest.TestCase): + + def setUp(self): + self.api_client = petstore_api.ApiClient() + + def test_configuration(self): + config = petstore_api.Configuration() + + config.api_key['api_key'] = '123456' + config.api_key_prefix['api_key'] = 'PREFIX' + config.username = 'test_username' + config.password = 'test_password' + + header_params = {'test1': 'value1'} + query_params = {'test2': 'value2'} + auth_settings = ['api_key', 'unknown'] + + client = petstore_api.ApiClient(config) + + # test prefix + self.assertEqual('PREFIX', client.configuration.api_key_prefix['api_key']) + + # update parameters based on auth setting + client.update_params_for_auth(header_params, query_params, + auth_settings, + None, None, None) + + # test api key auth + self.assertEqual(header_params['test1'], 'value1') + self.assertEqual(header_params['api_key'], 'PREFIX 123456') + self.assertEqual(query_params['test2'], 'value2') + + # test basic auth + self.assertEqual('test_username', client.configuration.username) + self.assertEqual('test_password', client.configuration.password) + + def test_select_header_accept(self): + accepts = ['APPLICATION/JSON', 'APPLICATION/XML'] + accept = self.api_client.select_header_accept(accepts) + self.assertEqual(accept, 'APPLICATION/JSON') + + accepts = ['application/json', 'application/xml'] + accept = self.api_client.select_header_accept(accepts) + self.assertEqual(accept, 'application/json') + + accepts = ['application/xml', 'application/json'] + accept = self.api_client.select_header_accept(accepts) + self.assertEqual(accept, 'application/json') + + accepts = ['application/xml', 'application/json-patch+json'] + accept = self.api_client.select_header_accept(accepts) + self.assertEqual(accept, 'application/json-patch+json') + + accepts = ['application/xml', 'application/json; charset=utf-8'] + accept = self.api_client.select_header_accept(accepts) + self.assertEqual(accept, 'application/json; charset=utf-8') + + accepts = ['application/xml', 'application/json;format=flowed'] + accept = self.api_client.select_header_accept(accepts) + self.assertEqual(accept, 'application/json;format=flowed') + + accepts = ['text/plain', 'application/xml'] + accept = self.api_client.select_header_accept(accepts) + self.assertEqual(accept, 'text/plain') + + accepts = [] + accept = self.api_client.select_header_accept(accepts) + self.assertEqual(accept, None) + + def test_select_header_content_type(self): + content_types = ['APPLICATION/JSON', 'APPLICATION/XML'] + content_type = self.api_client.select_header_content_type(content_types) + self.assertEqual(content_type, 'APPLICATION/JSON') + + content_types = ['application/json', 'application/xml'] + content_type = self.api_client.select_header_content_type(content_types) + self.assertEqual(content_type, 'application/json') + + content_types = ['application/xml', 'application/json'] + content_type = self.api_client.select_header_content_type(content_types) + self.assertEqual(content_type, 'application/json') + + content_types = ['application/xml', 'application/json-patch+json'] + content_type = self.api_client.select_header_content_type(content_types) + self.assertEqual(content_type, 'application/json-patch+json') + + content_types = ['application/xml', 'application/json; charset=utf-8'] + content_type = self.api_client.select_header_content_type(content_types) + self.assertEqual(content_type, 'application/json; charset=utf-8') + + content_types = ['application/xml', 'application/json;format=flowed'] + content_type = self.api_client.select_header_content_type(content_types) + self.assertEqual(content_type, 'application/json;format=flowed') + + content_types = ['text/plain', 'application/xml'] + content_type = self.api_client.select_header_content_type(content_types) + self.assertEqual(content_type, 'text/plain') + + # no content type, default to None + content_types = [] + content_type = self.api_client.select_header_content_type(content_types) + self.assertEqual(content_type, None) + + def test_sanitize_for_serialization(self): + # None + data = None + result = self.api_client.sanitize_for_serialization(None) + self.assertEqual(result, data) + + # str + data = "test string" + result = self.api_client.sanitize_for_serialization(data) + self.assertEqual(result, data) + + # int + data = 1 + result = self.api_client.sanitize_for_serialization(data) + self.assertEqual(result, data) + + # bool + data = True + result = self.api_client.sanitize_for_serialization(data) + self.assertEqual(result, data) + + # date + data = parse("1997-07-16").date() # date + result = self.api_client.sanitize_for_serialization(data) + self.assertEqual(result, "1997-07-16") + + # datetime + data = parse("1997-07-16T19:20:30.45+01:00") # datetime + result = self.api_client.sanitize_for_serialization(data) + self.assertEqual(result, "1997-07-16T19:20:30.450000+01:00") + + # list + data = [1] + result = self.api_client.sanitize_for_serialization(data) + self.assertEqual(result, data) + + # dict + data = {"test key": "test value"} + result = self.api_client.sanitize_for_serialization(data) + self.assertEqual(result, data) + + # model + pet_dict = {"id": 1, "name": "monkey", + "category": {"id": 1, "name": "test category"}, + "tags": [{"id": 1, "name": "test tag1"}, + {"id": 2, "name": "test tag2"}], + "status": "available", + "photoUrls": ["http://foo.bar.com/3", + "http://foo.bar.com/4"]} + pet = petstore_api.Pet(name=pet_dict["name"], photo_urls=pet_dict["photoUrls"]) + pet.id = pet_dict["id"] + cate = petstore_api.Category(name="something") + cate.id = pet_dict["category"]["id"] + cate.name = pet_dict["category"]["name"] + pet.category = cate + tag1 = petstore_api.Tag() + tag1.id = pet_dict["tags"][0]["id"] + tag1.name = pet_dict["tags"][0]["name"] + tag2 = petstore_api.Tag() + tag2.id = pet_dict["tags"][1]["id"] + tag2.name = pet_dict["tags"][1]["name"] + pet.tags = [tag1, tag2] + pet.status = pet_dict["status"] + + data = pet + result = self.api_client.sanitize_for_serialization(data) + self.assertEqual(result, pet_dict) + + # list of models + list_of_pet_dict = [pet_dict] + data = [pet] + result = self.api_client.sanitize_for_serialization(data) + self.assertEqual(result, list_of_pet_dict) + + def test_context_manager_closes_threadpool(self): + with petstore_api.ApiClient() as client: + self.assertIsNotNone(client.pool) + pool_ref = weakref.ref(client._pool) + self.assertIsNotNone(pool_ref()) + self.assertIsNone(pool_ref()) + + def test_atexit_closes_threadpool(self): + client = petstore_api.ApiClient() + self.assertIsNotNone(client.pool) + self.assertIsNotNone(client._pool) + atexit._run_exitfuncs() + self.assertIsNone(client._pool) + + def test_parameters_to_url_query(self): + data = 'value={"category": "example", "category2": "example2"}' + dictionary = { + "category": "example", + "category2": "example2" + } + result = self.api_client.parameters_to_url_query([('value', dictionary)], {}) + self.assertEqual(result, "value=%7B%22category%22%3A%20%22example%22%2C%20%22category2%22%3A%20%22example2%22%7D") + + data='value={"number": 1, "string": "str", "bool": true, "dict": {"number": 1, "string": "str", "bool": true}}' + dictionary = { + "number": 1, + "string": "str", + "bool": True, + "dict": { + "number": 1, + "string": "str", + "bool": True + } + } + result = self.api_client.parameters_to_url_query([('value', dictionary)], {}) + self.assertEqual(result, 'value=%7B%22number%22%3A%201%2C%20%22string%22%3A%20%22str%22%2C%20%22bool%22%3A%20true%2C%20%22dict%22%3A%20%7B%22number%22%3A%201%2C%20%22string%22%3A%20%22str%22%2C%20%22bool%22%3A%20true%7D%7D') + + data='value={"strValues": ["one", "two", "three"], "dictValues": [{"name": "value1", "age": 14}, {"name": "value2", "age": 12}]}' + dictionary = { + "strValues": [ + "one", + "two", + "three" + ], + "dictValues": [ + { + "name": "value1", + "age": 14 + }, + { + "name": "value2", + "age": 12 + }, + ] + } + result = self.api_client.parameters_to_url_query([('value', dictionary)], {}) + self.assertEqual(result, 'value=%7B%22strValues%22%3A%20%5B%22one%22%2C%20%22two%22%2C%20%22three%22%5D%2C%20%22dictValues%22%3A%20%5B%7B%22name%22%3A%20%22value1%22%2C%20%22age%22%3A%2014%7D%2C%20%7B%22name%22%3A%20%22value2%22%2C%20%22age%22%3A%2012%7D%5D%7D') + + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_api_exception.py b/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_api_exception.py new file mode 100644 index 000000000000..73915b0d5fca --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_api_exception.py @@ -0,0 +1,82 @@ +# coding: utf-8 + +# flake8: noqa + +""" +Run the tests. +$ pip install -U pytest +$ cd petstore_api-python +$ pytest +""" + +import os +import six +import sys +import unittest + +import petstore_api +from petstore_api.rest import ApiException + +from .util import id_gen + + +class ApiExceptionTests(unittest.TestCase): + + def setUp(self): + self.api_client = petstore_api.ApiClient() + self.pet_api = petstore_api.PetApi(self.api_client) + self.setUpModels() + + def setUpModels(self): + self.category = petstore_api.Category(name="dog") + self.category.id = id_gen() + self.category.name = "dog" + self.tag = petstore_api.Tag() + self.tag.id = id_gen() + self.tag.name = "blank" + self.pet = petstore_api.Pet(name="hello kity", photo_urls=["http://foo.bar.com/1", "http://foo.bar.com/2"]) + self.pet.id = id_gen() + self.pet.status = "sold" + self.pet.category = self.category + self.pet.tags = [self.tag] + + def test_404_error(self): + self.pet_api.add_pet(self.pet) + self.pet_api.delete_pet(pet_id=self.pet.id) + + with self.checkRaiseRegex(ApiException, "Pet not found"): + self.pet_api.get_pet_by_id(pet_id=self.pet.id) + + try: + self.pet_api.get_pet_by_id(pet_id=self.pet.id) + except ApiException as e: + self.assertEqual(e.status, 404) + self.assertEqual(e.reason, "Not Found") + self.checkRegex(e.body, "Pet not found") + + def test_500_error(self): + self.pet_api.add_pet(self.pet) + + with self.checkRaiseRegex(ApiException, "Internal Server Error"): + self.pet_api.upload_file( + pet_id=self.pet.id, + additional_metadata="special", + file=None + ) + + try: + self.pet_api.upload_file( + pet_id=self.pet.id, + additional_metadata="special", + file=None + ) + except ApiException as e: + self.assertEqual(e.status, 500) + self.assertEqual(e.reason, "Internal Server Error") + self.checkRegex(e.body, "Error 500 Internal Server Error") + + def checkRaiseRegex(self, expected_exception, expected_regex): + return self.assertRaisesRegex(expected_exception, expected_regex) + + def checkRegex(self, text, expected_regex): + return self.assertRegex(text, expected_regex) diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_api_validation.py b/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_api_validation.py new file mode 100644 index 000000000000..dc7da96329c0 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_api_validation.py @@ -0,0 +1,79 @@ +# coding: utf-8 + +# flake8: noqa + +""" +Run the tests. +$ pip install -U pytest +$ cd petstore_api-python +$ pytest +""" + +import os +import six +import sys +import unittest + +import petstore_api +from petstore_api.rest import ApiException +from pydantic import BaseModel, ValidationError + +from .util import id_gen + + +class ApiExceptionTests(unittest.TestCase): + + def setUp(self): + self.api_client = petstore_api.ApiClient() + self.pet_api = petstore_api.PetApi(self.api_client) + self.setUpModels() + + def setUpModels(self): + self.category = petstore_api.Category(name="dog") + self.category.id = id_gen() + self.category.name = "dog" + self.tag = petstore_api.Tag() + self.tag.id = id_gen() + self.tag.name = "blank" + self.pet = petstore_api.Pet(name="hello kity", photo_urls=["http://foo.bar.com/1", "http://foo.bar.com/2"]) + self.pet.id = id_gen() + self.pet.status = "sold" + self.pet.category = self.category + self.pet.tags = [self.tag] + + def test_set_param_validation(self): + try: + self.pet_api.find_pets_by_tags(["a", "a"]) + except ValidationError as e: + self.assertTrue("the list has duplicated items" in str(e)) + + def test_required_param_validation(self): + try: + self.pet_api.get_pet_by_id() + except ValidationError as e: + self.assertEqual(str(e), "1 validation error for GetPetById\n" + "pet_id\n" + " field required (type=value_error.missing)") + + def test_integer_validation(self): + try: + self.pet_api.get_pet_by_id("123") + except ValidationError as e: + self.assertEqual(str(e), "1 validation error for GetPetById\n" + "pet_id\n" + " value is not a valid integer (type=type_error.integer)") + + def test_string_enum_validation(self): + try: + self.pet_api.find_pets_by_status(["Cat"]) + except ValidationError as e: + self.assertEqual(str(e), "1 validation error for FindPetsByStatus\n" + "status -> 0\n" + " unexpected value; permitted: 'available', 'pending', 'sold' (" + "type=value_error.const; given=Cat; permitted=('available', 'pending', 'sold'))") + + def checkRaiseRegex(self, expected_exception, expected_regex): + return self.assertRaisesRegex(expected_exception, expected_regex) + + def checkRegex(self, text, expected_regex): + return self.assertRegex(text, expected_regex) diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_configuration.py b/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_configuration.py new file mode 100644 index 000000000000..04c2781f5e29 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_configuration.py @@ -0,0 +1,62 @@ +# coding: utf-8 + +# flake8: noqa + +""" +Run the tests. +$ pip install -U pytest +$ cd petstore_api-python +$ pytest +""" +from __future__ import absolute_import + +import unittest + +import petstore_api + + +class TestConfiguration(unittest.TestCase): + """Animal unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + # reset Configuration + petstore_api.Configuration.set_default(None) + + def testConfiguration(self): + # check that different instances use different dictionaries + c1 = petstore_api.Configuration() + c2 = petstore_api.Configuration() + self.assertNotEqual(id(c1), id(c2)) + self.assertNotEqual(id(c1.api_key), id(c2.api_key)) + self.assertNotEqual(id(c1.api_key_prefix), id(c2.api_key_prefix)) + + def testDefaultConfiguration(self): + # prepare default configuration + c1 = petstore_api.Configuration(host="example.com") + c1.debug = True + petstore_api.Configuration.set_default(c1) + + # get default configuration + c2 = petstore_api.Configuration.get_default_copy() + self.assertEqual(c2.host, "example.com") + self.assertTrue(c2.debug) + + self.assertEqual(id(c1), id(c2)) + self.assertEqual(id(c1.api_key), id(c2.api_key)) + self.assertEqual(id(c1.api_key_prefix), id(c2.api_key_prefix)) + + def testApiClientDefaultConfiguration(self): + # ensure the default configuration is the same + p1 = petstore_api.PetApi() + p2 = petstore_api.PetApi() + self.assertEqual(id(p1.api_client.configuration), id(p2.api_client.configuration)) + + def testAccessTokenWhenConstructingConfiguration(self): + c1 = petstore_api.Configuration(access_token="12345") + self.assertEqual(c1.access_token, "12345") + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_deserialization.py b/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_deserialization.py new file mode 100644 index 000000000000..c5fb68663821 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_deserialization.py @@ -0,0 +1,295 @@ +# coding: utf-8 + +# flake8: noqa + +""" +Run the tests. +$ pip install -U pytest +$ cd OpenAPIPetstore-python +$ pytest +""" +from collections import namedtuple +import json +import os +import time +import unittest +import datetime + +import pytest as pytest + +import petstore_api + +MockResponse = namedtuple('MockResponse', 'data') + + +class DeserializationTests(unittest.TestCase): + + def setUp(self): + self.api_client = petstore_api.ApiClient() + self.deserialize = self.api_client.deserialize + + def test_enum_test(self): + """ deserialize Dict[str, EnumTest] """ + data = { + 'enum_test': { + "enum_string": "UPPER", + "enum_string_required": "lower", + "enum_integer": 1, + "enum_number": 1.1, + "outerEnum": "placed" + } + } + response = MockResponse(data=json.dumps(data)) + + deserialized = self.deserialize(response, 'Dict[str, EnumTest]') + self.assertTrue(isinstance(deserialized, dict)) + self.assertTrue(isinstance(deserialized['enum_test'], petstore_api.EnumTest)) + self.assertEqual(deserialized['enum_test'], + petstore_api.EnumTest(enum_string="UPPER", + enum_string_required="lower", + enum_integer=1, + enum_number=1.1, + outer_enum=petstore_api.OuterEnum.PLACED)) + + def test_deserialize_dict_str_pet(self): + """ deserialize Dict[str, Pet] """ + data = { + 'pet': { + "id": 0, + "category": { + "id": 0, + "name": "string" + }, + "name": "doggie", + "photoUrls": [ + "string" + ], + "tags": [ + { + "id": 0, + "name": "string" + } + ], + "status": "available" + } + } + response = MockResponse(data=json.dumps(data)) + + deserialized = self.deserialize(response, 'Dict[str, Pet]') + self.assertTrue(isinstance(deserialized, dict)) + self.assertTrue(isinstance(deserialized['pet'], petstore_api.Pet)) + + @pytest.mark.skip(reason="skipping for now as deserialization will be refactored") + def test_deserialize_dict_str_dog(self): + """ deserialize Dict[str, Animal], use discriminator""" + data = { + 'dog': { + "id": 0, + "className": "Dog", + "color": "white", + "bread": "Jack Russel Terrier" + } + } + response = MockResponse(data=json.dumps(data)) + + deserialized = self.deserialize(response, 'Dict[str, Animal]') + self.assertTrue(isinstance(deserialized, dict)) + self.assertTrue(isinstance(deserialized['dog'], petstore_api.Dog)) + + @pytest.mark.skip(reason="skipping for now as deserialization will be refactored") + def test_deserialize_dict_str_int(self): + """ deserialize Dict[str, int] """ + data = { + 'integer': 1 + } + response = MockResponse(data=json.dumps(data)) + + deserialized = self.deserialize(response, 'Dict[str, int]') + self.assertTrue(isinstance(deserialized, dict)) + self.assertTrue(isinstance(deserialized['integer'], int)) + + def test_deserialize_str(self): + """ deserialize str """ + data = "test str" + response = MockResponse(data=json.dumps(data)) + + deserialized = self.deserialize(response, "str") + self.assertTrue(isinstance(deserialized, str)) + + def test_deserialize_date(self): + """ deserialize date """ + data = "1997-07-16" + response = MockResponse(data=json.dumps(data)) + + deserialized = self.deserialize(response, "date") + self.assertTrue(isinstance(deserialized, datetime.date)) + + def test_deserialize_datetime(self): + """ deserialize datetime """ + data = "1997-07-16T19:20:30.45+01:00" + response = MockResponse(data=json.dumps(data)) + + deserialized = self.deserialize(response, "datetime") + self.assertTrue(isinstance(deserialized, datetime.datetime)) + + def test_deserialize_pet(self): + """ deserialize pet """ + data = { + "id": 0, + "category": { + "id": 0, + "name": "string" + }, + "name": "doggie", + "photoUrls": [ + "string" + ], + "tags": [ + { + "id": 0, + "name": "string" + } + ], + "status": "available" + } + response = MockResponse(data=json.dumps(data)) + + deserialized = self.deserialize(response, "Pet") + self.assertTrue(isinstance(deserialized, petstore_api.Pet)) + self.assertEqual(deserialized.id, 0) + self.assertEqual(deserialized.name, "doggie") + self.assertTrue(isinstance(deserialized.category, petstore_api.Category)) + self.assertEqual(deserialized.category.name, "string") + self.assertTrue(isinstance(deserialized.tags, list)) + self.assertEqual(deserialized.tags[0].name, "string") + + def test_deserialize_list_of_pet(self): + """ deserialize list[Pet] """ + data = [ + { + "id": 0, + "category": { + "id": 0, + "name": "string" + }, + "name": "doggie0", + "photoUrls": [ + "string" + ], + "tags": [ + { + "id": 0, + "name": "string" + } + ], + "status": "available" + }, + { + "id": 1, + "category": { + "id": 0, + "name": "string" + }, + "name": "doggie1", + "photoUrls": [ + "string" + ], + "tags": [ + { + "id": 0, + "name": "string" + } + ], + "status": "available" + }] + response = MockResponse(data=json.dumps(data)) + + deserialized = self.deserialize(response, "List[Pet]") + self.assertTrue(isinstance(deserialized, list)) + self.assertTrue(isinstance(deserialized[0], petstore_api.Pet)) + self.assertEqual(deserialized[0].id, 0) + self.assertEqual(deserialized[1].id, 1) + self.assertEqual(deserialized[0].name, "doggie0") + self.assertEqual(deserialized[1].name, "doggie1") + + def test_deserialize_nested_dict(self): + """ deserialize Dict[str, Dict[str, int]] """ + data = { + "foo": { + "bar": 1 + } + } + response = MockResponse(data=json.dumps(data)) + + deserialized = self.deserialize(response, "Dict[str, Dict[str, int]]") + self.assertTrue(isinstance(deserialized, dict)) + self.assertTrue(isinstance(deserialized["foo"], dict)) + self.assertTrue(isinstance(deserialized["foo"]["bar"], int)) + + def test_deserialize_nested_list(self): + """ deserialize list[list[str]] """ + data = [["foo"]] + response = MockResponse(data=json.dumps(data)) + + deserialized = self.deserialize(response, "List[List[str]]") + self.assertTrue(isinstance(deserialized, list)) + self.assertTrue(isinstance(deserialized[0], list)) + self.assertTrue(isinstance(deserialized[0][0], str)) + + def test_deserialize_none(self): + """ deserialize None """ + response = MockResponse(data=json.dumps(None)) + + deserialized = self.deserialize(response, "datetime") + self.assertIsNone(deserialized) + + def test_deserialize_pig(self): + """ deserialize pig (oneOf) """ + data = { + "className": "BasqueBig", + "color": "white" + } + + response = MockResponse(data=json.dumps(data)) + deserialized = self.deserialize(response, "Pig") + self.assertTrue(isinstance(deserialized.actual_instance, + petstore_api.BasquePig)) + self.assertEqual(deserialized.actual_instance.class_name, "BasqueBig") + self.assertEqual(deserialized.actual_instance.color, "white") + + def test_deserialize_animal(self): + """ deserialize animal with discriminator mapping """ + data = { + "declawed": True, + "className": "Cat2222" # incorrect class name + } + + response = MockResponse(data=json.dumps(data)) + + with pytest.raises(ValueError) as ex: + deserialized = self.deserialize(response, "Animal") + assert str( + ex.value) == 'Animal failed to lookup discriminator value from {"declawed": true, "className": ' \ + '"Cat2222"}. Discriminator property name: className, mapping: {"Cat": "Cat", "Dog": "Dog"}' + + data = { + "declawed": True, + "className": "Cat" # correct class name + } + + response = MockResponse(data=json.dumps(data)) + + deserialized = self.deserialize(response, "Animal") + self.assertTrue(isinstance(deserialized, petstore_api.Cat)) + self.assertEqual(deserialized.class_name, "Cat") + self.assertEqual(deserialized.declawed, True) + self.assertEqual(deserialized.to_json(), '{"className": "Cat", "color": "red", "declawed": true}') + + # test from json + json_str = '{"className": "Cat", "color": "red", "declawed": true}' + + deserialized = petstore_api.Animal.from_json(json_str) + self.assertTrue(isinstance(deserialized, petstore_api.Cat)) + self.assertEqual(deserialized.class_name, "Cat") + self.assertEqual(deserialized.declawed, True) + self.assertEqual(deserialized.to_json(), '{"className": "Cat", "color": "red", "declawed": true}') diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_http_signature.py b/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_http_signature.py new file mode 100644 index 000000000000..2784d3ac1d0b --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_http_signature.py @@ -0,0 +1,521 @@ +# coding: utf-8 + +# flake8: noqa + +""" +Run the tests. +$ docker pull swaggerapi/petstore +$ docker run -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore +$ cd petstore_api-python +$ pytest +""" + +from collections import namedtuple +from datetime import datetime, timedelta +import base64 +import json +import os +import re +import shutil +import unittest +from urllib.parse import urlencode, urlparse + +from Crypto.Hash import SHA256, SHA512 +from Crypto.PublicKey import ECC, RSA +from Crypto.Signature import pkcs1_15, pss, DSS + +import petstore_api +#from petstore_api.models import Category, Tag, Pet +from petstore_api.api.pet_api import PetApi +from petstore_api import Configuration, signing +from petstore_api.rest import ( + RESTClientObject, + RESTResponse +) + +from petstore_api.exceptions import ( + ApiException, + ApiValueError, + ApiTypeError, +) + +from .util import id_gen + +import urllib3 + +from unittest.mock import patch + +HOST = 'http://localhost/v2' + +# This test RSA private key below is published in Appendix C 'Test Values' of +# https://www.ietf.org/id/draft-cavage-http-signatures-12.txt +RSA_TEST_PRIVATE_KEY = """-----BEGIN RSA PRIVATE KEY----- +MIICXgIBAAKBgQDCFENGw33yGihy92pDjZQhl0C36rPJj+CvfSC8+q28hxA161QF +NUd13wuCTUcq0Qd2qsBe/2hFyc2DCJJg0h1L78+6Z4UMR7EOcpfdUE9Hf3m/hs+F +UR45uBJeDK1HSFHD8bHKD6kv8FPGfJTotc+2xjJwoYi+1hqp1fIekaxsyQIDAQAB +AoGBAJR8ZkCUvx5kzv+utdl7T5MnordT1TvoXXJGXK7ZZ+UuvMNUCdN2QPc4sBiA +QWvLw1cSKt5DsKZ8UETpYPy8pPYnnDEz2dDYiaew9+xEpubyeW2oH4Zx71wqBtOK +kqwrXa/pzdpiucRRjk6vE6YY7EBBs/g7uanVpGibOVAEsqH1AkEA7DkjVH28WDUg +f1nqvfn2Kj6CT7nIcE3jGJsZZ7zlZmBmHFDONMLUrXR/Zm3pR5m0tCmBqa5RK95u +412jt1dPIwJBANJT3v8pnkth48bQo/fKel6uEYyboRtA5/uHuHkZ6FQF7OUkGogc +mSJluOdc5t6hI1VsLn0QZEjQZMEOWr+wKSMCQQCC4kXJEsHAve77oP6HtG/IiEn7 +kpyUXRNvFsDE0czpJJBvL/aRFUJxuRK91jhjC68sA7NsKMGg5OXb5I5Jj36xAkEA +gIT7aFOYBFwGgQAQkWNKLvySgKbAZRTeLBacpHMuQdl1DfdntvAyqpAZ0lY0RKmW +G6aFKaqQfOXKCyWoUiVknQJAXrlgySFci/2ueKlIE1QqIiLSZ8V8OlpFLRnb1pzI +7U1yQXnTAEFYM560yJlzUpOb1V4cScGd365tiSMvxLOvTA== +-----END RSA PRIVATE KEY-----""" + + +class TimeoutWithEqual(urllib3.Timeout): + def __init__(self, *arg, **kwargs): + super(TimeoutWithEqual, self).__init__(*arg, **kwargs) + + def __eq__(self, other): + return self._read == other._read and self._connect == other._connect and self.total == other.total + +class MockPoolManager(object): + def __init__(self, tc): + self._tc = tc + self._reqs = [] + + def expect_request(self, *args, **kwargs): + self._reqs.append((args, kwargs)) + + def set_signing_config(self, signing_cfg): + self.signing_cfg = signing_cfg + self._tc.assertIsNotNone(self.signing_cfg) + self.pubkey = self.signing_cfg.get_public_key() + self._tc.assertIsNotNone(self.pubkey) + + def request(self, *actual_request_target, **actual_request_headers_and_body): + self._tc.assertTrue(len(self._reqs) > 0) + expected_results = self._reqs.pop(0) + self._tc.maxDiff = None + expected_request_target = expected_results[0] # The expected HTTP method and URL path. + expected_request_headers_and_body = expected_results[1] # dict that contains the expected body, headers + self._tc.assertEqual(expected_request_target, actual_request_target) + # actual_request_headers_and_body is a dict that contains the actual body, headers + for k, expected in expected_request_headers_and_body.items(): + self._tc.assertIn(k, actual_request_headers_and_body) + if k == 'body': + actual_body = actual_request_headers_and_body[k] + self._tc.assertEqual(expected, actual_body) + elif k == 'headers': + actual_headers = actual_request_headers_and_body[k] + for expected_header_name, expected_header_value in expected.items(): + # Validate the generated request contains the expected header. + self._tc.assertIn(expected_header_name, actual_headers) + actual_header_value = actual_headers[expected_header_name] + # Compare the actual value of the header against the expected value. + pattern = re.compile(expected_header_value) + m = pattern.match(actual_header_value) + self._tc.assertTrue(m, msg="Expected:\n{0}\nActual:\n{1}".format( + expected_header_value,actual_header_value)) + if expected_header_name == 'Authorization': + self._validate_authorization_header( + expected_request_target, actual_headers, actual_header_value) + elif k == 'timeout': + self._tc.assertEqual(expected, actual_request_headers_and_body[k]) + return urllib3.HTTPResponse(status=200, body=b'test') + + def _validate_authorization_header(self, request_target, actual_headers, authorization_header): + """Validate the signature. + """ + # Extract (created) + r1 = re.compile(r'created=([0-9]+)') + m1 = r1.search(authorization_header) + self._tc.assertIsNotNone(m1) + created = m1.group(1) + + # Extract list of signed headers + r1 = re.compile(r'headers="([^"]+)"') + m1 = r1.search(authorization_header) + self._tc.assertIsNotNone(m1) + headers = m1.group(1).split(' ') + signed_headers_list = [] + for h in headers: + if h == '(created)': + signed_headers_list.append((h, created)) + elif h == '(request-target)': + url = request_target[1] + target_path = urlparse(url).path + signed_headers_list.append((h, "{0} {1}".format(request_target[0].lower(), target_path))) + else: + value = next((v for k, v in actual_headers.items() if k.lower() == h), None) + self._tc.assertIsNotNone(value) + signed_headers_list.append((h, value)) + header_items = [ + "{0}: {1}".format(key.lower(), value) for key, value in signed_headers_list] + string_to_sign = "\n".join(header_items) + digest = None + if self.signing_cfg.hash_algorithm == signing.HASH_SHA512: + digest = SHA512.new() + elif self.signing_cfg.hash_algorithm == signing.HASH_SHA256: + digest = SHA256.new() + else: + self._tc.fail("Unsupported hash algorithm: {0}".format(self.signing_cfg.hash_algorithm)) + digest.update(string_to_sign.encode()) + b64_body_digest = base64.b64encode(digest.digest()).decode() + + # Extract the signature + r2 = re.compile(r'signature="([^"]+)"') + m2 = r2.search(authorization_header) + self._tc.assertIsNotNone(m2) + b64_signature = m2.group(1) + signature = base64.b64decode(b64_signature) + # Build the message + signing_alg = self.signing_cfg.signing_algorithm + if signing_alg is None: + # Determine default + if isinstance(self.pubkey, RSA.RsaKey): + signing_alg = signing.ALGORITHM_RSASSA_PSS + elif isinstance(self.pubkey, ECC.EccKey): + signing_alg = signing.ALGORITHM_ECDSA_MODE_FIPS_186_3 + else: + self._tc.fail("Unsupported key: {0}".format(type(self.pubkey))) + + if signing_alg == signing.ALGORITHM_RSASSA_PKCS1v15: + pkcs1_15.new(self.pubkey).verify(digest, signature) + elif signing_alg == signing.ALGORITHM_RSASSA_PSS: + pss.new(self.pubkey).verify(digest, signature) + elif signing_alg == signing.ALGORITHM_ECDSA_MODE_FIPS_186_3: + verifier = DSS.new(key=self.pubkey, mode=signing.ALGORITHM_ECDSA_MODE_FIPS_186_3, + encoding='der') + verifier.verify(digest, signature) + elif signing_alg == signing.ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979: + verifier = DSS.new(key=self.pubkey, mode=signing.ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979, + encoding='der') + verifier.verify(digest, signature) + else: + self._tc.fail("Unsupported signing algorithm: {0}".format(signing_alg)) + +class PetApiTests(unittest.TestCase): + + @classmethod + def setUpClass(cls): + cls.setUpModels() + cls.setUpFiles() + + @classmethod + def tearDownClass(cls): + file_paths = [ + cls.rsa_key_path, + cls.rsa4096_key_path, + cls.ec_p521_key_path, + ] + for file_path in file_paths: + os.unlink(file_path) + + @classmethod + def setUpModels(cls): + cls.category = petstore_api.Category(name="dog") + cls.category.id = id_gen() + cls.tag = petstore_api.Tag() + cls.tag.id = id_gen() + cls.tag.name = "python-pet-tag" + cls.pet = petstore_api.Pet( + name="hello kity", + photo_urls=["http://foo.bar.com/1", "http://foo.bar.com/2"] + ) + cls.pet.id = id_gen() + cls.pet.status = "sold" + cls.pet.category = cls.category + cls.pet.tags = [cls.tag] + + @classmethod + def setUpFiles(cls): + cls.test_file_dir = os.path.join( + os.path.dirname(__file__), "..", "testfiles") + cls.test_file_dir = os.path.realpath(cls.test_file_dir) + if not os.path.exists(cls.test_file_dir): + os.mkdir(cls.test_file_dir) + + cls.private_key_passphrase = 'test-passphrase' + cls.rsa_key_path = os.path.join(cls.test_file_dir, 'rsa.pem') + cls.rsa4096_key_path = os.path.join(cls.test_file_dir, 'rsa4096.pem') + cls.ec_p521_key_path = os.path.join(cls.test_file_dir, 'ecP521.pem') + + if not os.path.exists(cls.rsa_key_path): + with open(cls.rsa_key_path, 'w') as f: + f.write(RSA_TEST_PRIVATE_KEY) + + if not os.path.exists(cls.rsa4096_key_path): + key = RSA.generate(4096) + private_key = key.export_key( + passphrase=cls.private_key_passphrase, + protection='PEM' + ) + with open(cls.rsa4096_key_path, "wb") as f: + f.write(private_key) + + if not os.path.exists(cls.ec_p521_key_path): + key = ECC.generate(curve='P-521') + private_key = key.export_key( + format='PEM', + passphrase=cls.private_key_passphrase, + use_pkcs8=True, + protection='PBKDF2WithHMAC-SHA1AndAES128-CBC' + ) + with open(cls.ec_p521_key_path, "wt") as f: + f.write(private_key) + + def test_valid_http_signature(self): + privkey_path = self.rsa_key_path + signing_cfg = signing.HttpSigningConfiguration( + key_id="my-key-id", + signing_scheme=signing.SCHEME_HS2019, + private_key_path=privkey_path, + private_key_passphrase=self.private_key_passphrase, + signing_algorithm=signing.ALGORITHM_RSASSA_PKCS1v15, + signed_headers=[ + signing.HEADER_REQUEST_TARGET, + signing.HEADER_CREATED, + signing.HEADER_HOST, + signing.HEADER_DATE, + signing.HEADER_DIGEST, + 'Content-Type' + ] + ) + config = Configuration(host=HOST, signing_info=signing_cfg) + # Set the OAuth2 access_token to None. Here we are interested in testing + # the HTTP signature scheme. + config.access_token = None + + api_client = petstore_api.ApiClient(config) + pet_api = PetApi(api_client) + + mock_pool = MockPoolManager(self) + api_client.rest_client.pool_manager = mock_pool + + mock_pool.set_signing_config(signing_cfg) + mock_pool.expect_request('POST', HOST + '/pet', + #body=json.dumps(api_client.sanitize_for_serialization(self.pet)), + body=self.pet.to_json(), + headers={'Content-Type': r'application/json', + 'Authorization': r'Signature keyId="my-key-id",algorithm="hs2019",created=[0-9]+,' + r'headers="\(request-target\) \(created\) host date digest content-type",' + r'signature="[a-zA-Z0-9+/=]+"', + 'User-Agent': r'OpenAPI-Generator/1.0.0/python'}, + preload_content=True, timeout=None) + + pet_api.add_pet(self.pet) + + def test_valid_http_signature_with_defaults(self): + privkey_path = self.rsa4096_key_path + signing_cfg = signing.HttpSigningConfiguration( + key_id="my-key-id", + signing_scheme=signing.SCHEME_HS2019, + private_key_path=privkey_path, + private_key_passphrase=self.private_key_passphrase, + ) + config = Configuration(host=HOST, signing_info=signing_cfg) + # Set the OAuth2 access_token to None. Here we are interested in testing + # the HTTP signature scheme. + config.access_token = None + + api_client = petstore_api.ApiClient(config) + pet_api = PetApi(api_client) + + mock_pool = MockPoolManager(self) + api_client.rest_client.pool_manager = mock_pool + + mock_pool.set_signing_config(signing_cfg) + mock_pool.expect_request('POST', HOST + '/pet', + #body=json.dumps(api_client.sanitize_for_serialization(self.pet)), + body=self.pet.to_json(), + headers={'Content-Type': r'application/json', + 'Authorization': r'Signature keyId="my-key-id",algorithm="hs2019",created=[0-9]+,' + r'headers="\(created\)",' + r'signature="[a-zA-Z0-9+/=]+"', + 'User-Agent': r'OpenAPI-Generator/1.0.0/python'}, + preload_content=True, timeout=None) + + pet_api.add_pet(self.pet) + + def test_valid_http_signature_rsassa_pkcs1v15(self): + privkey_path = self.rsa4096_key_path + signing_cfg = signing.HttpSigningConfiguration( + key_id="my-key-id", + signing_scheme=signing.SCHEME_HS2019, + private_key_path=privkey_path, + private_key_passphrase=self.private_key_passphrase, + signing_algorithm=signing.ALGORITHM_RSASSA_PKCS1v15, + signed_headers=[ + signing.HEADER_REQUEST_TARGET, + signing.HEADER_CREATED, + ] + ) + config = Configuration(host=HOST, signing_info=signing_cfg) + # Set the OAuth2 access_token to None. Here we are interested in testing + # the HTTP signature scheme. + config.access_token = None + + api_client = petstore_api.ApiClient(config) + pet_api = PetApi(api_client) + + mock_pool = MockPoolManager(self) + api_client.rest_client.pool_manager = mock_pool + + mock_pool.set_signing_config(signing_cfg) + mock_pool.expect_request('POST', HOST + '/pet', + #body=json.dumps(api_client.sanitize_for_serialization(self.pet)), + body=self.pet.to_json(), + headers={'Content-Type': r'application/json', + 'Authorization': r'Signature keyId="my-key-id",algorithm="hs2019",created=[0-9]+,' + r'headers="\(request-target\) \(created\)",' + r'signature="[a-zA-Z0-9+/=]+"', + 'User-Agent': r'OpenAPI-Generator/1.0.0/python'}, + preload_content=True, timeout=None) + + pet_api.add_pet(self.pet) + + def test_valid_http_signature_rsassa_pss(self): + privkey_path = self.rsa4096_key_path + signing_cfg = signing.HttpSigningConfiguration( + key_id="my-key-id", + signing_scheme=signing.SCHEME_HS2019, + private_key_path=privkey_path, + private_key_passphrase=self.private_key_passphrase, + signing_algorithm=signing.ALGORITHM_RSASSA_PSS, + signed_headers=[ + signing.HEADER_REQUEST_TARGET, + signing.HEADER_CREATED, + ] + ) + config = Configuration(host=HOST, signing_info=signing_cfg) + # Set the OAuth2 access_token to None. Here we are interested in testing + # the HTTP signature scheme. + config.access_token = None + + api_client = petstore_api.ApiClient(config) + pet_api = PetApi(api_client) + + mock_pool = MockPoolManager(self) + api_client.rest_client.pool_manager = mock_pool + + mock_pool.set_signing_config(signing_cfg) + mock_pool.expect_request('POST', HOST + '/pet', + #body=json.dumps(api_client.sanitize_for_serialization(self.pet)), + body=self.pet.to_json(), + headers={'Content-Type': r'application/json', + 'Authorization': r'Signature keyId="my-key-id",algorithm="hs2019",created=[0-9]+,' + r'headers="\(request-target\) \(created\)",' + r'signature="[a-zA-Z0-9+/=]+"', + 'User-Agent': r'OpenAPI-Generator/1.0.0/python'}, + preload_content=True, timeout=None) + + pet_api.add_pet(self.pet) + + def test_valid_http_signature_ec_p521(self): + privkey_path = self.ec_p521_key_path + signing_cfg = signing.HttpSigningConfiguration( + key_id="my-key-id", + signing_scheme=signing.SCHEME_HS2019, + private_key_path=privkey_path, + private_key_passphrase=self.private_key_passphrase, + hash_algorithm=signing.HASH_SHA512, + signed_headers=[ + signing.HEADER_REQUEST_TARGET, + signing.HEADER_CREATED, + ] + ) + config = Configuration(host=HOST, signing_info=signing_cfg) + # Set the OAuth2 access_token to None. Here we are interested in testing + # the HTTP signature scheme. + config.access_token = None + + api_client = petstore_api.ApiClient(config) + pet_api = PetApi(api_client) + + mock_pool = MockPoolManager(self) + api_client.rest_client.pool_manager = mock_pool + + mock_pool.set_signing_config(signing_cfg) + mock_pool.expect_request('POST', HOST + '/pet', + #body=json.dumps(api_client.sanitize_for_serialization(self.pet)), + body=self.pet.to_json(), + headers={'Content-Type': r'application/json', + 'Authorization': r'Signature keyId="my-key-id",algorithm="hs2019",created=[0-9]+,' + r'headers="\(request-target\) \(created\)",' + r'signature="[a-zA-Z0-9+/=]+"', + 'User-Agent': r'OpenAPI-Generator/1.0.0/python'}, + preload_content=True, timeout=None) + + pet_api.add_pet(self.pet) + + def test_invalid_configuration(self): + # Signing scheme must be valid. + with self.assertRaises(Exception) as cm: + signing_cfg = signing.HttpSigningConfiguration( + key_id="my-key-id", + signing_scheme='foo', + private_key_path=self.ec_p521_key_path + ) + self.assertTrue(re.match('Unsupported security scheme', str(cm.exception)), + 'Exception message: {0}'.format(str(cm.exception))) + + # Signing scheme must be specified. + with self.assertRaises(Exception) as cm: + signing_cfg = signing.HttpSigningConfiguration( + key_id="my-key-id", + private_key_path=self.ec_p521_key_path, + signing_scheme=None + ) + self.assertTrue(re.match('Unsupported security scheme', str(cm.exception)), + 'Exception message: {0}'.format(str(cm.exception))) + + # Private key passphrase is missing but key is encrypted. + with self.assertRaises(Exception) as cm: + signing_cfg = signing.HttpSigningConfiguration( + key_id="my-key-id", + signing_scheme=signing.SCHEME_HS2019, + private_key_path=self.ec_p521_key_path, + ) + self.assertTrue(re.match('Not a valid clear PKCS#8 structure', str(cm.exception)), + 'Exception message: {0}'.format(str(cm.exception))) + + # File containing private key must exist. + with self.assertRaises(Exception) as cm: + signing_cfg = signing.HttpSigningConfiguration( + key_id="my-key-id", + signing_scheme=signing.SCHEME_HS2019, + private_key_path='foobar', + ) + self.assertTrue(re.match('Private key file does not exist', str(cm.exception)), + 'Exception message: {0}'.format(str(cm.exception))) + + # The max validity must be a positive value. + with self.assertRaises(Exception) as cm: + signing_cfg = signing.HttpSigningConfiguration( + key_id="my-key-id", + signing_scheme=signing.SCHEME_HS2019, + private_key_path=self.ec_p521_key_path, + signature_max_validity=timedelta(hours=-1) + ) + self.assertTrue(re.match('The signature max validity must be a positive value', + str(cm.exception)), + 'Exception message: {0}'.format(str(cm.exception))) + + # Cannot include the 'Authorization' header. + with self.assertRaises(Exception) as cm: + signing_cfg = signing.HttpSigningConfiguration( + key_id="my-key-id", + signing_scheme=signing.SCHEME_HS2019, + private_key_path=self.ec_p521_key_path, + signed_headers=['Authorization'] + ) + self.assertTrue(re.match("'Authorization' header cannot be included", str(cm.exception)), + 'Exception message: {0}'.format(str(cm.exception))) + + # Cannot specify duplicate headers. + with self.assertRaises(Exception) as cm: + signing_cfg = signing.HttpSigningConfiguration( + key_id="my-key-id", + signing_scheme=signing.SCHEME_HS2019, + private_key_path=self.ec_p521_key_path, + signed_headers=['Host', 'Date', 'Host'] + ) + self.assertTrue(re.match('Cannot have duplicates in the signed_headers parameter', + str(cm.exception)), + 'Exception message: {0}'.format(str(cm.exception))) + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_map_test.py b/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_map_test.py new file mode 100644 index 000000000000..8c0cb48f432c --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_map_test.py @@ -0,0 +1,117 @@ +# coding: utf-8 + +# flake8: noqa + +""" +Run the tests. +$ pip install -U pytest +$ cd petstore_api-python +$ pytest +""" + +import os +import time +import unittest + +import petstore_api + + +class MapTestTests(unittest.TestCase): + + def test_maptest_init(self): + # + # Test MapTest construction with valid values + # + up_or_low_dict = { + 'UPPER': "UP", + 'lower': "low" + } +# map_enum_test = petstore_api.MapTest(map_of_enum_string=up_or_low_dict) +# +# self.assertEqual(map_enum_test.map_of_enum_string, up_or_low_dict) +# +# map_of_map_of_strings = { +# 'val1': 1, +# 'valText': "Text", +# 'valueDict': up_or_low_dict +# } +# map_enum_test = petstore_api.MapTest(map_map_of_string=map_of_map_of_strings) +# +# self.assertEqual(map_enum_test.map_map_of_string, map_of_map_of_strings) +# +# # +# # Make sure that the init fails for invalid enum values +# # +# black_or_white_dict = { +# 'black': "UP", +# 'white': "low" +# } +# try: +# map_enum_test = petstore_api.MapTest(map_of_enum_string=black_or_white_dict) +# self.assertTrue(0) +# except ValueError: +# self.assertTrue(1) +# +# def test_maptest_setter(self): +# # +# # Check with some valid values +# # +# map_enum_test = petstore_api.MapTest() +# up_or_low_dict = { +# 'UPPER': "UP", +# 'lower': "low" +# } +# map_enum_test.map_of_enum_string = up_or_low_dict +# self.assertEqual(map_enum_test.map_of_enum_string, up_or_low_dict) +# +# # +# # Check if the setter fails for invalid enum values +# # +# map_enum_test = petstore_api.MapTest() +# black_or_white_dict = { +# 'black': "UP", +# 'white': "low" +# } +# try: +# map_enum_test.map_of_enum_string = black_or_white_dict +# except ValueError: +# self.assertEqual(map_enum_test.map_of_enum_string, None) +# +# def test_todict(self): +# # +# # Check dictionary serialization +# # +# map_enum_test = petstore_api.MapTest() +# up_or_low_dict = { +# 'UPPER': "UP", +# 'lower': "low" +# } +# map_of_map_of_strings = { +# 'val1': 1, +# 'valText': "Text", +# 'valueDict': up_or_low_dict +# } +# indirect_map = { +# 'option1': True +# } +# direct_map = { +# 'option2': False +# } +# map_enum_test.map_of_enum_string = up_or_low_dict +# map_enum_test.map_map_of_string = map_of_map_of_strings +# map_enum_test.indirect_map = indirect_map +# map_enum_test.direct_map = direct_map +# +# self.assertEqual(map_enum_test.map_of_enum_string, up_or_low_dict) +# self.assertEqual(map_enum_test.map_map_of_string, map_of_map_of_strings) +# self.assertEqual(map_enum_test.indirect_map, indirect_map) +# self.assertEqual(map_enum_test.direct_map, direct_map) +# +# expected_dict = { +# 'map_of_enum_string': up_or_low_dict, +# 'map_map_of_string': map_of_map_of_strings, +# 'indirect_map': indirect_map, +# 'direct_map': direct_map +# } +# +# self.assertEqual(map_enum_test.to_dict(), expected_dict) diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_model.py b/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_model.py new file mode 100644 index 000000000000..01d5d001fab8 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_model.py @@ -0,0 +1,536 @@ +# coding: utf-8 + +# flake8: noqa + +import json +import os +import time +import unittest + +import petstore_api + + +class ModelTests(unittest.TestCase): + + def setUp(self): + self.pet = petstore_api.Pet(name="test name", photo_urls=["string"]) + self.pet.id = 1 + self.pet.status = "available" + cate = petstore_api.Category(name="dog") + cate.id = 1 + cate.name = "dog" + self.pet.category = cate + tag = petstore_api.Tag() + tag.id = 1 + self.pet.tags = [tag] + + def test_cat(self): + self.cat = petstore_api.Cat(class_name="cat") + self.assertEqual("cat", self.cat.class_name) + self.assertEqual("red", self.cat.color) + cat_str = ("{'additional_properties': {},\n" + " 'className': 'cat',\n" + " 'color': 'red',\n" + " 'declawed': None}") + self.assertEqual(cat_str, self.cat.to_str()) + + def test_to_str(self): + data = ("{'additional_properties': {},\n" + " 'category': {'additional_properties': {}, 'id': 1, 'name': 'dog'},\n" + " 'id': 1,\n" + " 'name': 'test name',\n" + " 'photoUrls': ['string'],\n" + " 'status': 'available',\n" + " 'tags': [{'additional_properties': {}, 'id': 1, 'name': None}]}") + self.assertEqual(data, self.pet.to_str()) + + def test_equal(self): + self.pet1 = petstore_api.Pet(name="test name", photo_urls=["string"]) + self.pet1.id = 1 + self.pet1.status = "available" + cate1 = petstore_api.Category(name="dog") + cate1.id = 1 + # cate1.name = "dog" + self.pet.category = cate1 + tag1 = petstore_api.Tag() + tag1.id = 1 + self.pet1.tags = [tag1] + + self.pet2 = petstore_api.Pet(name="test name", photo_urls=["string"]) + self.pet2.id = 1 + self.pet2.status = "available" + cate2 = petstore_api.Category(name="dog") + cate2.id = 1 + cate2.name = "dog" + self.pet.category = cate2 + tag2 = petstore_api.Tag() + tag2.id = 1 + self.pet2.tags = [tag2] + + self.assertTrue(self.pet1 == self.pet2) + + # reset pet1 tags to empty array so that object comparison returns false + self.pet1.tags = [] + self.assertFalse(self.pet1 == self.pet2) + + def test_oneOf_array_of_integers(self): + # test new Color + new_color = petstore_api.Color() + self.assertEqual("null", new_color.to_json()) + self.assertEqual(None, new_color.actual_instance) + + # test the oneof schema validator + json_str = '[12,34,56]' + array_of_integers = json.loads(json_str) + # no error should be thrown + new_color.oneof_schema_1_validator = array_of_integers + new_color.actual_instance = array_of_integers + new_color.actual_instance = None + + # test the oneof schema validator with invalid input + json_str = '[12,34,56120938]' + array_of_integers = json.loads(json_str) + try: + new_color.oneof_schema_1_validator = array_of_integers + except ValueError as e: + self.assertTrue("ensure this value is less than or equal to 255" in str(e)) + + try: + new_color.actual_instance = array_of_integers + except ValueError as e: + self.assertTrue("ensure this value is less than or equal to 255" in str(e)) + + # test from_josn + json_str = '[12,34,56]' + p = petstore_api.Color.from_json(json_str) + self.assertEqual(p.actual_instance, [12, 34, 56]) + + try: + p = petstore_api.Color.from_json('[2342112,0,0,0]') + except ValueError as e: + self.assertTrue("ensure this value is less than or equal to 255" in str(e)) + + # test to_json, to_dict method + json_str = '[12,34,56]' + p = petstore_api.Color.from_json(json_str) + self.assertEqual(p.to_json(), "[12, 34, 56]") + self.assertEqual(p.to_dict(), [12, 34, 56]) + + # test nullable + p = petstore_api.Color.from_json(None) + self.assertEqual(p.actual_instance, None) + + def test_oneof_enum_string(self): + enum_string1 = petstore_api.EnumString1('a') + # test from_json + oneof_enum = petstore_api.OneOfEnumString.from_json('"a"') + # test from_dict + oneof_enum = petstore_api.OneOfEnumString.from_dict("a") + nested = petstore_api.WithNestedOneOf(size = 1, nested_oneof_enum_string = oneof_enum) + # test to_json + self.assertEqual(nested.to_json(), '{"size": 1, "nested_oneof_enum_string": "a"}') + # test from_json + nested = petstore_api.WithNestedOneOf.from_json('{"size": 1, "nested_oneof_enum_string": "c"}') + self.assertEqual(nested.to_json(), '{"size": 1, "nested_oneof_enum_string": "c"}') + # test from_dict + nested = petstore_api.WithNestedOneOf.from_dict({"size": 1, "nested_oneof_enum_string": "c"}) + # test to_dict + self.assertEqual(nested.to_dict(), {"size": 1, "nested_oneof_enum_string": "c"}) + # invalid enum value + try: + nested2 = petstore_api.WithNestedOneOf.from_json('{"size": 1, "nested_oneof_enum_string": "e"}') + except ValueError as e: + self.assertTrue("'e' is not a valid EnumString1, 'e' is not a valid EnumString" in str(e)) + + # test the constructor + enum_string1 = petstore_api.EnumString1('a') + constructor1 = petstore_api.OneOfEnumString(actual_instance=enum_string1) + self.assertEqual(constructor1.actual_instance, enum_string1) + constructor2 = petstore_api.OneOfEnumString(enum_string1) + self.assertEqual(constructor2.actual_instance, enum_string1) + constructor3 = petstore_api.OneOfEnumString() + self.assertEqual(constructor3.actual_instance, None) + + def test_anyOf_array_of_integers(self): + # test new Color + new_color = petstore_api.AnyOfColor() + self.assertEqual("null", new_color.to_json()) + self.assertEqual(None, new_color.actual_instance) + + # test the oneof schema validator + json_str = '[12,34,56]' + array_of_integers = json.loads(json_str) + # no error should be thrown + new_color.anyof_schema_1_validator = array_of_integers + new_color.actual_instance = array_of_integers + + # test the oneof schema validator with invalid input + json_str = '[12,34,56120938]' + array_of_integers = json.loads(json_str) + try: + new_color.anyof_schema_1_validator = array_of_integers + except ValueError as e: + self.assertTrue("ensure this value is less than or equal to 255" in str(e)) + + try: + new_color.actual_instance = array_of_integers + except ValueError as e: + self.assertTrue("ensure this value is less than or equal to 255" in str(e)) + + # test from_josn + json_str = '[12,34,56]' + p = petstore_api.AnyOfColor.from_json(json_str) + self.assertEqual(p.actual_instance, [12, 34,56]) + + try: + p = petstore_api.AnyOfColor.from_json('[2342112,0,0,0]') + except ValueError as e: + self.assertTrue("ensure this value is less than or equal to 255" in str(e)) + + def test_oneOf(self): + # test new Pig + bp = petstore_api.BasquePig.from_dict({"className": "BasquePig", "color": "red"}) + new_pig = petstore_api.Pig() + self.assertEqual("null", new_pig.to_json()) + self.assertEqual(None, new_pig.actual_instance) + new_pig2 = petstore_api.Pig(actual_instance=bp) + self.assertEqual('{"className": "BasquePig", "color": "red"}', new_pig2.to_json()) + new_pig3 = petstore_api.Pig(bp) + self.assertEqual('{"className": "BasquePig", "color": "red"}', new_pig3.to_json()) + try: + new_pig4 = petstore_api.Pig(bp, actual_instance=bp) + except ValueError as e: + self.assertTrue("If position argument is used, keyword argument cannot be used.", str(e)) + try: + new_pig5 = petstore_api.Pig(bp, bp) + except ValueError as e: + self.assertTrue("If position argument is used, only 1 is allowed to set `actual_instance`", str(e)) + + # test from_json + json_str = '{"className": "BasquePig", "color": "red"}' + p = petstore_api.Pig.from_json(json_str) + self.assertIsInstance(p.actual_instance, petstore_api.BasquePig) + + # test from_dict + json_dict = {"className": "BasquePig", "color": "red"} + p = petstore_api.Pig.from_dict(json_dict) + self.assertIsInstance(p.actual_instance, petstore_api.BasquePig) + + # test init + basque_pig = p.actual_instance + pig2 = petstore_api.Pig(actual_instance=basque_pig) + self.assertIsInstance(pig2.actual_instance, petstore_api.BasquePig) + + # test failed init + try: + pig3 = petstore_api.Pig(actual_instance="123") + self.assertTrue(False) # this line shouldn't execute + except ValueError as e: + self.assertTrue("No match found when setting `actual_instance` in Pig with oneOf schemas: BasquePig, DanishPig" in str(e)) + + # failure + try: + p2 = petstore_api.Pig.from_json("1") + self.assertTrue(False) # this line shouldn't execute + except AttributeError as e: + self.assertEqual(str(e), "'int' object has no attribute 'get'") + # comment out below as the error message is different using oneOf discriminator lookup option + #except ValueError as e: + # error_message = ( + # "No match found when deserializing the JSON string into Pig with oneOf schemas: BasquePig, DanishPig. " + # "Details: 1 validation error for BasquePig\n" + # "__root__\n" + # " BasquePig expected dict not int (type=type_error), 1 validation error for DanishPig\n" + # "__root__\n" + # " DanishPig expected dict not int (type=type_error)") + # self.assertEqual(str(e), error_message) + + # test to_json + self.assertEqual(p.to_json(), '{"className": "BasquePig", "color": "red"}') + + # test nested property + nested = petstore_api.WithNestedOneOf(size = 1, nested_pig = p) + self.assertEqual(nested.to_json(), '{"size": 1, "nested_pig": {"className": "BasquePig", "color": "red"}}') + + nested_json = nested.to_json() + nested2 = petstore_api.WithNestedOneOf.from_json(nested_json) + self.assertEqual(nested2.to_json(), nested_json) + + def test_anyOf(self): + # test new AnyOfPig + new_anypig = petstore_api.AnyOfPig() + self.assertEqual("null", new_anypig.to_json()) + self.assertEqual(None, new_anypig.actual_instance) + + # test from_json + json_str = '{"className": "BasquePig", "color": "red"}' + p = petstore_api.AnyOfPig.from_json(json_str) + self.assertIsInstance(p.actual_instance, petstore_api.BasquePig) + + # test from_dict + json_dict = {"className": "BasquePig", "color": "red"} + p = petstore_api.AnyOfPig.from_dict(json_dict) + self.assertIsInstance(p.actual_instance, petstore_api.BasquePig) + + # test init + basque_pig = p.actual_instance + pig2 = petstore_api.AnyOfPig(actual_instance=basque_pig) + self.assertIsInstance(pig2.actual_instance, petstore_api.BasquePig) + + # test failed init + try: + pig3 = petstore_api.AnyOfPig(actual_instance="123") + self.assertTrue(False) # this line shouldn't execute + except ValueError as e: + self.assertTrue( + "No match found when setting the actual_instance in AnyOfPig with anyOf schemas: BasquePig, " + "DanishPig" in str(e)) + + # failure + try: + p2 = petstore_api.AnyOfPig.from_json("1") + self.assertTrue(False) # this line shouldn't execute + except ValueError as e: + error_message = ( + "No match found when deserializing the JSON string into AnyOfPig with anyOf schemas: BasquePig, " + "DanishPig. Details: 1 validation error for BasquePig\n" + "__root__\n" + " BasquePig expected dict not int (type=type_error), 1 validation error for DanishPig\n" + "__root__\n" + " DanishPig expected dict not int (type=type_error)") + self.assertEqual(str(e), error_message) + + # test to_json + self.assertEqual(p.to_json(), '{"className": "BasquePig", "color": "red"}') + + def test_inheritance(self): + dog = petstore_api.Dog(breed="bulldog", className="dog", color="white") + self.assertEqual(dog.to_json(), '{"className": "dog", "color": "white", "breed": "bulldog"}') + self.assertEqual(dog.to_dict(), {'breed': 'bulldog', 'className': + 'dog', 'color': 'white'}) + dog2 = petstore_api.Dog.from_json(dog.to_json()) + self.assertEqual(dog2.breed, 'bulldog') + self.assertEqual(dog2.class_name, "dog") + self.assertEqual(dog2.color, 'white') + + def test_list(self): + # should throw exception as var_123_list should be string + try: + l3 = petstore_api.List(var_123_list=123) + self.assertTrue(False) # this line shouldn't execute + except ValueError as e: + #error_message = ( + # "1 validation error for List\n" + # "123-list\n" + # " str type expected (type=type_error.str)\n") + self.assertTrue("str type expected" in str(e)) + + l = petstore_api.List(var_123_list="bulldog") + self.assertEqual(l.to_json(), '{"123-list": "bulldog"}') + self.assertEqual(l.to_dict(), {'123-list': 'bulldog'}) + l2 = petstore_api.List.from_json(l.to_json()) + self.assertEqual(l2.var_123_list, 'bulldog') + + self.assertTrue(isinstance(l2, petstore_api.List)) + + def test_enum_ref_property(self): + # test enum ref property + # test to_json + d = petstore_api.OuterObjectWithEnumProperty(value=petstore_api.OuterEnumInteger.NUMBER_1) + self.assertEqual(d.to_json(), '{"value": 1}') + d2 = petstore_api.OuterObjectWithEnumProperty(value=petstore_api.OuterEnumInteger.NUMBER_1, str_value=petstore_api.OuterEnum.DELIVERED) + self.assertEqual(d2.to_json(), '{"str_value": "delivered", "value": 1}') + # test from_json (round trip) + d3 = petstore_api.OuterObjectWithEnumProperty.from_json(d2.to_json()) + self.assertEqual(d3.str_value, petstore_api.OuterEnum.DELIVERED) + self.assertEqual(d3.value, petstore_api.OuterEnumInteger.NUMBER_1) + self.assertEqual(d3.to_json(), '{"str_value": "delivered", "value": 1}') + d4 = petstore_api.OuterObjectWithEnumProperty(value=petstore_api.OuterEnumInteger.NUMBER_1, str_value=None) + self.assertEqual(d4.to_json(), '{"value": 1, "str_value": null}') + d5 = petstore_api.OuterObjectWithEnumProperty(value=petstore_api.OuterEnumInteger.NUMBER_1) + self.assertEqual(d5.__fields_set__, {'value'}) + d5.str_value = None # set None explicitly + self.assertEqual(d5.__fields_set__, {'value', 'str_value'}) + self.assertEqual(d5.to_json(), '{"value": 1, "str_value": null}') + + def test_valdiator(self): + # test regular expression + a = petstore_api.FormatTest(number=123.45, byte=bytes("string", 'utf-8'), date="2013-09-17", password="testing09876") + try: + a.pattern_with_digits_and_delimiter = "123" + self.assertTrue(False) # this line shouldn't execute + except ValueError as e: + self.assertTrue(r"must validate the regular expression /^image_\d{1,3}$/i" in str(e)) + + # test None with optional string (with regualr expression) + a = petstore_api.FormatTest(number=123.45, byte=bytes("string", 'utf-8'), date="2013-09-17", password="testing09876") + a.string = None # shouldn't throw an exception + + a.pattern_with_digits_and_delimiter = "IMAGE_123" + self.assertEqual(a.pattern_with_digits_and_delimiter, "IMAGE_123") + a.pattern_with_digits_and_delimiter = "image_123" + self.assertEqual(a.pattern_with_digits_and_delimiter, "image_123") + + def test_inline_enum_validator(self): + self.pet = petstore_api.Pet(name="test name", photo_urls=["string"]) + self.pet.id = 1 + try: + self.pet.status = "error" + self.assertTrue(False) # this line shouldn't execute + except ValueError as e: + self.assertTrue("must be one of enum values ('available', 'pending', 'sold')" in str(e)) + + def test_object_id(self): + pet_ap = petstore_api.Pet(name="test name", photo_urls=["string"]) + pet_ap2 = petstore_api.Pet(name="test name", photo_urls=["string"]) + self.assertNotEqual(id(pet_ap), id(pet_ap2)) + + pet_ap3 = petstore_api.Pet.from_dict(pet_ap.to_dict()) + pet_ap4 = petstore_api.Pet.from_dict(pet_ap.to_dict()) + self.assertNotEqual(id(pet_ap3), id(pet_ap4)) + + + def test_additional_properties(self): + pet_ap = petstore_api.Pet(name="test name", photo_urls=["string"]) + pet_ap.id = 1 + pet_ap.status = "available" + + pet_ap2 = petstore_api.Pet(name="test name", photo_urls=["string"]) + pet_ap2.id = 1 + pet_ap2.status = "available" + + self.assertNotEqual(id(pet_ap.additional_properties), id(pet_ap2.additional_properties)) + + pet_ap.additional_properties["something-new"] = "haha" + self.assertEqual(pet_ap.to_json(), '{"id": 1, "name": "test name", "photoUrls": ["string"], "status": "available", "something-new": "haha"}') + self.assertEqual(type(pet_ap2.additional_properties), dict) + self.assertNotEqual(id(pet_ap.additional_properties), id(pet_ap2.additional_properties)) + self.assertEqual(pet_ap.additional_properties["something-new"], "haha") + + try: + _tmp = pet_ap2.additional_properties["something-new"] + self.assertTrue(False) # this line shouldn't execute + except KeyError as e: + self.assertEqual("'something-new'", str(e)) + + pet_ap_dict = pet_ap.to_dict() + pet_ap_dict["something-new"] = 123 + pet_ap_dict["array"] = ["a", "b"] + pet_ap_dict["dict"] = {"key999": "value999"} + + pet_ap2 = petstore_api.Pet.from_dict(pet_ap_dict) + + self.assertEqual(pet_ap2.additional_properties["array"], ["a", "b"]) + self.assertEqual(pet_ap2.additional_properties["something-new"], 123) + self.assertEqual(pet_ap2.additional_properties["dict"], {"key999": "value999"}) + + def test_nullable(self): + h = petstore_api.HealthCheckResult(nullable_message="Not none") + self.assertEqual(h.to_json(), '{"NullableMessage": "Not none"}') + + h.nullable_message = None + self.assertEqual(h.to_json(), '{"NullableMessage": null}') + + #import json + #dictionary ={ + # "id": "04", + # "name": "sunil", + # "department": None + #} + # + ## Serializing json + #json_object = json.dumps(dictionary) + #self.assertEqual(json_object, "") + + def test_inline_enum_default(self): + enum_test = petstore_api.EnumTest(enum_string_required="lower") + self.assertEqual(enum_test.enum_integer_default, 5) + + def test_object_with_optional_dict(self): + # for https://github.com/OpenAPITools/openapi-generator/issues/14913 + # shouldn't throw exception by the optional dict property + a = petstore_api.ParentWithOptionalDict.from_dict({}) + self.assertFalse(a is None) + + b = petstore_api.ParentWithOptionalDict.from_dict({"optionalDict": {"key": {"aProperty": {"a": "b"}}}}) + self.assertFalse(b is None) + self.assertEqual(b.optional_dict["key"].a_property["a"], "b") + + def test_object_with_dict_of_dict_of_object(self): + # for https://github.com/OpenAPITools/openapi-generator/issues/15135 + d = {"optionalDict": {"a": {"b": {"aProperty": "value"}}}} + a = petstore_api.Parent.from_dict(d) + self.assertEqual(a.to_dict(), d) + + def test_eum_class(self): + a = petstore_api.EnumClass("-efg") + self.assertEqual(a.value, "-efg") + self.assertEqual(a.name, "MINUS_EFG") + self.assertEqual(a, "-efg") + + def test_nullable_property_pattern(self): + a = petstore_api.NullableProperty(id=12, name=None) + self.assertEqual(a.id, 12) + self.assertEqual(a.name, None) + + def test_int_or_string_oneof(self): + a = petstore_api.IntOrString("-efg") + self.assertEqual(a.actual_instance, "-efg") + a = petstore_api.IntOrString(100) + self.assertEqual(a.actual_instance, 100) + + try: + a = petstore_api.IntOrString(1) + except ValueError as e: + self.assertTrue("ensure this value is greater than or equal to 10" in str(e)) + + def test_map_of_array_of_model(self): + a = petstore_api.MapOfArrayOfModel() + t = petstore_api.Tag(id=123, name="tag name") + a.shop_id_to_org_online_lip_map = {"somekey": [t]} + self.assertEqual(a.to_dict(), {'shopIdToOrgOnlineLipMap': {'somekey': [{'id': 123, 'name': 'tag name'}]}}) + self.assertEqual(a.to_json(), '{"shopIdToOrgOnlineLipMap": {"somekey": [{"id": 123, "name": "tag name"}]}}') + a2 = petstore_api.MapOfArrayOfModel.from_dict(a.to_dict()) + self.assertEqual(a.to_dict(), a2.to_dict()) + + def test_array_of_array_of_model(self): + a = petstore_api.ArrayOfArrayOfModel() + t = petstore_api.Tag(id=123, name="tag name") + a.another_property = [[t]] + self.assertEqual(a.to_dict(), {'another_property': [[ {'id': 123, 'name': 'tag name'} ]]}) + self.assertEqual(a.to_json(), '{"another_property": [[{"id": 123, "name": "tag name"}]]}') + a2 = petstore_api.ArrayOfArrayOfModel.from_dict(a.to_dict()) + self.assertEqual(a.to_dict(), a2.to_dict()) + + def test_object_with_additional_properties(self): + a = petstore_api.ObjectToTestAdditionalProperties() + a.additional_properties = { "abc": 123 } + # should not throw the following errors: + # pydantic.errors.ConfigError: field "additional_properties" not yet prepared so type is still a ForwardRef, you might need to call ObjectToTestAdditionalProperties.update_forward_refs(). + + def test_first_ref(self): + # shouldn't throw "still a ForwardRef" error + a = petstore_api.FirstRef.from_dict({}) + self.assertEqual(a.to_json(), "{}") + + def test_allof(self): + # for issue 16104 + model = petstore_api.Tiger.from_json('{"skill": "none", "type": "tiger", "info": {"name": "creature info"}}') + # shouldn't throw NameError + self.assertEqual(model.to_json(), '{"skill": "none", "type": "tiger", "info": {"name": "creature info"}}') + + def test_additional_properties(self): + a1 = petstore_api.AdditionalPropertiesAnyType() + a1.additional_properties = { "abc": 123 } + self.assertEqual(a1.to_dict(), {"abc": 123}) + self.assertEqual(a1.to_json(), "{\"abc\": 123}") + + a2 = petstore_api.AdditionalPropertiesObject() + a2.additional_properties = { "efg": 45.6 } + self.assertEqual(a2.to_dict(), {"efg": 45.6}) + self.assertEqual(a2.to_json(), "{\"efg\": 45.6}") + + a3 = petstore_api.AdditionalPropertiesWithDescriptionOnly() + a3.additional_properties = { "xyz": 45.6 } + self.assertEqual(a3.to_dict(), {"xyz": 45.6}) + self.assertEqual(a3.to_json(), "{\"xyz\": 45.6}") diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_order_model.py b/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_order_model.py new file mode 100644 index 000000000000..7d4afba5b1db --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_order_model.py @@ -0,0 +1,20 @@ +# coding: utf-8 + +# flake8: noqa + +import os +import time +import unittest + +import petstore_api + + +class OrderModelTests(unittest.TestCase): + + def test_status(self): + order = petstore_api.Order() + # order.status = "placed" + # self.assertEqual("placed", order.status) + + # with self.assertRaises(ValueError): + # order.status = "invalid" diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_pet_api.py b/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_pet_api.py new file mode 100644 index 000000000000..61a6030a4aed --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_pet_api.py @@ -0,0 +1,269 @@ +# coding: utf-8 + +# flake8: noqa + +""" +Run the tests. +$ docker pull swaggerapi/petstore +$ docker run -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore +$ pip install -U pytest +$ cd petstore_api-python +$ pytest +""" + +import os +import unittest + +import petstore_api +from petstore_api import Configuration +from petstore_api.rest import ApiException + +from .util import id_gen + +import json + +import urllib3 + +HOST = 'http://petstore.swagger.io/v2' + + +class TimeoutWithEqual(urllib3.Timeout): + def __init__(self, *arg, **kwargs): + super(TimeoutWithEqual, self).__init__(*arg, **kwargs) + + def __eq__(self, other): + return self._read == other._read and self._connect == other._connect and self.total == other.total + + +class MockPoolManager(object): + def __init__(self, tc): + self._tc = tc + self._reqs = [] + + def expect_request(self, *args, **kwargs): + self._reqs.append((args, kwargs)) + + def request(self, *args, **kwargs): + self._tc.assertTrue(len(self._reqs) > 0) + r = self._reqs.pop(0) + self._tc.maxDiff = None + self._tc.assertEqual(r[0], args) + self._tc.assertEqual(r[1], kwargs) + return urllib3.HTTPResponse(status=200, body=b'test') + + +class PetApiTests(unittest.TestCase): + + def setUp(self): + config = Configuration() + config.host = HOST + config.access_token = 'ACCESS_TOKEN' + self.api_client = petstore_api.ApiClient(config) + self.pet_api = petstore_api.PetApi(self.api_client) + self.setUpModels() + self.setUpFiles() + + def setUpModels(self): + self.category = petstore_api.Category(name="dog") + self.category.id = id_gen() + # self.category.name = "dog" + self.tag = petstore_api.Tag() + self.tag.id = id_gen() + self.tag.name = "python-pet-tag" + self.pet = petstore_api.Pet(name="hello kity", photo_urls=["http://foo.bar.com/1", "http://foo.bar.com/2"]) + self.pet.id = id_gen() + self.pet.status = "sold" + self.pet.category = self.category + self.pet.tags = [self.tag] + + self.pet2 = petstore_api.Pet(name="superman 2", photo_urls=["http://foo.bar.com/1", "http://foo.bar.com/2"]) + self.pet2.id = id_gen() + 1 + self.pet2.status = "available" + self.pet2.category = self.category + self.pet2.tags = [self.tag] + + def setUpFiles(self): + self.test_file_dir = os.path.join(os.path.dirname(__file__), "..", "testfiles") + self.test_file_dir = os.path.realpath(self.test_file_dir) + self.foo = os.path.join(self.test_file_dir, "pix.gif") + + def test_timeout(self): + mock_pool = MockPoolManager(self) + self.api_client.rest_client.pool_manager = mock_pool + + mock_pool.expect_request('POST', HOST + '/pet', + body=json.dumps(self.api_client.sanitize_for_serialization(self.pet)), + headers={'Content-Type': 'application/json', + 'Authorization': 'Bearer ACCESS_TOKEN', + 'User-Agent': 'OpenAPI-Generator/1.0.0/python'}, + preload_content=True, timeout=TimeoutWithEqual(total=5)) + mock_pool.expect_request('POST', HOST + '/pet', + body=json.dumps(self.api_client.sanitize_for_serialization(self.pet)), + headers={'Content-Type': 'application/json', + 'Authorization': 'Bearer ACCESS_TOKEN', + 'User-Agent': 'OpenAPI-Generator/1.0.0/python'}, + preload_content=True, timeout=TimeoutWithEqual(connect=1, read=2)) + + self.pet_api.add_pet(self.pet, _request_timeout=5) + self.pet_api.add_pet(self.pet, _request_timeout=(1, 2)) + + def test_separate_default_config_instances(self): + # ensure the default api client is used + pet_api = petstore_api.PetApi() + pet_api2 = petstore_api.PetApi() + self.assertEqual(id(pet_api.api_client), id(pet_api2.api_client)) + # ensure the default configuration is used + self.assertEqual(id(pet_api.api_client.configuration), id(pet_api2.api_client.configuration)) + + def test_async_request(self): + thread = self.pet_api.add_pet(self.pet, async_req=True) + response = thread.get() + self.assertIsNone(response) + + thread = self.pet_api.get_pet_by_id(self.pet.id, async_req=True) + result = thread.get() + self.assertIsInstance(result, petstore_api.Pet) + + def test_async_with_result(self): + self.pet_api.add_pet(self.pet, async_req=False) + + thread = self.pet_api.get_pet_by_id(self.pet.id, async_req=True) + thread2 = self.pet_api.get_pet_by_id(self.pet.id, async_req=True) + + response = thread.get() + response2 = thread2.get() + + self.assertEqual(response.id, self.pet.id) + self.assertIsNotNone(response2.id, self.pet.id) + + def test_async_with_http_info(self): + self.pet_api.add_pet(self.pet) + + thread = self.pet_api.get_pet_by_id_with_http_info(self.pet.id, async_req=True) + api_response_object = thread.get() + + self.assertIsInstance(api_response_object.data, petstore_api.Pet) + self.assertEqual(api_response_object.status_code, 200) + self.assertEqual(api_response_object.headers['Content-Type'], "application/json") + self.assertIsInstance(api_response_object.raw_data, str) # it's a str, not Pet + self.assertTrue(api_response_object.raw_data.startswith('{"id":')) + + def test_async_exception(self): + self.pet_api.add_pet(self.pet) + + thread = self.pet_api.get_pet_by_id(9999999999999, async_req=True) + + exception = None + try: + thread.get() + except ApiException as e: + exception = e + + self.assertIsInstance(exception, ApiException) + self.assertEqual(exception.status, 404) + + def test_add_pet_and_get_pet_by_id(self): + self.pet_api.add_pet(self.pet) + + fetched = self.pet_api.get_pet_by_id(pet_id=self.pet.id) + self.assertIsNotNone(fetched) + self.assertEqual(self.pet.id, fetched.id) + self.assertIsNotNone(fetched.category) + self.assertEqual(self.pet.category.name, fetched.category.name) + + def test_add_pet_and_get_pet_by_id_with_preload_content_flag(self): + try: + self.pet_api.add_pet(self.pet, _preload_content=False) + except ValueError as e: + self.assertEqual("Error! Please call the add_pet_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data", str(e)) + + self.pet_api.add_pet(self.pet) + fetched = self.pet_api.get_pet_by_id_with_http_info(pet_id=self.pet.id, + _preload_content=False) + self.assertIsNone(fetched.data) + self.assertIsInstance(fetched.raw_data, bytes) # it's a str, not Pet + self.assertTrue(fetched.raw_data.decode("utf-8").startswith('{"id":')) + + def test_add_pet_and_get_pet_by_id_with_http_info(self): + self.pet_api.add_pet(self.pet) + + # fetched is an ApiResponse object + fetched = self.pet_api.get_pet_by_id_with_http_info(pet_id=self.pet.id) + self.assertIsNotNone(fetched.data) + self.assertEqual(self.pet.id, fetched.data.id) + self.assertIsNotNone(fetched.data.category) + self.assertEqual(self.pet.category.name, fetched.data.category.name) + + def test_update_pet(self): + self.pet.name = "hello kity with updated" + self.pet_api.update_pet(self.pet) + + fetched = self.pet_api.get_pet_by_id(pet_id=self.pet.id) + self.assertIsNotNone(fetched) + self.assertEqual(self.pet.id, fetched.id) + self.assertEqual(self.pet.name, fetched.name) + self.assertIsNotNone(fetched.category) + self.assertEqual(fetched.category.name, self.pet.category.name) + + def test_find_pets_by_status(self): + self.pet_api.add_pet(self.pet) + self.pet_api.add_pet(self.pet2) + + results = self.pet_api.find_pets_by_status(status=["pending", "available"]) + self.assertIsInstance(results, list) + self.assertTrue(len(results) > 1) + # TODO + #for result in results: + # self.assertTrue(result.status in ["sold", "available"]) + + def test_find_pets_by_tags(self): + self.pet_api.add_pet(self.pet) + + self.assertIn( + self.pet.id, + list(map(lambda x: getattr(x, 'id'), self.pet_api.find_pets_by_tags(tags=[self.tag.name, "here is another tag"]))) + ) + + def test_update_pet_with_form(self): + self.pet_api.add_pet(self.pet) + + name = "hello kity with form updated abc" + status = "pending" + self.pet_api.update_pet_with_form(pet_id=self.pet.id, name=name, status=status) + + fetched = self.pet_api.get_pet_by_id(pet_id=self.pet.id) + self.assertEqual(self.pet.id, fetched.id) + self.assertEqual(name, fetched.name) + self.assertEqual(status, fetched.status) + + def test_upload_file(self): + # upload file with form parameter + try: + additional_metadata = "special data 123" + self.pet_api.upload_file( + pet_id=self.pet.id, + additional_metadata=additional_metadata, + file=self.foo + ) + except ApiException as e: + self.fail("upload_file() raised {0} unexpectedly".format(type(e))) + + # upload only file + try: + self.pet_api.upload_file(pet_id=self.pet.id, file=self.foo) + except ApiException as e: + self.fail("upload_file() raised {0} unexpectedly".format(type(e))) + + def test_delete_pet(self): + self.pet_api.add_pet(self.pet) + self.pet_api.delete_pet(pet_id=self.pet.id, api_key="special-key") + + try: + self.pet_api.get_pet_by_id(pet_id=self.pet.id) + raise Exception("expected an error") + except ApiException as e: + self.assertEqual(404, e.status) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_pet_model.py b/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_pet_model.py new file mode 100644 index 000000000000..2c8b2f403263 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_pet_model.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +# flake8: noqa + +import os +import time +import unittest + +import petstore_api +import json +from pydantic import ValidationError + + +class PetModelTests(unittest.TestCase): + + def setUp(self): + self.pet = petstore_api.Pet(name="test name", photo_urls=["string"]) + self.pet.id = 1 + self.pet.status = "available" + cate = petstore_api.Category(name="dog") + cate.id = 1 + # cate.name = "dog" + self.pet.category = cate + tag = petstore_api.Tag() + tag.id = 1 + self.pet.tags = [tag] + + def test_to_str(self): + data = ("{'additional_properties': {},\n" + " 'category': {'additional_properties': {}, 'id': 1, 'name': 'dog'},\n" + " 'id': 1,\n" + " 'name': 'test name',\n" + " 'photoUrls': ['string'],\n" + " 'status': 'available',\n" + " 'tags': [{'additional_properties': {}, 'id': 1, 'name': None}]}") + self.assertEqual(data, self.pet.to_str()) + + def test_equal(self): + self.pet1 = petstore_api.Pet(name="test name", photo_urls=["string"]) + self.pet1.id = 1 + self.pet1.status = "available" + cate1 = petstore_api.Category(name="dog") + cate1.id = 1 + # cate1.name = "dog" + self.pet1.category = cate1 + tag1 = petstore_api.Tag() + tag1.id = 1 + self.pet1.tags = [tag1] + + self.pet2 = petstore_api.Pet(name="test name", photo_urls=["string"]) + self.pet2.id = 1 + self.pet2.status = "available" + cate2 = petstore_api.Category(name="dog") + cate2.id = 1 + # cate2.name = "dog" + self.pet2.category = cate2 + tag2 = petstore_api.Tag() + tag2.id = 1 + self.pet2.tags = [tag2] + + self.assertTrue(self.pet1 == self.pet2) + + # reset pet1 tags to empty array so that object comparison returns false + self.pet1.tags = [] + self.assertFalse(self.pet1 == self.pet2) + + # test from_json, to_json, to_dict, from_dict + def test_from_to_methods(self): + json_str = ("{\"category\": {\"id\": 1, \"name\": \"dog\"},\n" + " \"id\": 1,\n" + " \"name\": \"test name\",\n" + " \"photoUrls\": [\"string\"],\n" + " \"status\": \"available\",\n" + " \"tags\": [{\"id\": 1, \"name\": \"None\"}]}") + pet = petstore_api.Pet.from_json(json_str) + self.assertEqual(pet.id, 1) + self.assertEqual(pet.status, "available") + self.assertEqual(pet.photo_urls, ["string"]) + self.assertEqual(pet.tags[0].id, 1) + self.assertEqual(pet.tags[0].name, "None") + self.assertEqual(pet.category.id, 1) + # test to_json + self.assertEqual(pet.to_json(), + '{"id": 1, "category": {"id": 1, "name": "dog"}, "name": "test name", "photoUrls": [' + '"string"], "tags": [{"id": 1, "name": "None"}], "status": "available"}') + + # test to_dict + self.assertEqual(pet.to_dict(), + {"id": 1, "category": {"id": 1, "name": "dog"}, "name": "test name", "photoUrls": ["string"], + "tags": [{"id": 1, "name": "None"}], "status": "available"}) + + # test from_dict + pet2 = petstore_api.Pet.from_dict(pet.to_dict()) + self.assertEqual(pet2.id, 1) + self.assertEqual(pet2.status, "available") + self.assertEqual(pet2.photo_urls, ["string"]) + self.assertEqual(pet2.tags[0].id, 1) + self.assertEqual(pet2.tags[0].name, "None") + self.assertEqual(pet2.category.id, 1) + + def test_unpack_operator(self): + d = {"name": "required name", "id": 123, "photoUrls": ["https://a.com", "https://b.com"]} + pet = petstore_api.Pet(**d) + self.assertEqual(pet.to_json(), '{"id": 123, "name": "required name", "photoUrls": ["https://a.com", "https://b.com"]}') + self.assertEqual(pet.to_dict(), {"id": 123, "name": "required name", "photoUrls": ["https://a.com", "https://b.com"]}) + + def test_optional_fields(self): + _pet = petstore_api.Pet(name="required name", + photoUrls=["https://a.com", + "https://b.com"]) + self.assertEqual(_pet.to_json(), '{"name": "required name", "photoUrls": ["https://a.com", "https://b.com"]}') + self.assertEqual(_pet.to_dict(), {"name": "required name", "photoUrls": ["https://a.com", "https://b.com"]}) + + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_store_api.py b/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_store_api.py new file mode 100644 index 000000000000..178e44fd1fef --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/tests/test_store_api.py @@ -0,0 +1,32 @@ +# coding: utf-8 + +# flake8: noqa + +""" +Run the tests. +$ pip install -U pytest +$ cd OpenAP/Petstore-python +$ pytest +""" + +import os +import time +import unittest + +import petstore_api +from petstore_api.rest import ApiException + + +class StoreApiTests(unittest.TestCase): + + def setUp(self): + self.store_api = petstore_api.StoreApi() + + def tearDown(self): + # sleep 1 sec between two every 2 tests + time.sleep(1) + + def test_get_inventory(self): + data = self.store_api.get_inventory() + self.assertIsNotNone(data) + self.assertTrue(isinstance(data, dict)) diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/tests/util.py b/samples/openapi3/client/petstore/python-pydantic-v2/tests/util.py new file mode 100644 index 000000000000..113d7dcc5478 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/tests/util.py @@ -0,0 +1,8 @@ +# flake8: noqa + +import random + + +def id_gen(bits=32): + """ Returns a n-bit randomly generated int """ + return int(random.getrandbits(bits)) diff --git a/samples/openapi3/client/petstore/python-pydantic-v2/tox.ini b/samples/openapi3/client/petstore/python-pydantic-v2/tox.ini new file mode 100755 index 000000000000..49d3f9352a6c --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v2/tox.ini @@ -0,0 +1,9 @@ +[tox] +envlist = py3 + +[testenv] +deps=-r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + +commands= + pytest --cov=petstore_api test/test_model.py diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py index c8ae8d0af133..07b372e879e8 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py @@ -17,6 +17,7 @@ import warnings from pydantic import validate_arguments, ValidationError +from typing_extensions import Annotated from typing_extensions import Annotated from pydantic import Field diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/default_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/default_api.py index b52692877379..3b615de2250a 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/default_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/default_api.py @@ -17,6 +17,7 @@ import warnings from pydantic import validate_arguments, ValidationError +from typing_extensions import Annotated from petstore_api.models.foo_get_default_response import FooGetDefaultResponse diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py index 1bdbf4e06a91..3385216d5aae 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py @@ -17,6 +17,7 @@ import warnings from pydantic import validate_arguments, ValidationError +from typing_extensions import Annotated from typing_extensions import Annotated from datetime import date, datetime diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py index acfe8c01a94f..ad82b56f9008 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py @@ -17,6 +17,7 @@ import warnings from pydantic import validate_arguments, ValidationError +from typing_extensions import Annotated from typing_extensions import Annotated from pydantic import Field diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py index f0eefd7ec890..ac29f3bf728d 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py @@ -17,6 +17,7 @@ import warnings from pydantic import validate_arguments, ValidationError +from typing_extensions import Annotated from typing_extensions import Annotated from pydantic import Field, StrictBytes, StrictInt, StrictStr, conlist, validator diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py index b5b845531fe6..08886968882e 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py @@ -17,6 +17,7 @@ import warnings from pydantic import validate_arguments, ValidationError +from typing_extensions import Annotated from typing_extensions import Annotated from pydantic import Field, StrictStr, conint diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py index 240a692ebcad..0ff0ce0f7724 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py @@ -17,6 +17,7 @@ import warnings from pydantic import validate_arguments, ValidationError +from typing_extensions import Annotated from typing_extensions import Annotated from pydantic import Field, StrictStr, conlist diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py index a0f5848057e7..eba260e84f41 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py @@ -29,8 +29,8 @@ class AdditionalPropertiesAnyType(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["name"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py index 06c924e21f91..f7c4f8663e89 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py @@ -30,8 +30,8 @@ class AdditionalPropertiesClass(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["map_property", "map_of_map_property"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py index 022aa9c286a1..14707fa99697 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py @@ -29,8 +29,8 @@ class AdditionalPropertiesObject(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["name"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py index ab7281d0dc4d..3c64a8134d65 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py @@ -29,8 +29,8 @@ class AdditionalPropertiesWithDescriptionOnly(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["name"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py index f0fba0386424..b28814c3a4ca 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py @@ -31,8 +31,8 @@ class AllOfWithSingleRef(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["username", "SingleRefType"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python/petstore_api/models/animal.py index 08c51a32b431..a4a2f85ec7ff 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/animal.py @@ -30,8 +30,8 @@ class Animal(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["className", "color"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py index b422650686fd..79eece679cda 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py @@ -21,7 +21,6 @@ from typing import List, Optional from pydantic import BaseModel, Field, StrictStr, ValidationError, conint, conlist, constr, validator from typing import Union, Any, List, TYPE_CHECKING -from pydantic import StrictStr, Field ANYOFCOLOR_ANY_OF_SCHEMAS = ["List[int]", "str"] @@ -42,6 +41,7 @@ class AnyOfColor(BaseModel): actual_instance: Any any_of_schemas: List[str] = Field(ANYOFCOLOR_ANY_OF_SCHEMAS, const=True) + """Pydantic configuration""" class Config: validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py index 1254f6789a8c..30274e51269a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py @@ -23,7 +23,6 @@ from petstore_api.models.basque_pig import BasquePig from petstore_api.models.danish_pig import DanishPig from typing import Union, Any, List, TYPE_CHECKING -from pydantic import StrictStr, Field ANYOFPIG_ANY_OF_SCHEMAS = ["BasquePig", "DanishPig"] @@ -42,6 +41,7 @@ class AnyOfPig(BaseModel): actual_instance: Any any_of_schemas: List[str] = Field(ANYOFPIG_ANY_OF_SCHEMAS, const=True) + """Pydantic configuration""" class Config: validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/api_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/api_response.py index 6224b7b9564d..56e7928f07be 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/api_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/api_response.py @@ -31,8 +31,8 @@ class ApiResponse(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["code", "type", "message"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py index 0f444a85a296..293c13902dbe 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py @@ -30,8 +30,8 @@ class ArrayOfArrayOfModel(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["another_property"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py index 45ffc93e2bbd..2a52c2936ba1 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py @@ -29,8 +29,8 @@ class ArrayOfArrayOfNumberOnly(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["ArrayArrayNumber"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py index ff06726b621f..10dd656729ce 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py @@ -29,8 +29,8 @@ class ArrayOfNumberOnly(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["ArrayNumber"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py index 5e266148eb4f..8fcc378f6d48 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py @@ -32,8 +32,8 @@ class ArrayTest(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["array_of_string", "array_array_of_integer", "array_array_of_model"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py index c9f6603166fb..e1455ef6aac3 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py @@ -30,8 +30,8 @@ class BasquePig(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["className", "color"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py index 3685da0822c0..b5b6be2e7b1f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py @@ -34,8 +34,8 @@ class Capitalization(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["smallCamel", "CapitalCamel", "small_Snake", "Capital_Snake", "SCA_ETH_Flow_Points", "ATT_NAME"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python/petstore_api/models/cat.py index b5dd4c4b08da..a0767dcda8db 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/cat.py @@ -30,8 +30,8 @@ class Cat(Animal): additional_properties: Dict[str, Any] = {} __properties = ["className", "color", "declawed"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/category.py b/samples/openapi3/client/petstore/python/petstore_api/models/category.py index 068827c38788..e741639d3d26 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/category.py @@ -30,8 +30,8 @@ class Category(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["id", "name"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py index 68a202082b28..4c65c3e7e9df 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py @@ -30,8 +30,8 @@ class CircularReferenceModel(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["size", "nested"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py index f9464aa85629..8dbe440495f4 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py @@ -29,8 +29,8 @@ class ClassModel(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["_class"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/client.py b/samples/openapi3/client/petstore/python/petstore_api/models/client.py index b527c6e6aeed..d33089c7acf2 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/client.py @@ -29,8 +29,8 @@ class Client(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["client"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/color.py b/samples/openapi3/client/petstore/python/petstore_api/models/color.py index 4dee9419ab7f..574093092a01 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/color.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/color.py @@ -21,7 +21,6 @@ from typing import Any, List, Optional from pydantic import BaseModel, Field, StrictStr, ValidationError, conint, conlist, constr, validator from typing import Union, Any, List, TYPE_CHECKING -from pydantic import StrictStr, Field COLOR_ONE_OF_SCHEMAS = ["List[int]", "str"] @@ -39,8 +38,10 @@ class Color(BaseModel): actual_instance: Union[List[int], str] else: actual_instance: Any + one_of_schemas: List[str] = Field(COLOR_ONE_OF_SCHEMAS, const=True) + """Pydantic configuration""" class Config: validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python/petstore_api/models/creature.py index ade10d2236a1..b825d112ffde 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/creature.py @@ -31,8 +31,8 @@ class Creature(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["info", "type"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py b/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py index bdc45b05b777..1e3f89ba59bc 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py @@ -29,8 +29,8 @@ class CreatureInfo(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["name"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py index 206f58550469..63ac5adc7c93 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py @@ -30,8 +30,8 @@ class DanishPig(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["className", "size"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py b/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py index 4e9dc9ddf75e..072a70136f7d 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py @@ -29,8 +29,8 @@ class DeprecatedObject(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["name"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python/petstore_api/models/dog.py index 6317e1fe32a0..8c64d451b9ed 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/dog.py @@ -30,8 +30,8 @@ class Dog(Animal): additional_properties: Dict[str, Any] = {} __properties = ["className", "color", "breed"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py index 951906fd28e5..fd5e54166033 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py @@ -30,8 +30,8 @@ class DummyModel(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["category", "self_ref"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py index f804f117c9b3..af6d88417552 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py @@ -51,8 +51,8 @@ def array_enum_validate_enum(cls, value): raise ValueError("each list item must be one of ('fish', 'crab')") return value + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py index 8a06dc2f0cf3..0bae41973e41 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py @@ -88,8 +88,8 @@ def enum_number_validate_enum(cls, value): raise ValueError("must be one of enum values (1.1, -1.2)") return value + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/file.py b/samples/openapi3/client/petstore/python/petstore_api/models/file.py index f45b5114f2c5..38c1c6628984 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/file.py @@ -29,8 +29,8 @@ class File(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["sourceURI"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py index efbb7d95f03d..65561c5e061d 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py @@ -31,8 +31,8 @@ class FileSchemaTestClass(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["file", "files"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py index 5a44cd22c7e6..ee6cf8a9ca00 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py @@ -30,8 +30,8 @@ class FirstRef(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["category", "self_ref"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python/petstore_api/models/foo.py index 77f2ef9a359a..72cb376c34b0 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/foo.py @@ -29,8 +29,8 @@ class Foo(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["bar"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py index 3eb736a411e3..5a0b5e662a6f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py @@ -30,8 +30,8 @@ class FooGetDefaultResponse(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["string"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py index 5363f6311963..9593187ab837 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py @@ -85,8 +85,8 @@ def pattern_with_digits_and_delimiter_validate_regular_expression(cls, value): raise ValueError(r"must validate the regular expression /^image_\d{1,3}$/i") return value + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py index be7b0eb636b3..d1325c9ff63c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py @@ -30,8 +30,8 @@ class HasOnlyReadOnly(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["bar", "foo"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py index ec2c401c3631..b3f08f79162d 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py @@ -29,8 +29,8 @@ class HealthCheckResult(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["NullableMessage"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py b/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py index f3a50b0851b9..97c87383862b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py @@ -29,8 +29,8 @@ class InnerDictWithProperty(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["aProperty"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py b/samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py index 5d5de47e305a..574c73549525 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py @@ -21,7 +21,6 @@ from typing import Any, List, Optional from pydantic import BaseModel, Field, StrictStr, ValidationError, conint, validator from typing import Union, Any, List, TYPE_CHECKING -from pydantic import StrictStr, Field INTORSTRING_ONE_OF_SCHEMAS = ["int", "str"] @@ -37,8 +36,10 @@ class IntOrString(BaseModel): actual_instance: Union[int, str] else: actual_instance: Any + one_of_schemas: List[str] = Field(INTORSTRING_ONE_OF_SCHEMAS, const=True) + """Pydantic configuration""" class Config: validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/list.py b/samples/openapi3/client/petstore/python/petstore_api/models/list.py index d4381879ccb3..c1e80a8bf1d6 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/list.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/list.py @@ -29,8 +29,8 @@ class List(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["123-list"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py index 0f0bf902f308..5339b05fb0ae 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py @@ -30,8 +30,8 @@ class MapOfArrayOfModel(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["shopIdToOrgOnlineLipMap"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py index 4270158fd4d0..d9a35e2e76c4 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py @@ -42,8 +42,8 @@ def map_of_enum_string_validate_enum(cls, value): raise ValueError("must be one of enum values ('UPPER', 'lower')") return value + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py index 9345c5b2ab6b..656a0c70c329 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -32,8 +32,8 @@ class MixedPropertiesAndAdditionalPropertiesClass(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["uuid", "dateTime", "map"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py index 63c69743338e..a3955bcb9632 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py @@ -30,8 +30,8 @@ class Model200Response(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["name", "class"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py index a7212e506b6c..5d73d5ff459c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py @@ -29,8 +29,8 @@ class ModelReturn(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["return"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/name.py b/samples/openapi3/client/petstore/python/petstore_api/models/name.py index 180e06e24c55..78691119c80d 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/name.py @@ -32,8 +32,8 @@ class Name(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["name", "snake_case", "property", "123Number"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py index 578579888444..f9f75200a479 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py @@ -41,8 +41,8 @@ class NullableClass(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["required_integer_prop", "integer_prop", "number_prop", "boolean_prop", "string_prop", "date_prop", "datetime_prop", "array_nullable_prop", "array_and_items_nullable_prop", "array_items_nullable", "object_nullable_prop", "object_and_items_nullable_prop", "object_items_nullable"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py index 059cbdc577cb..f9852c6d4c50 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py @@ -40,8 +40,8 @@ def name_validate_regular_expression(cls, value): raise ValueError(r"must validate the regular expression /^[A-Z].*/") return value + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py index 78a00af5654b..b615444e8cb4 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py @@ -29,8 +29,8 @@ class NumberOnly(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["JustNumber"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py b/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py index 21e9a30d7dfb..69889866bbad 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py @@ -29,8 +29,8 @@ class ObjectToTestAdditionalProperties(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["property"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py b/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py index fda4435b8be3..1b23fea5022e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py @@ -33,8 +33,8 @@ class ObjectWithDeprecatedFields(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["uuid", "id", "deprecatedRef", "bars"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py b/samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py index d7ae93ccb6a8..f4b18189e6f9 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py @@ -23,7 +23,6 @@ from petstore_api.models.enum_string1 import EnumString1 from petstore_api.models.enum_string2 import EnumString2 from typing import Union, Any, List, TYPE_CHECKING -from pydantic import StrictStr, Field ONEOFENUMSTRING_ONE_OF_SCHEMAS = ["EnumString1", "EnumString2"] @@ -39,8 +38,10 @@ class OneOfEnumString(BaseModel): actual_instance: Union[EnumString1, EnumString2] else: actual_instance: Any + one_of_schemas: List[str] = Field(ONEOFENUMSTRING_ONE_OF_SCHEMAS, const=True) + """Pydantic configuration""" class Config: validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/order.py b/samples/openapi3/client/petstore/python/petstore_api/models/order.py index 691eb04bbb1f..46744c6d899c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/order.py @@ -44,8 +44,8 @@ def status_validate_enum(cls, value): raise ValueError("must be one of enum values ('placed', 'approved', 'delivered')") return value + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py index b453339e1c87..ab19c5478cab 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py @@ -31,8 +31,8 @@ class OuterComposite(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["my_number", "my_string", "my_boolean"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py index a5723f0a9321..f925d15226d0 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py @@ -32,8 +32,8 @@ class OuterObjectWithEnumProperty(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["str_value", "value"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python/petstore_api/models/parent.py index d597e8c4e444..ffd387db12e9 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/parent.py @@ -30,8 +30,8 @@ class Parent(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["optionalDict"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py index fa23256f5c60..a7832616daed 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py @@ -30,8 +30,8 @@ class ParentWithOptionalDict(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["optionalDict"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python/petstore_api/models/pet.py index 25743a7ef09a..2f68cf79f205 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/pet.py @@ -46,8 +46,8 @@ def status_validate_enum(cls, value): raise ValueError("must be one of enum values ('available', 'pending', 'sold')") return value + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/pig.py index 62ae5a2a0ef7..0f96725a08b9 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/pig.py @@ -23,7 +23,6 @@ from petstore_api.models.basque_pig import BasquePig from petstore_api.models.danish_pig import DanishPig from typing import Union, Any, List, TYPE_CHECKING -from pydantic import StrictStr, Field PIG_ONE_OF_SCHEMAS = ["BasquePig", "DanishPig"] @@ -39,8 +38,10 @@ class Pig(BaseModel): actual_instance: Union[BasquePig, DanishPig] else: actual_instance: Any + one_of_schemas: List[str] = Field(PIG_ONE_OF_SCHEMAS, const=True) + """Pydantic configuration""" class Config: validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py b/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py index b5314f3d63e8..10a53fc54ddd 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py @@ -31,8 +31,8 @@ class PropertyNameCollision(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["_type", "type", "type_"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py index cfaf97c7091e..00fccbdf1a48 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py @@ -30,8 +30,8 @@ class ReadOnlyFirst(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["bar", "baz"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py index 2f0c99ae1b90..8fc160607612 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py @@ -30,8 +30,8 @@ class SecondRef(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["category", "circular_ref"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py index 55512492d8e9..6176d7327d7f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py @@ -30,8 +30,8 @@ class SelfReferenceModel(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["size", "nested"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py index 1c9804d5b4ae..373b1209fe04 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py @@ -29,8 +29,8 @@ class SpecialModelName(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["$special[property.name]"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py b/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py index 51d955951d4f..01075364c1b2 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py @@ -42,8 +42,8 @@ def var_schema_validate_enum(cls, value): raise ValueError("must be one of enum values ('available', 'pending', 'sold')") return value + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python/petstore_api/models/tag.py index 299159859552..28766eda136a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/tag.py @@ -30,8 +30,8 @@ class Tag(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["id", "name"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py b/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py index 71453dcec366..26c12744c636 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py @@ -29,8 +29,8 @@ class Tiger(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["skill"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/user.py b/samples/openapi3/client/petstore/python/petstore_api/models/user.py index 365c77ceb141..2c1e32c81ce7 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/user.py @@ -36,8 +36,8 @@ class User(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["id", "username", "firstName", "lastName", "email", "password", "phone", "userStatus"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py b/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py index 8ec40c8eda1e..8bf965cd87e7 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py @@ -33,8 +33,8 @@ class WithNestedOneOf(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["size", "nested_pig", "nested_oneof_enum_string"] + """Pydantic configuration""" class Config: - """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True diff --git a/samples/server/petstore/python-fastapi/requirements.txt b/samples/server/petstore/python-fastapi/requirements.txt index e5a1b375c4c3..6e52599f1f75 100644 --- a/samples/server/petstore/python-fastapi/requirements.txt +++ b/samples/server/petstore/python-fastapi/requirements.txt @@ -7,7 +7,7 @@ chardet==4.0.0 click==7.1.2 dnspython==2.1.0 email-validator==1.1.2 -fastapi==0.95.2 +fastapi==0.103.0 graphene==2.1.8 graphql-core==2.3.2 graphql-relay==2.0.1 @@ -20,7 +20,7 @@ Jinja2==2.11.3 MarkupSafe==2.0.1 orjson==3.5.2 promise==2.3 -pydantic==1.8.2 +pydantic==2.3.0 python-dotenv==0.17.1 python-multipart==0.0.5 PyYAML==5.4.1