python: generate Pydantic v2 + typing complete code (#16624)

* python: improve type generation with more specific typing

* Annotate function parameters

* Remove unused imports

* remove unused files

* remove temporary hack

* remove lock file

* fix Annotated import

* support Python 3.7

* Regenerate code with typing-extensions

* Fix setup.py

* More Pydantic v2 compatibility

* depend on pydantic v2

* fix client_echo tests

* fix JSON serialization

* Fix references

* Skip circular dependency tests for now

* Temporarily hide the "float" property

The "float" property aliases the "float" type and completely breaks the
model: all the properties that were "float" now become the type of the
"float" property instead.

* Fix errors

* Import Literal from typing_extensions

* Fix GitHub Action workflows

* Fix Python 3.7 failure

* Fix quotes

* Apply suggestions from code review

* Fix tests

* split model imports from other modules imports

* fix workflow

* Comment the array unique items convertion, remove set translation

* Replace alias usage
This commit is contained in:
Jonathan Ballet 2023-09-28 13:13:14 +02:00 committed by GitHub
parent af352df10f
commit 04fa53b692
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
219 changed files with 3305 additions and 1566 deletions

View File

@ -15,7 +15,7 @@ jobs:
matrix: matrix:
sample: sample:
# clients # clients
- samples/client/echo_api/python - samples/client/echo_api/python-pydantic-v1/
python-version: python-version:
- "3.7" - "3.7"
- "3.8" - "3.8"

View File

@ -21,8 +21,8 @@ jobs:
- "3.10" - "3.10"
- "3.11" - "3.11"
sample: sample:
- samples/openapi3/client/petstore/python-aiohttp - samples/openapi3/client/petstore/python-pydantic-v1-aiohttp
- samples/openapi3/client/petstore/python - samples/openapi3/client/petstore/python-pydantic-v1
services: services:
petstore-api: petstore-api:
image: swaggerapi/petstore image: swaggerapi/petstore

View File

@ -1,6 +1,6 @@
generatorName: python generatorName: python
outputDir: samples/client/echo_api/python outputDir: samples/client/echo_api/python
inputSpec: modules/openapi-generator/src/test/resources/3_0/echo_api.yaml inputSpec: modules/openapi-generator/src/test/resources/3_0/python/echo_api.yaml
templateDir: modules/openapi-generator/src/main/resources/python templateDir: modules/openapi-generator/src/main/resources/python
additionalProperties: additionalProperties:
hideGenerationTimestamp: "true" hideGenerationTimestamp: "true"

View File

@ -53,7 +53,7 @@ if [[ ${#files[@]} -eq 1 && "${files[0]}" != *'*'* ]]; then
java ${JAVA_OPTS} -jar "$executable" generate -c ${files[0]} ${args[@]} java ${JAVA_OPTS} -jar "$executable" generate -c ${files[0]} ${args[@]}
else else
echo "Please press CTRL+C to stop or the script will continue in 5 seconds." echo "Please press CTRL+C to stop or the script will continue in 5 seconds."
sleep 5 #sleep 5
if [ ${#files[@]} -eq 0 ]; then if [ ${#files[@]} -eq 0 ]; then
files=("${root}"/bin/configs/*.yaml) files=("${root}"/bin/configs/*.yaml)
fi fi

View File

@ -999,6 +999,82 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
this.hasMultipleTypes = hasMultipleTypes; this.hasMultipleTypes = hasMultipleTypes;
} }
@Override
public boolean getIsFloat() {
return isFloat;
}
@Override
public void setIsFloat(boolean isFloat) {
this.isFloat = isFloat;
}
@Override
public boolean getIsDouble() {
return isDouble;
}
@Override
public void setIsDouble(boolean isDouble) {
this.isDouble = isDouble;
}
@Override
public boolean getIsInteger() {
return isInteger;
}
@Override
public void setIsInteger(boolean isInteger) {
this.isInteger = isInteger;
}
@Override
public boolean getIsLong() {
return isLong;
}
@Override
public void setIsLong(boolean isLong) {
this.isLong = isLong;
}
@Override
public boolean getIsBinary() {
return false;
}
@Override
public void setIsBinary(boolean isBinary) {}
@Override
public boolean getIsByteArray() {
return false;
}
@Override
public void setIsByteArray(boolean isByteArray) {}
@Override
public boolean getIsDecimal() {
return isDecimal;
}
@Override
public void setIsDecimal(boolean isDecimal) {
this.isDecimal = isDecimal;
}
@Override
public boolean getIsEnum() {
return isEnum;
}
@Override
public void setIsEnum(boolean isEnum) {
this.isEnum = isEnum;
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;

View File

@ -17,9 +17,14 @@
package org.openapitools.codegen; package org.openapitools.codegen;
import io.swagger.v3.oas.models.examples.Example; import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*; import io.swagger.v3.oas.models.examples.Example;
/** /**
* Describes a single operation parameter in the OAS specification. * Describes a single operation parameter in the OAS specification.
@ -997,5 +1002,105 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
public void setSchemaIsFromAdditionalProperties(boolean schemaIsFromAdditionalProperties) { public void setSchemaIsFromAdditionalProperties(boolean schemaIsFromAdditionalProperties) {
this.schemaIsFromAdditionalProperties = schemaIsFromAdditionalProperties; this.schemaIsFromAdditionalProperties = schemaIsFromAdditionalProperties;
} }
@Override
public String getDataType() {
return dataType;
}
@Override
public void setDataType(String dataType) {
this.dataType = dataType;
}
@Override
public boolean getIsFloat() {
return isFloat;
}
@Override
public void setIsFloat(boolean isFloat) {
this.isFloat = isFloat;
}
@Override
public boolean getIsDouble() {
return isDouble;
}
@Override
public void setIsDouble(boolean isDouble) {
this.isDouble = isDouble;
}
@Override
public boolean getIsInteger() {
return isInteger;
}
@Override
public void setIsInteger(boolean isInteger) {
this.isInteger = isInteger;
}
@Override
public boolean getIsLong() {
return isLong;
}
@Override
public void setIsLong(boolean isLong) {
this.isLong = isLong;
}
@Override
public boolean getIsBinary() {
return isBinary;
}
@Override
public void setIsBinary(boolean isBinary) {
this.isBinary = isBinary;
}
@Override
public boolean getIsByteArray() {
return isByteArray;
}
@Override
public void setIsByteArray(boolean isByteArray) {
this.isByteArray = isByteArray;
}
@Override
public boolean getIsDecimal() {
return isDecimal;
}
@Override
public void setIsDecimal(boolean isDecimal) {
this.isDecimal = isDecimal;
}
@Override
public boolean getIsUuid() {
return isUuid;
}
@Override
public void setIsUuid(boolean isUuid) {
this.isUuid = isUuid;
}
@Override
public boolean getIsEnum() {
return isEnum;
}
@Override
public void setIsEnum(boolean isEnum) {
this.isEnum = isEnum;
}
} }

View File

@ -17,7 +17,12 @@
package org.openapitools.codegen; package org.openapitools.codegen;
import java.util.*; import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperties { public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperties {
/** /**
@ -317,10 +322,18 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
return dataType; return dataType;
} }
/**
* @deprecated use {@link #setDataType()} instead.
*/
@Deprecated
public void setDatatype(String datatype) { public void setDatatype(String datatype) {
this.dataType = datatype; this.dataType = datatype;
} }
public void setDataType(String dataType) {
this.dataType = dataType;
}
public String getDatatypeWithEnum() { public String getDatatypeWithEnum() {
return datatypeWithEnum; return datatypeWithEnum;
} }
@ -1027,6 +1040,76 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
this.requiredVarsMap = requiredVarsMap; this.requiredVarsMap = requiredVarsMap;
} }
@Override
public boolean getIsFloat() {
return isFloat;
}
@Override
public void setIsFloat(boolean isFloat) {
this.isFloat = isFloat;
}
@Override
public boolean getIsDouble() {
return isDouble;
}
@Override
public void setIsDouble(boolean isDouble) {
this.isDouble = isDouble;
}
@Override
public boolean getIsInteger() {
return isInteger;
}
@Override
public void setIsInteger(boolean isInteger) {
this.isInteger = isInteger;
}
@Override
public boolean getIsLong() {
return isLong;
}
@Override
public void setIsLong(boolean isLong) {
this.isLong = isLong;
}
@Override
public boolean getIsBinary() {
return isBinary;
}
@Override
public void setIsBinary(boolean isBinary) {
this.isBinary = isBinary;
}
@Override
public boolean getIsByteArray() {
return isByteArray;
}
@Override
public void setIsByteArray(boolean isByteArray) {
this.isByteArray = isByteArray;
}
@Override
public boolean getIsDecimal() {
return isDecimal;
}
@Override
public void setIsDecimal(boolean isDecimal) {
this.isDecimal = isDecimal;
}
/** /**
* Return true if it's an enum (inline or ref) * Return true if it's an enum (inline or ref)
* *
@ -1036,6 +1119,16 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
return isEnum || isEnumRef; return isEnum || isEnumRef;
} }
@Override
public boolean getIsEnum() {
return isEnum;
}
@Override
public void setIsEnum(boolean isEnum) {
this.isEnum = isEnum;
}
@Override @Override
public String toString() { public String toString() {
final StringBuilder sb = new StringBuilder("CodegenProperty{"); final StringBuilder sb = new StringBuilder("CodegenProperty{");

View File

@ -542,6 +542,16 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
this.hasRequired = hasRequired; this.hasRequired = hasRequired;
} }
@Override
public boolean getIsUuid() {
return isUuid;
}
@Override
public void setIsUuid(boolean isUuid) {
this.isUuid = isUuid;
}
@Override @Override
public String toString() { public String toString() {
final StringBuilder sb = new StringBuilder("CodegenResponse{"); final StringBuilder sb = new StringBuilder("CodegenResponse{");
@ -790,4 +800,92 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
public void setSchemaIsFromAdditionalProperties(boolean schemaIsFromAdditionalProperties) { public void setSchemaIsFromAdditionalProperties(boolean schemaIsFromAdditionalProperties) {
this.schemaIsFromAdditionalProperties = schemaIsFromAdditionalProperties; this.schemaIsFromAdditionalProperties = schemaIsFromAdditionalProperties;
} }
@Override
public String getDataType() {
return dataType;
}
@Override
public void setDataType(String dataType) {
this.dataType = dataType;
}
@Override
public boolean getIsFloat() {
return isFloat;
}
@Override
public void setIsFloat(boolean isFloat) {
this.isFloat = isFloat;
}
@Override
public boolean getIsDouble() {
return isDouble;
}
@Override
public void setIsDouble(boolean isDouble) {
this.isDouble = isDouble;
}
@Override
public boolean getIsInteger() {
return isInteger;
}
@Override
public void setIsInteger(boolean isInteger) {
this.isInteger = isInteger;
}
@Override
public boolean getIsLong() {
return isLong;
}
@Override
public void setIsLong(boolean isLong) {
this.isLong = isLong;
}
@Override
public boolean getIsBinary() {
return isBinary;
}
@Override
public void setIsBinary(boolean isBinary) {
this.isBinary = isBinary;
}
@Override
public boolean getIsByteArray() {
return isByteArray;
}
@Override
public void setIsByteArray(boolean isByteArray) {
this.isByteArray = isByteArray;
}
@Override
public boolean getIsDecimal() {
return isDecimal;
}
@Override
public void setIsDecimal(boolean isDecimal) {
this.isDecimal = isDecimal;
}
@Override
public boolean getIsEnum() {
return false;
}
@Override
public void setIsEnum(boolean isEnum) {}
} }

View File

@ -9,11 +9,12 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Stream; import java.util.stream.Stream;
import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.meta.FeatureSet; import org.openapitools.codegen.meta.FeatureSet;
import org.openapitools.codegen.meta.features.SchemaSupportFeature; import org.openapitools.codegen.meta.features.SchemaSupportFeature;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import io.swagger.v3.oas.models.media.Schema;
public interface IJsonSchemaValidationProperties { public interface IJsonSchemaValidationProperties {
CodegenProperty getContains(); CodegenProperty getContains();
@ -223,6 +224,46 @@ public interface IJsonSchemaValidationProperties {
String getFormat(); String getFormat();
void setDataType(String dataType);
String getDataType();
void setIsFloat(boolean isFloat);
boolean getIsFloat();
void setIsDouble(boolean isDouble);
boolean getIsDouble();
void setIsInteger(boolean isDouble);
boolean getIsInteger();
void setIsLong(boolean isLong);
boolean getIsLong();
void setIsBinary(boolean isBinary);
boolean getIsBinary();
void setIsByteArray(boolean isByteArray);
boolean getIsByteArray();
void setIsDecimal(boolean isDecimal);
boolean getIsDecimal();
void setIsUuid(boolean isUuid);
boolean getIsUuid();
void setIsEnum(boolean isEnum);
boolean getIsEnum();
/** /**
* Syncs all the schema's type properties into the IJsonSchemaValidationProperties instance * Syncs all the schema's type properties into the IJsonSchemaValidationProperties instance
* for now this only supports types without format information * for now this only supports types without format information

View File

@ -7,9 +7,6 @@ import io
import warnings import warnings
from pydantic import validate_arguments, ValidationError from pydantic import validate_arguments, ValidationError
{{#asyncio}}
from typing import overload, Optional, Union, Awaitable
{{/asyncio}}
{{#imports}} {{#imports}}
{{import}} {{import}}

View File

@ -6,10 +6,14 @@ import re # noqa: F401
{{#vendorExtensions.x-py-datetime-imports}}{{#-first}}from datetime import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-datetime-imports}} {{#vendorExtensions.x-py-datetime-imports}}{{#-first}}from datetime import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-datetime-imports}}
{{#vendorExtensions.x-py-typing-imports}}{{#-first}}from typing import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-typing-imports}} {{#vendorExtensions.x-py-typing-imports}}{{#-first}}from typing import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-typing-imports}}
{{#vendorExtensions.x-py-pydantic-imports}}{{#-first}}from pydantic import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-pydantic-imports}} {{#vendorExtensions.x-py-pydantic-imports}}{{#-first}}from pydantic import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-pydantic-imports}}
{{#vendorExtensions.x-py-other-imports}}
{{{.}}}
{{/vendorExtensions.x-py-other-imports}}
{{#vendorExtensions.x-py-model-imports}} {{#vendorExtensions.x-py-model-imports}}
{{{.}}} {{{.}}}
{{/vendorExtensions.x-py-model-imports}} {{/vendorExtensions.x-py-model-imports}}
from typing import Union, Any, List, TYPE_CHECKING from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict
from typing_extensions import Literal
from pydantic import StrictStr, Field from pydantic import StrictStr, Field
{{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ANY_OF_SCHEMAS = [{{#anyOf}}"{{.}}"{{^-last}}, {{/-last}}{{/anyOf}}] {{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ANY_OF_SCHEMAS = [{{#anyOf}}"{{.}}"{{^-last}}, {{/-last}}{{/anyOf}}]
@ -24,16 +28,16 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
{{vendorExtensions.x-py-name}}: {{{vendorExtensions.x-py-typing}}} {{vendorExtensions.x-py-name}}: {{{vendorExtensions.x-py-typing}}}
{{/composedSchemas.anyOf}} {{/composedSchemas.anyOf}}
if TYPE_CHECKING: if TYPE_CHECKING:
actual_instance: Union[{{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}}] actual_instance: Optional[Union[{{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}}]] = None
else: else:
actual_instance: Any actual_instance: Any = None
any_of_schemas: List[str] = Field({{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ANY_OF_SCHEMAS, const=True) any_of_schemas: List[str] = Literal[{{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ANY_OF_SCHEMAS]
class Config: class Config:
validate_assignment = True validate_assignment = True
{{#discriminator}} {{#discriminator}}
discriminator_value_class_map = { discriminator_value_class_map: Dict[str, str] = {
{{#children}} {{#children}}
'{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}': '{{{classname}}}'{{^-last}},{{/-last}} '{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}': '{{{classname}}}'{{^-last}},{{/-last}}
{{/children}} {{/children}}
@ -174,7 +178,10 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
{{#vendorExtensions.x-py-postponed-model-imports.size}} {{#vendorExtensions.x-py-postponed-model-imports.size}}
{{#vendorExtensions.x-py-postponed-model-imports}} {{#vendorExtensions.x-py-postponed-model-imports}}
from typing import TYPE_CHECKING
if TYPE_CHECKING:
{{{.}}} {{{.}}}
# TODO: pydantic v2
{{/vendorExtensions.x-py-postponed-model-imports}} {{/vendorExtensions.x-py-postponed-model-imports}}
{{classname}}.update_forward_refs() # {{classname}}.model_rebuild()
{{/vendorExtensions.x-py-postponed-model-imports.size}} {{/vendorExtensions.x-py-postponed-model-imports.size}}

View File

@ -6,6 +6,9 @@ import json
{{#vendorExtensions.x-py-datetime-imports}}{{#-first}}from datetime import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-datetime-imports}} {{#vendorExtensions.x-py-datetime-imports}}{{#-first}}from datetime import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-datetime-imports}}
{{#vendorExtensions.x-py-typing-imports}}{{#-first}}from typing import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-typing-imports}} {{#vendorExtensions.x-py-typing-imports}}{{#-first}}from typing import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-typing-imports}}
{{#vendorExtensions.x-py-pydantic-imports}}{{#-first}}from pydantic import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-pydantic-imports}} {{#vendorExtensions.x-py-pydantic-imports}}{{#-first}}from pydantic import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-pydantic-imports}}
{{#vendorExtensions.x-py-other-imports}}
{{{.}}}
{{/vendorExtensions.x-py-other-imports}}
{{#vendorExtensions.x-py-model-imports}} {{#vendorExtensions.x-py-model-imports}}
{{{.}}} {{{.}}}
{{/vendorExtensions.x-py-model-imports}} {{/vendorExtensions.x-py-model-imports}}
@ -95,9 +98,9 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
@classmethod @classmethod
def get_discriminator_value(cls, obj: dict) -> str: def get_discriminator_value(cls, obj: dict) -> str:
"""Returns the discriminator value (object type) of the data""" """Returns the discriminator value (object type) of the data"""
discriminator_value = obj[cls.__discriminator_property_name] discriminator_value = obj[cls.__discriminator_property_name.default]
if discriminator_value: if discriminator_value:
return cls.__discriminator_value_class_map.get(discriminator_value) return cls.__discriminator_value_class_map.default.get(discriminator_value)
else: else:
return None return None
{{/-last}} {{/-last}}
@ -111,6 +114,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -227,8 +231,8 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
return klass.from_dict(obj) return klass.from_dict(obj)
else: else:
raise ValueError("{{{classname}}} failed to lookup discriminator value from " + raise ValueError("{{{classname}}} failed to lookup discriminator value from " +
json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name + json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name.default +
", mapping: " + json.dumps(cls.__discriminator_value_class_map)) ", mapping: " + json.dumps(cls.__discriminator_value_class_map.default))
{{/discriminator}} {{/discriminator}}
{{/hasChildren}} {{/hasChildren}}
{{^hasChildren}} {{^hasChildren}}
@ -253,10 +257,10 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
{{#isArray}} {{#isArray}}
{{#items.isArray}} {{#items.isArray}}
{{#items.items.isPrimitiveType}} {{#items.items.isPrimitiveType}}
"{{{name}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}} "{{{baseName}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}}
{{/items.items.isPrimitiveType}} {{/items.items.isPrimitiveType}}
{{^items.items.isPrimitiveType}} {{^items.items.isPrimitiveType}}
"{{{name}}}": [ "{{{baseName}}}": [
[{{{items.items.dataType}}}.from_dict(_inner_item) for _inner_item in _item] [{{{items.items.dataType}}}.from_dict(_inner_item) for _inner_item in _item]
for _item in obj.get("{{{baseName}}}") for _item in obj.get("{{{baseName}}}")
] if obj.get("{{{baseName}}}") is not None else None{{^-last}},{{/-last}} ] if obj.get("{{{baseName}}}") is not None else None{{^-last}},{{/-last}}
@ -265,14 +269,14 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
{{^items.isArray}} {{^items.isArray}}
{{^items.isPrimitiveType}} {{^items.isPrimitiveType}}
{{#items.isEnumOrRef}} {{#items.isEnumOrRef}}
"{{{name}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}} "{{{baseName}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}}
{{/items.isEnumOrRef}} {{/items.isEnumOrRef}}
{{^items.isEnumOrRef}} {{^items.isEnumOrRef}}
"{{{name}}}": [{{{items.dataType}}}.from_dict(_item) for _item in obj.get("{{{baseName}}}")] if obj.get("{{{baseName}}}") is not None else None{{^-last}},{{/-last}} "{{{baseName}}}": [{{{items.dataType}}}.from_dict(_item) for _item in obj.get("{{{baseName}}}")] if obj.get("{{{baseName}}}") is not None else None{{^-last}},{{/-last}}
{{/items.isEnumOrRef}} {{/items.isEnumOrRef}}
{{/items.isPrimitiveType}} {{/items.isPrimitiveType}}
{{#items.isPrimitiveType}} {{#items.isPrimitiveType}}
"{{{name}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}} "{{{baseName}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}}
{{/items.isPrimitiveType}} {{/items.isPrimitiveType}}
{{/items.isArray}} {{/items.isArray}}
{{/isArray}} {{/isArray}}
@ -281,7 +285,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
{{^items.isEnumOrRef}} {{^items.isEnumOrRef}}
{{#items.isContainer}} {{#items.isContainer}}
{{#items.isMap}} {{#items.isMap}}
"{{{name}}}": dict( "{{{baseName}}}": dict(
(_k, dict( (_k, dict(
(_ik, {{{items.items.dataType}}}.from_dict(_iv)) (_ik, {{{items.items.dataType}}}.from_dict(_iv))
for _ik, _iv in _v.items() for _ik, _iv in _v.items()
@ -295,7 +299,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
else None{{^-last}},{{/-last}} else None{{^-last}},{{/-last}}
{{/items.isMap}} {{/items.isMap}}
{{#items.isArray}} {{#items.isArray}}
"{{{name}}}": dict( "{{{baseName}}}": dict(
(_k, (_k,
[{{{items.items.dataType}}}.from_dict(_item) for _item in _v] [{{{items.items.dataType}}}.from_dict(_item) for _item in _v]
if _v is not None if _v is not None
@ -306,7 +310,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
{{/items.isArray}} {{/items.isArray}}
{{/items.isContainer}} {{/items.isContainer}}
{{^items.isContainer}} {{^items.isContainer}}
"{{{name}}}": dict( "{{{baseName}}}": dict(
(_k, {{{items.dataType}}}.from_dict(_v)) (_k, {{{items.dataType}}}.from_dict(_v))
for _k, _v in obj.get("{{{baseName}}}").items() for _k, _v in obj.get("{{{baseName}}}").items()
) )
@ -315,29 +319,29 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
{{/items.isContainer}} {{/items.isContainer}}
{{/items.isEnumOrRef}} {{/items.isEnumOrRef}}
{{#items.isEnumOrRef}} {{#items.isEnumOrRef}}
"{{{name}}}": dict((_k, _v) for _k, _v in obj.get("{{{baseName}}}").items()){{^-last}},{{/-last}} "{{{baseName}}}": dict((_k, _v) for _k, _v in obj.get("{{{baseName}}}").items()){{^-last}},{{/-last}}
{{/items.isEnumOrRef}} {{/items.isEnumOrRef}}
{{/items.isPrimitiveType}} {{/items.isPrimitiveType}}
{{#items.isPrimitiveType}} {{#items.isPrimitiveType}}
"{{{name}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}} "{{{baseName}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}}
{{/items.isPrimitiveType}} {{/items.isPrimitiveType}}
{{/isMap}} {{/isMap}}
{{/isContainer}} {{/isContainer}}
{{^isContainer}} {{^isContainer}}
{{^isPrimitiveType}} {{^isPrimitiveType}}
{{^isEnumOrRef}} {{^isEnumOrRef}}
"{{{name}}}": {{{dataType}}}.from_dict(obj.get("{{{baseName}}}")) if obj.get("{{{baseName}}}") is not None else None{{^-last}},{{/-last}} "{{{baseName}}}": {{{dataType}}}.from_dict(obj.get("{{{baseName}}}")) if obj.get("{{{baseName}}}") is not None else None{{^-last}},{{/-last}}
{{/isEnumOrRef}} {{/isEnumOrRef}}
{{#isEnumOrRef}} {{#isEnumOrRef}}
"{{{name}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}} "{{{baseName}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}}
{{/isEnumOrRef}} {{/isEnumOrRef}}
{{/isPrimitiveType}} {{/isPrimitiveType}}
{{#isPrimitiveType}} {{#isPrimitiveType}}
{{#defaultValue}} {{#defaultValue}}
"{{{name}}}": obj.get("{{{baseName}}}") if obj.get("{{{baseName}}}") is not None else {{{defaultValue}}}{{^-last}},{{/-last}} "{{{baseName}}}": obj.get("{{{baseName}}}") if obj.get("{{{baseName}}}") is not None else {{{defaultValue}}}{{^-last}},{{/-last}}
{{/defaultValue}} {{/defaultValue}}
{{^defaultValue}} {{^defaultValue}}
"{{{name}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}} "{{{baseName}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}}
{{/defaultValue}} {{/defaultValue}}
{{/isPrimitiveType}} {{/isPrimitiveType}}
{{/isContainer}} {{/isContainer}}
@ -346,7 +350,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesTrue}}
# store additional fields in additional_properties # store additional fields in additional_properties
for _key in obj.keys(): for _key in obj.keys():
if _key not in cls.__properties: if _key not in cls.__properties.default:
_obj.additional_properties[_key] = obj.get(_key) _obj.additional_properties[_key] = obj.get(_key)
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesTrue}}
@ -357,5 +361,9 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
{{#vendorExtensions.x-py-postponed-model-imports}} {{#vendorExtensions.x-py-postponed-model-imports}}
{{{.}}} {{{.}}}
{{/vendorExtensions.x-py-postponed-model-imports}} {{/vendorExtensions.x-py-postponed-model-imports}}
{{classname}}.update_forward_refs() from typing import TYPE_CHECKING
if TYPE_CHECKING:
# TODO: pydantic v2
# {{classname}}.model_rebuild()
pass
{{/vendorExtensions.x-py-postponed-model-imports.size}} {{/vendorExtensions.x-py-postponed-model-imports.size}}

View File

@ -6,10 +6,14 @@ import re # noqa: F401
{{#vendorExtensions.x-py-datetime-imports}}{{#-first}}from datetime import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-datetime-imports}} {{#vendorExtensions.x-py-datetime-imports}}{{#-first}}from datetime import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-datetime-imports}}
{{#vendorExtensions.x-py-typing-imports}}{{#-first}}from typing import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-typing-imports}} {{#vendorExtensions.x-py-typing-imports}}{{#-first}}from typing import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-typing-imports}}
{{#vendorExtensions.x-py-pydantic-imports}}{{#-first}}from pydantic import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-pydantic-imports}} {{#vendorExtensions.x-py-pydantic-imports}}{{#-first}}from pydantic import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-pydantic-imports}}
{{#vendorExtensions.x-py-other-imports}}
{{{.}}}
{{/vendorExtensions.x-py-other-imports}}
{{#vendorExtensions.x-py-model-imports}} {{#vendorExtensions.x-py-model-imports}}
{{{.}}} {{{.}}}
{{/vendorExtensions.x-py-model-imports}} {{/vendorExtensions.x-py-model-imports}}
from typing import Union, Any, List, TYPE_CHECKING from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict
from typing_extensions import Literal
from pydantic import StrictStr, Field from pydantic import StrictStr, Field
{{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ONE_OF_SCHEMAS = [{{#oneOf}}"{{.}}"{{^-last}}, {{/-last}}{{/oneOf}}] {{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ONE_OF_SCHEMAS = [{{#oneOf}}"{{.}}"{{^-last}}, {{/-last}}{{/oneOf}}]
@ -22,17 +26,14 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
# data type: {{{dataType}}} # data type: {{{dataType}}}
{{vendorExtensions.x-py-name}}: {{{vendorExtensions.x-py-typing}}} {{vendorExtensions.x-py-name}}: {{{vendorExtensions.x-py-typing}}}
{{/composedSchemas.oneOf}} {{/composedSchemas.oneOf}}
if TYPE_CHECKING: actual_instance: Optional[Union[{{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}]] = None
actual_instance: Union[{{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}] one_of_schemas: List[str] = Literal[{{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ONE_OF_SCHEMAS]
else:
actual_instance: Any
one_of_schemas: List[str] = Field({{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ONE_OF_SCHEMAS, const=True)
class Config: class Config:
validate_assignment = True validate_assignment = True
{{#discriminator}} {{#discriminator}}
discriminator_value_class_map = { discriminator_value_class_map: Dict[str, str] = {
{{#children}} {{#children}}
'{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}': '{{{classname}}}'{{^-last}},{{/-last}} '{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}': '{{{classname}}}'{{^-last}},{{/-last}}
{{/children}} {{/children}}
@ -200,7 +201,10 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
{{#vendorExtensions.x-py-postponed-model-imports.size}} {{#vendorExtensions.x-py-postponed-model-imports.size}}
{{#vendorExtensions.x-py-postponed-model-imports}} {{#vendorExtensions.x-py-postponed-model-imports}}
from typing import TYPE_CHECKING
if TYPE_CHECKING:
{{{.}}} {{{.}}}
# TODO: pydantic v2
{{/vendorExtensions.x-py-postponed-model-imports}} {{/vendorExtensions.x-py-postponed-model-imports}}
{{classname}}.update_forward_refs() # {{classname}}.model_rebuild()
{{/vendorExtensions.x-py-postponed-model-imports.size}} {{/vendorExtensions.x-py-postponed-model-imports.size}}

View File

@ -24,8 +24,9 @@ tornado = ">=4.2,<5"
pem = ">= 19.3.0" pem = ">= 19.3.0"
pycryptodome = ">= 3.9.0" pycryptodome = ">= 3.9.0"
{{/hasHttpSignatureMethods}} {{/hasHttpSignatureMethods}}
pydantic = "^1.10.5, <2" pydantic = ">=2"
aenum = ">=3.1.11" aenum = ">=3.1.11"
typing-extensions = ">=4.7.1"
[tool.poetry.dev-dependencies] [tool.poetry.dev-dependencies]
pytest = ">=7.2.1" pytest = ">=7.2.1"

View File

@ -1,8 +1,9 @@
python_dateutil >= 2.5.3 python_dateutil >= 2.5.3
setuptools >= 21.0.0 setuptools >= 21.0.0
urllib3 >= 1.25.3, < 2.1.0 urllib3 >= 1.25.3, < 2.1.0
pydantic >= 1.10.5, < 2 pydantic >= 2
aenum >= 3.1.11 aenum >= 3.1.11
typing-extensions >= 4.7.1
{{#asyncio}} {{#asyncio}}
aiohttp >= 3.0.0 aiohttp >= 3.0.0
{{/asyncio}} {{/asyncio}}

View File

@ -29,8 +29,9 @@ REQUIRES = [
"pem>=19.3.0", "pem>=19.3.0",
"pycryptodome>=3.9.0", "pycryptodome>=3.9.0",
{{/hasHttpSignatureMethods}} {{/hasHttpSignatureMethods}}
"pydantic >= 1.10.5, < 2", "pydantic >= 2",
"aenum" "aenum",
"typing-extensions >= 4.7.1",
] ]
setup( setup(

View File

@ -0,0 +1,700 @@
#
# Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
openapi: 3.0.3
info:
title: Echo Server API
description: Echo Server API
contact:
email: team@openapitools.org
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
version: 0.1.0
servers:
- url: http://localhost:3000/
paths:
# Path usually starts with parameter type such as path, query, header, form
# For body/form parameters, path starts with "/echo" so the the echo server
# will response with the same body in the HTTP request.
#
# path parameter tests
/path/string/{path_string}/integer/{path_integer}:
get:
tags:
- path
summary: Test path parameter(s)
description: Test path parameter(s)
operationId: tests/path/string/{path_string}/integer/{path_integer}
parameters:
- in: path
name: path_string
required: true
schema:
type: string
- in: path
name: path_integer
required: true
schema:
type: integer
responses:
'200':
description: Successful operation
content:
text/plain:
schema:
type: string
# form parameter tests
/form/integer/boolean/string:
post:
tags:
- form
summary: Test form parameter(s)
description: Test form parameter(s)
operationId: test/form/integer/boolean/string
requestBody:
content:
application/x-www-form-urlencoded:
schema:
type: object
properties:
integer_form:
type: integer
boolean_form:
type: boolean
string_form:
type: string
responses:
'200':
description: Successful operation
content:
text/plain:
schema:
type: string
# form parameter tests for oneOf schema
/form/oneof:
post:
tags:
- form
summary: Test form parameter(s) for oneOf schema
description: Test form parameter(s) for oneOf schema
operationId: test/form/oneof
requestBody:
content:
application/x-www-form-urlencoded:
schema:
type: object
oneOf:
- type: object
properties:
form1:
type: string
form2:
type: integer
- type: object
properties:
form3:
type: string
form4:
type: boolean
- $ref: '#/components/schemas/Tag'
responses:
'200':
description: Successful operation
content:
text/plain:
schema:
type: string
# header parameter tests
/header/integer/boolean/string:
get:
tags:
- header
summary: Test header parameter(s)
description: Test header parameter(s)
operationId: test/header/integer/boolean/string
parameters:
- in: header
name: integer_header
style: form #default
explode: true #default
schema:
type: integer
- in: header
name: boolean_header
style: form #default
explode: true #default
schema:
type: boolean
- in: header
name: string_header
style: form #default
explode: true #default
schema:
type: string
responses:
'200':
description: Successful operation
content:
text/plain:
schema:
type: string
# query parameter tests
/query/enum_ref_string:
get:
tags:
- query
summary: Test query parameter(s)
description: Test query parameter(s)
operationId: test/enum_ref_string
parameters:
- in: query
name: enum_ref_string_query
style: form #default
explode: true #default
schema:
$ref: '#/components/schemas/StringEnumRef'
responses:
'200':
description: Successful operation
content:
text/plain:
schema:
type: string
/query/datetime/date/string:
get:
tags:
- query
summary: Test query parameter(s)
description: Test query parameter(s)
operationId: test/query/datetime/date/string
parameters:
- in: query
name: datetime_query
style: form #default
explode: true #default
schema:
type: string
format: date-time
- in: query
name: date_query
style: form #default
explode: true #default
schema:
type: string
format: date
- in: query
name: string_query
style: form #default
explode: true #default
schema:
type: string
responses:
'200':
description: Successful operation
content:
text/plain:
schema:
type: string
/query/integer/boolean/string:
get:
tags:
- query
summary: Test query parameter(s)
description: Test query parameter(s)
operationId: test/query/integer/boolean/string
parameters:
- in: query
name: integer_query
style: form #default
explode: true #default
schema:
type: integer
- in: query
name: boolean_query
style: form #default
explode: true #default
schema:
type: boolean
- in: query
name: string_query
style: form #default
explode: true #default
schema:
type: string
responses:
'200':
description: Successful operation
content:
text/plain:
schema:
type: string
/query/style_form/explode_true/array_string:
get:
tags:
- query
summary: Test query parameter(s)
description: Test query parameter(s)
operationId: test/query/style_form/explode_true/array_string
parameters:
- in: query
name: query_object
style: form #default
explode: true #default
schema:
type: object
properties:
values:
type: array
items:
type: string
responses:
'200':
description: Successful operation
content:
text/plain:
schema:
type: string
/query/style_form/explode_true/object:
get:
tags:
- query
summary: Test query parameter(s)
description: Test query parameter(s)
operationId: test/query/style_form/explode_true/object
parameters:
- in: query
name: query_object
style: form #default
explode: true #default
schema:
$ref: '#/components/schemas/Pet'
responses:
'200':
description: Successful operation
content:
text/plain:
schema:
type: string
/query/style_form/explode_true/object/allOf:
get:
tags:
- query
summary: Test query parameter(s)
description: Test query parameter(s)
operationId: test/query/style_form/explode_true/object/allOf
parameters:
- in: query
name: query_object
style: form #default
explode: true #default
schema:
$ref: '#/components/schemas/DataQuery'
responses:
'200':
description: Successful operation
content:
text/plain:
schema:
type: string
/query/style_deepObject/explode_true/object:
get:
tags:
- query
summary: Test query parameter(s)
description: Test query parameter(s)
operationId: test/query/style_deepObject/explode_true/object
parameters:
- in: query
name: query_object
style: deepObject
explode: true #default
schema:
$ref: '#/components/schemas/Pet'
responses:
'200':
description: Successful operation
content:
text/plain:
schema:
type: string
/query/style_deepObject/explode_true/object/allOf:
get:
tags:
- query
summary: Test query parameter(s)
description: Test query parameter(s)
operationId: test/query/style_deepObject/explode_true/object/allOf
parameters:
- in: query
name: query_object
style: deepObject
explode: true #default
schema:
allOf:
- $ref: '#/components/schemas/Bird'
- $ref: '#/components/schemas/Category'
responses:
'200':
description: Successful operation
content:
text/plain:
schema:
type: string
# body parameter tests
/body/application/octetstream/binary:
post:
tags:
- body
summary: Test body parameter(s)
description: Test body parameter(s)
operationId: test/body/application/octetstream/binary
requestBody:
content:
application/octet-stream:
schema:
type: string
format: binary
responses:
'200':
description: Successful operation
content:
text/plain:
schema:
type: string
/echo/body/Pet:
post:
tags:
- body
summary: Test body parameter(s)
description: Test body parameter(s)
operationId: test/echo/body/Pet
requestBody:
$ref: '#/components/requestBodies/Pet'
responses:
'200':
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
/echo/body/Pet/response_string:
post:
tags:
- body
summary: Test empty response body
description: Test empty response body
operationId: test/echo/body/Pet/response_string
requestBody:
$ref: '#/components/requestBodies/Pet'
responses:
'200':
description: Successful operation
content:
text/plain:
schema:
type: string
/echo/body/Tag/response_string:
post:
tags:
- body
summary: Test empty json (request body)
description: Test empty json (request body)
operationId: test/echo/body/Tag/response_string
requestBody:
$ref: '#/components/requestBodies/Tag'
responses:
'200':
description: Successful operation
content:
text/plain:
schema:
type: string
/echo/body/FreeFormObject/response_string:
post:
tags:
- body
summary: Test free form object
description: Test free form object
operationId: test/echo/body/FreeFormObject/response_string
requestBody:
content:
application/json:
schema:
type: object
description: Free form object
responses:
'200':
description: Successful operation
content:
text/plain:
schema:
type: string
/binary/gif:
post:
tags:
- body
summary: Test binary (gif) response body
description: Test binary (gif) response body
operationId: test/binary/gif
responses:
'200':
description: Successful operation
content:
image/gif:
schema:
type: string
format: binary
# Array of binary in multipart mime tests
/body/application/octetstream/array_of_binary:
post:
tags:
- body
summary: Test array of binary in multipart mime
description: Test array of binary in multipart mime
operationId: test/body/multipart/formdata/array_of_binary
requestBody:
content:
multipart/form-data:
schema:
required:
- files
type: object
properties:
files:
type: array
items:
type: string
format: binary
responses:
'200':
description: Successful operation
content:
text/plain:
schema:
type: string
# To test http basic auth
/auth/http/basic:
post:
tags:
- auth
security:
- http_auth: []
summary: To test HTTP basic authentication
description: To test HTTP basic authentication
operationId: test/auth/http/basic
responses:
'200':
description: Successful operation
content:
text/plain:
schema:
type: string
components:
securitySchemes:
http_auth:
type: http
scheme: basic
requestBodies:
Pet:
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
description: Pet object that needs to be added to the store
Tag:
content:
application/json:
schema:
$ref: '#/components/schemas/Tag'
description: Tag object
schemas:
Category:
type: object
properties:
id:
type: integer
format: int64
example: 1
name:
type: string
example: Dogs
xml:
name: category
Tag:
type: object
properties:
id:
type: integer
format: int64
name:
type: string
xml:
name: tag
Pet:
required:
- name
- photoUrls
type: object
properties:
id:
type: integer
format: int64
example: 10
name:
type: string
example: doggie
category:
$ref: '#/components/schemas/Category'
photoUrls:
type: array
xml:
wrapped: true
items:
type: string
xml:
name: photoUrl
tags:
type: array
xml:
wrapped: true
items:
$ref: '#/components/schemas/Tag'
status:
type: string
description: pet status in the store
enum:
- available
- pending
- sold
xml:
name: pet
StringEnumRef:
type: string
enum:
- success
- failure
- unclassified
DefaultValue:
type: object
description: to test the default value of properties
properties:
array_string_enum_ref_default:
type: array
items:
$ref: '#/components/schemas/StringEnumRef'
default:
- success
- failure
array_string_enum_default:
type: array
items:
type: string
enum:
- success
- failure
- unclassified
default:
- success
- failure
array_string_default:
type: array
items:
type: string
default:
- failure
- skipped
array_integer_default:
type: array
items:
type: integer
default:
- 1
- 3
array_string:
type: array
items:
type: string
array_string_nullable:
nullable: true
type: array
items:
type: string
array_string_extension_nullable:
x-nullable: true
type: array
items:
type: string
string_nullable:
type: string
nullable: true
Bird:
type: object
properties:
size:
type: string
color:
type: string
Query:
type: object
x-parent: true
properties:
id:
type: integer
description: Query
format: int64
outcomes:
type: array
items:
type: string
enum:
- SUCCESS
- FAILURE
- SKIPPED
default:
- SUCCESS
- FAILURE
DataQuery:
allOf:
- type: object
properties:
suffix:
type: string
description: test suffix
text:
type: string
description: Some text containing white spaces
example: "Some text"
date:
type: string
format: date-time
description: A date
- $ref: '#/components/schemas/Query'
NumberPropertiesOnly:
type: object
properties:
number:
type: number
# TODO: pydantic v2: this field name override the default `float` type
# If this property is uncommented, consider removing this file
# completely in favor of the parent echo_api.yaml file
#float:
#type: number
#format: float
double:
type: number
format: double
minimum: 0.8
maximum: 50.2

View File

@ -1649,11 +1649,12 @@ components:
maximum: 543.2 maximum: 543.2
minimum: 32.1 minimum: 32.1
type: number type: number
float: # TODO: pydantic v2: this field name override the default `float` type
type: number #float:
format: float #type: number
maximum: 987.6 #format: float
minimum: 54.3 #maximum: 987.6
#minimum: 54.3
double: double:
type: number type: number
format: double format: double

View File

@ -84,12 +84,14 @@ class TestManual(unittest.TestCase):
def testNumberPropertiesOnly(self): def testNumberPropertiesOnly(self):
n = openapi_client.NumberPropertiesOnly.from_json('{"number": 123, "float": 456, "double": 34}') n = openapi_client.NumberPropertiesOnly.from_json('{"number": 123, "float": 456, "double": 34}')
self.assertEqual(n.number, 123) self.assertEqual(n.number, 123)
self.assertEqual(n.float, 456) # TODO: pydantic v2: the "float" property aliases the "float" type in the pydantic v2 generator
# self.assertEqual(n.float, 456)
self.assertEqual(n.double, 34) self.assertEqual(n.double, 34)
n = openapi_client.NumberPropertiesOnly.from_json('{"number": 123.1, "float": 456.2, "double": 34.3}') n = openapi_client.NumberPropertiesOnly.from_json('{"number": 123.1, "float": 456.2, "double": 34.3}')
self.assertEqual(n.number, 123.1) self.assertEqual(n.number, 123.1)
self.assertEqual(n.float, 456.2) # TODO: pydantic v2: the "float" property aliases the "float" type in the pydantic v2 generator
# self.assertEqual(n.float, 456.2)
self.assertEqual(n.double, 34.3) self.assertEqual(n.double, 34.3)
def testApplicatinOctetStreamBinaryBodyParameter(self): def testApplicatinOctetStreamBinaryBodyParameter(self):

View File

@ -5,7 +5,6 @@
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**number** | **float** | | [optional] **number** | **float** | | [optional]
**float** | **float** | | [optional]
**double** | **float** | | [optional] **double** | **float** | | [optional]
## Example ## Example

View File

@ -19,10 +19,11 @@ import warnings
from pydantic import validate_arguments, ValidationError from pydantic import validate_arguments, ValidationError
from pydantic import Field
from typing_extensions import Annotated from typing_extensions import Annotated
from pydantic import Field, StrictBytes, StrictStr, conlist from pydantic import StrictBytes, StrictStr
from typing import Any, Dict, Optional, Union from typing import Any, Dict, List, Optional, Union
from openapi_client.models.pet import Pet from openapi_client.models.pet import Pet
from openapi_client.models.tag import Tag from openapi_client.models.tag import Tag
@ -332,7 +333,7 @@ class BodyApi:
_request_auth=_params.get('_request_auth')) _request_auth=_params.get('_request_auth'))
@validate_arguments @validate_arguments
def test_body_multipart_formdata_array_of_binary(self, files : conlist(Union[StrictBytes, StrictStr]), **kwargs) -> str: # noqa: E501 def test_body_multipart_formdata_array_of_binary(self, files : List[Union[StrictBytes, StrictStr]], **kwargs) -> str: # noqa: E501
"""Test array of binary in multipart mime # noqa: E501 """Test array of binary in multipart mime # noqa: E501
Test array of binary in multipart mime # noqa: E501 Test array of binary in multipart mime # noqa: E501
@ -362,7 +363,7 @@ class BodyApi:
return self.test_body_multipart_formdata_array_of_binary_with_http_info(files, **kwargs) # noqa: E501 return self.test_body_multipart_formdata_array_of_binary_with_http_info(files, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
def test_body_multipart_formdata_array_of_binary_with_http_info(self, files : conlist(Union[StrictBytes, StrictStr]), **kwargs) -> ApiResponse: # noqa: E501 def test_body_multipart_formdata_array_of_binary_with_http_info(self, files : List[Union[StrictBytes, StrictStr]], **kwargs) -> ApiResponse: # noqa: E501
"""Test array of binary in multipart mime # noqa: E501 """Test array of binary in multipart mime # noqa: E501
Test array of binary in multipart mime # noqa: E501 Test array of binary in multipart mime # noqa: E501

View File

@ -41,6 +41,7 @@ class Bird(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod

View File

@ -41,6 +41,7 @@ class Category(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod

View File

@ -20,16 +20,17 @@ import json
from datetime import datetime from datetime import datetime
from typing import Optional from typing import Optional
from pydantic import Field, StrictStr from pydantic import StrictStr
from pydantic import Field
from openapi_client.models.query import Query from openapi_client.models.query import Query
class DataQuery(Query): class DataQuery(Query):
""" """
DataQuery DataQuery
""" """
suffix: Optional[StrictStr] = Field(None, description="test suffix") suffix: Optional[StrictStr] = Field(default=None, description="test suffix")
text: Optional[StrictStr] = Field(None, description="Some text containing white spaces") text: Optional[StrictStr] = Field(default=None, description="Some text containing white spaces")
var_date: Optional[datetime] = Field(None, alias="date", description="A date") var_date: Optional[datetime] = Field(default=None, description="A date", alias="date")
__properties = ["id", "outcomes", "suffix", "text", "date"] __properties = ["id", "outcomes", "suffix", "text", "date"]
class Config: class Config:
@ -43,6 +44,7 @@ class DataQuery(Query):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -72,7 +74,7 @@ class DataQuery(Query):
"outcomes": obj.get("outcomes"), "outcomes": obj.get("outcomes"),
"suffix": obj.get("suffix"), "suffix": obj.get("suffix"),
"text": obj.get("text"), "text": obj.get("text"),
"var_date": obj.get("date") "date": obj.get("date")
}) })
return _obj return _obj

View File

@ -20,20 +20,20 @@ import json
from typing import List, Optional from typing import List, Optional
from pydantic import BaseModel, StrictInt, StrictStr, conlist, validator from pydantic import BaseModel, StrictInt, StrictStr, validator
from openapi_client.models.string_enum_ref import StringEnumRef from openapi_client.models.string_enum_ref import StringEnumRef
class DefaultValue(BaseModel): class DefaultValue(BaseModel):
""" """
to test the default value of properties # noqa: E501 to test the default value of properties # noqa: E501
""" """
array_string_enum_ref_default: Optional[conlist(StringEnumRef)] = None array_string_enum_ref_default: Optional[List[StringEnumRef]] = None
array_string_enum_default: Optional[conlist(StrictStr)] = None array_string_enum_default: Optional[List[StrictStr]] = None
array_string_default: Optional[conlist(StrictStr)] = None array_string_default: Optional[List[StrictStr]] = None
array_integer_default: Optional[conlist(StrictInt)] = None array_integer_default: Optional[List[StrictInt]] = None
array_string: Optional[conlist(StrictStr)] = None array_string: Optional[List[StrictStr]] = None
array_string_nullable: Optional[conlist(StrictStr)] = None array_string_nullable: Optional[List[StrictStr]] = None
array_string_extension_nullable: Optional[conlist(StrictStr)] = None array_string_extension_nullable: Optional[List[StrictStr]] = None
string_nullable: Optional[StrictStr] = None string_nullable: Optional[StrictStr] = None
__properties = ["array_string_enum_ref_default", "array_string_enum_default", "array_string_default", "array_integer_default", "array_string", "array_string_nullable", "array_string_extension_nullable", "string_nullable"] __properties = ["array_string_enum_ref_default", "array_string_enum_default", "array_string_default", "array_integer_default", "array_string", "array_string_nullable", "array_string_extension_nullable", "string_nullable"]
@ -59,6 +59,7 @@ class DefaultValue(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod

View File

@ -20,16 +20,17 @@ import json
from typing import Optional, Union from typing import Optional, Union
from pydantic import BaseModel, StrictFloat, StrictInt, confloat, conint from pydantic import BaseModel, StrictFloat, StrictInt
from pydantic import Field
from typing_extensions import Annotated
class NumberPropertiesOnly(BaseModel): class NumberPropertiesOnly(BaseModel):
""" """
NumberPropertiesOnly NumberPropertiesOnly
""" """
number: Optional[Union[StrictFloat, StrictInt]] = None number: Optional[Union[StrictFloat, StrictInt]] = None
float: Optional[Union[StrictFloat, StrictInt]] = None double: Optional[Union[Annotated[float, Field(le=50.2, strict=True, ge=0.8)], Annotated[int, Field(le=50, strict=True, ge=1)]]] = None
double: Optional[Union[confloat(le=50.2, ge=0.8, strict=True), conint(le=50, ge=1, strict=True)]] = None __properties = ["number", "double"]
__properties = ["number", "float", "double"]
class Config: class Config:
"""Pydantic configuration""" """Pydantic configuration"""
@ -42,6 +43,7 @@ class NumberPropertiesOnly(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -68,7 +70,6 @@ class NumberPropertiesOnly(BaseModel):
_obj = NumberPropertiesOnly.parse_obj({ _obj = NumberPropertiesOnly.parse_obj({
"number": obj.get("number"), "number": obj.get("number"),
"float": obj.get("float"),
"double": obj.get("double") "double": obj.get("double")
}) })
return _obj return _obj

View File

@ -20,7 +20,8 @@ import json
from typing import List, Optional from typing import List, Optional
from pydantic import BaseModel, Field, StrictInt, StrictStr, conlist, validator from pydantic import BaseModel, StrictInt, StrictStr, validator
from pydantic import Field
from openapi_client.models.category import Category from openapi_client.models.category import Category
from openapi_client.models.tag import Tag from openapi_client.models.tag import Tag
@ -29,11 +30,11 @@ class Pet(BaseModel):
Pet Pet
""" """
id: Optional[StrictInt] = None id: Optional[StrictInt] = None
name: StrictStr = Field(...) name: StrictStr
category: Optional[Category] = None category: Optional[Category] = None
photo_urls: conlist(StrictStr) = Field(..., alias="photoUrls") photo_urls: List[StrictStr] = Field(alias="photoUrls")
tags: Optional[conlist(Tag)] = None tags: Optional[List[Tag]] = None
status: Optional[StrictStr] = Field(None, description="pet status in the store") status: Optional[StrictStr] = Field(default=None, description="pet status in the store")
__properties = ["id", "name", "category", "photoUrls", "tags", "status"] __properties = ["id", "name", "category", "photoUrls", "tags", "status"]
@validator('status') @validator('status')
@ -57,6 +58,7 @@ class Pet(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -95,7 +97,7 @@ class Pet(BaseModel):
"id": obj.get("id"), "id": obj.get("id"),
"name": obj.get("name"), "name": obj.get("name"),
"category": Category.from_dict(obj.get("category")) if obj.get("category") is not None else None, "category": Category.from_dict(obj.get("category")) if obj.get("category") is not None else None,
"photo_urls": obj.get("photoUrls"), "photoUrls": obj.get("photoUrls"),
"tags": [Tag.from_dict(_item) for _item in obj.get("tags")] if obj.get("tags") is not None else None, "tags": [Tag.from_dict(_item) for _item in obj.get("tags")] if obj.get("tags") is not None else None,
"status": obj.get("status") "status": obj.get("status")
}) })

View File

@ -20,14 +20,15 @@ import json
from typing import List, Optional from typing import List, Optional
from pydantic import BaseModel, Field, StrictInt, StrictStr, conlist, validator from pydantic import BaseModel, StrictInt, StrictStr, validator
from pydantic import Field
class Query(BaseModel): class Query(BaseModel):
""" """
Query Query
""" """
id: Optional[StrictInt] = Field(None, description="Query") id: Optional[StrictInt] = Field(default=None, description="Query")
outcomes: Optional[conlist(StrictStr)] = None outcomes: Optional[List[StrictStr]] = None
__properties = ["id", "outcomes"] __properties = ["id", "outcomes"]
@validator('outcomes') @validator('outcomes')
@ -52,6 +53,7 @@ class Query(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod

View File

@ -41,6 +41,7 @@ class Tag(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod

View File

@ -43,6 +43,7 @@ class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter(BaseMod
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod

View File

@ -20,13 +20,13 @@ import json
from typing import List, Optional from typing import List, Optional
from pydantic import BaseModel, StrictStr, conlist from pydantic import BaseModel, StrictStr
class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(BaseModel): class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(BaseModel):
""" """
TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter
""" """
values: Optional[conlist(StrictStr)] = None values: Optional[List[StrictStr]] = None
__properties = ["values"] __properties = ["values"]
class Config: class Config:
@ -40,6 +40,7 @@ class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod

View File

@ -14,8 +14,9 @@ python = "^3.7"
urllib3 = ">= 1.25.3" urllib3 = ">= 1.25.3"
python-dateutil = ">=2.8.2" python-dateutil = ">=2.8.2"
pydantic = "^1.10.5, <2" pydantic = ">=2"
aenum = ">=3.1.11" aenum = ">=3.1.11"
typing-extensions = ">=4.7.1"
[tool.poetry.dev-dependencies] [tool.poetry.dev-dependencies]
pytest = ">=7.2.1" pytest = ">=7.2.1"

View File

@ -1,5 +1,6 @@
python_dateutil >= 2.5.3 python_dateutil >= 2.5.3
setuptools >= 21.0.0 setuptools >= 21.0.0
urllib3 >= 1.25.3, < 2.1.0 urllib3 >= 1.25.3, < 2.1.0
pydantic >= 1.10.5, < 2 pydantic >= 2
aenum >= 3.1.11 aenum >= 3.1.11
typing-extensions >= 4.7.1

View File

@ -27,8 +27,9 @@ PYTHON_REQUIRES = ">=3.7"
REQUIRES = [ REQUIRES = [
"urllib3 >= 1.25.3, < 2.1.0", "urllib3 >= 1.25.3, < 2.1.0",
"python-dateutil", "python-dateutil",
"pydantic >= 1.10.5, < 2", "pydantic >= 2",
"aenum" "aenum",
"typing-extensions >= 4.7.1",
] ]
setup( setup(

View File

@ -84,12 +84,14 @@ class TestManual(unittest.TestCase):
def testNumberPropertiesOnly(self): def testNumberPropertiesOnly(self):
n = openapi_client.NumberPropertiesOnly.from_json('{"number": 123, "float": 456, "double": 34}') n = openapi_client.NumberPropertiesOnly.from_json('{"number": 123, "float": 456, "double": 34}')
self.assertEqual(n.number, 123) self.assertEqual(n.number, 123)
self.assertEqual(n.float, 456) # TODO: pydantic v2: this field name override the default `float` type
# self.assertEqual(n.float, 456)
self.assertEqual(n.double, 34) self.assertEqual(n.double, 34)
n = openapi_client.NumberPropertiesOnly.from_json('{"number": 123.1, "float": 456.2, "double": 34.3}') n = openapi_client.NumberPropertiesOnly.from_json('{"number": 123.1, "float": 456.2, "double": 34.3}')
self.assertEqual(n.number, 123.1) self.assertEqual(n.number, 123.1)
self.assertEqual(n.float, 456.2) # TODO: pydantic v2: this field name override the default `float` type
# self.assertEqual(n.float, 456.2)
self.assertEqual(n.double, 34.3) self.assertEqual(n.double, 34.3)
def testApplicatinOctetStreamBinaryBodyParameter(self): def testApplicatinOctetStreamBinaryBodyParameter(self):

View File

@ -8,7 +8,6 @@ Name | Type | Description | Notes
**int32** | **int** | | [optional] **int32** | **int** | | [optional]
**int64** | **int** | | [optional] **int64** | **int** | | [optional]
**number** | **float** | | **number** | **float** | |
**float** | **float** | | [optional]
**double** | **float** | | [optional] **double** | **float** | | [optional]
**decimal** | **decimal.Decimal** | | [optional] **decimal** | **decimal.Decimal** | | [optional]
**string** | **str** | | [optional] **string** | **str** | | [optional]

View File

@ -17,11 +17,9 @@ import io
import warnings import warnings
from pydantic import validate_arguments, ValidationError from pydantic import validate_arguments, ValidationError
from typing import overload, Optional, Union, Awaitable
from typing_extensions import Annotated
from pydantic import Field from pydantic import Field
from typing_extensions import Annotated
from petstore_api.models.client import Client from petstore_api.models.client import Client
from petstore_api.api_client import ApiClient from petstore_api.api_client import ApiClient
@ -45,7 +43,7 @@ class AnotherFakeApi:
self.api_client = api_client self.api_client = api_client
@validate_arguments @validate_arguments
async def call_123_test_special_tags(self, client : Annotated[Client, Field(..., description="client model")], **kwargs) -> Client: # noqa: E501 async 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 # noqa: E501
To test special tags and operation ID starting with number # noqa: E501 To test special tags and operation ID starting with number # noqa: E501
@ -68,7 +66,7 @@ class AnotherFakeApi:
return await self.call_123_test_special_tags_with_http_info(client, **kwargs) # noqa: E501 return await self.call_123_test_special_tags_with_http_info(client, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async def call_123_test_special_tags_with_http_info(self, client : Annotated[Client, Field(..., description="client model")], **kwargs) -> ApiResponse: # noqa: E501 async 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 # noqa: E501
To test special tags and operation ID starting with number # noqa: E501 To test special tags and operation ID starting with number # noqa: E501

View File

@ -17,7 +17,6 @@ import io
import warnings import warnings
from pydantic import validate_arguments, ValidationError from pydantic import validate_arguments, ValidationError
from typing import overload, Optional, Union, Awaitable
from petstore_api.models.foo_get_default_response import FooGetDefaultResponse from petstore_api.models.foo_get_default_response import FooGetDefaultResponse

View File

@ -17,12 +17,12 @@ import io
import warnings import warnings
from pydantic import validate_arguments, ValidationError from pydantic import validate_arguments, ValidationError
from typing import overload, Optional, Union, Awaitable
from pydantic import Field
from typing_extensions import Annotated from typing_extensions import Annotated
from datetime import date, datetime from datetime import date, datetime
from pydantic import Field, StrictBool, StrictBytes, StrictInt, StrictStr, conbytes, confloat, conint, conlist, constr, validator from pydantic import StrictBool, StrictBytes, StrictInt, StrictStr, validator
from typing import Any, Dict, List, Optional, Union from typing import Any, Dict, List, Optional, Union
@ -411,7 +411,7 @@ class FakeApi:
_request_auth=_params.get('_request_auth')) _request_auth=_params.get('_request_auth'))
@validate_arguments @validate_arguments
async 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 async 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 """test http signature authentication # noqa: E501
@ -437,7 +437,7 @@ class FakeApi:
return await self.fake_http_signature_test_with_http_info(pet, query_1, header_1, **kwargs) # noqa: E501 return await self.fake_http_signature_test_with_http_info(pet, query_1, header_1, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async 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 async 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 """test http signature authentication # noqa: E501
@ -1074,7 +1074,7 @@ class FakeApi:
_request_auth=_params.get('_request_auth')) _request_auth=_params.get('_request_auth'))
@validate_arguments @validate_arguments
async 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 async 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 """fake_property_enum_integer_serialize # noqa: E501
Test serialization of enum (int) properties with examples # noqa: E501 Test serialization of enum (int) properties with examples # noqa: E501
@ -1097,7 +1097,7 @@ class FakeApi:
return await self.fake_property_enum_integer_serialize_with_http_info(outer_object_with_enum_property, **kwargs) # noqa: E501 return await self.fake_property_enum_integer_serialize_with_http_info(outer_object_with_enum_property, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async 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 async 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 """fake_property_enum_integer_serialize # noqa: E501
Test serialization of enum (int) properties with examples # noqa: E501 Test serialization of enum (int) properties with examples # noqa: E501
@ -1319,7 +1319,7 @@ class FakeApi:
_request_auth=_params.get('_request_auth')) _request_auth=_params.get('_request_auth'))
@validate_arguments @validate_arguments
async def fake_uuid_example(self, uuid_example : Annotated[StrictStr, Field(..., description="uuid example")], **kwargs) -> None: # noqa: E501 async def fake_uuid_example(self, uuid_example : Annotated[StrictStr, Field(description="uuid example")], **kwargs) -> None: # noqa: E501
"""test uuid example # noqa: E501 """test uuid example # noqa: E501
@ -1341,7 +1341,7 @@ class FakeApi:
return await self.fake_uuid_example_with_http_info(uuid_example, **kwargs) # noqa: E501 return await self.fake_uuid_example_with_http_info(uuid_example, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async def fake_uuid_example_with_http_info(self, uuid_example : Annotated[StrictStr, Field(..., description="uuid example")], **kwargs) -> ApiResponse: # noqa: E501 async 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 """test uuid example # noqa: E501
@ -1435,7 +1435,7 @@ class FakeApi:
_request_auth=_params.get('_request_auth')) _request_auth=_params.get('_request_auth'))
@validate_arguments @validate_arguments
async def test_body_with_binary(self, body : Annotated[Optional[Union[StrictBytes, StrictStr]], Field(..., description="image to upload")], **kwargs) -> None: # noqa: E501 async 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 """test_body_with_binary # noqa: E501
For this test, the body has to be a binary file. # noqa: E501 For this test, the body has to be a binary file. # noqa: E501
@ -1458,7 +1458,7 @@ class FakeApi:
return await self.test_body_with_binary_with_http_info(body, **kwargs) # noqa: E501 return await self.test_body_with_binary_with_http_info(body, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async def test_body_with_binary_with_http_info(self, body : Annotated[Optional[Union[StrictBytes, StrictStr]], Field(..., description="image to upload")], **kwargs) -> ApiResponse: # noqa: E501 async 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 """test_body_with_binary # noqa: E501
For this test, the body has to be a binary file. # noqa: E501 For this test, the body has to be a binary file. # noqa: E501
@ -1821,7 +1821,7 @@ class FakeApi:
_request_auth=_params.get('_request_auth')) _request_auth=_params.get('_request_auth'))
@validate_arguments @validate_arguments
async def test_client_model(self, client : Annotated[Client, Field(..., description="client model")], **kwargs) -> Client: # noqa: E501 async 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
To test \"client\" model # noqa: E501 To test \"client\" model # noqa: E501
@ -1844,7 +1844,7 @@ class FakeApi:
return await self.test_client_model_with_http_info(client, **kwargs) # noqa: E501 return await self.test_client_model_with_http_info(client, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async def test_client_model_with_http_info(self, client : Annotated[Client, Field(..., description="client model")], **kwargs) -> ApiResponse: # noqa: E501 async 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
To test \"client\" model # noqa: E501 To test \"client\" model # noqa: E501
@ -2079,7 +2079,7 @@ class FakeApi:
_request_auth=_params.get('_request_auth')) _request_auth=_params.get('_request_auth'))
@validate_arguments @validate_arguments
async def test_endpoint_parameters(self, number : Annotated[confloat(le=543.2, ge=32.1), Field(..., description="None")], double : Annotated[confloat(le=123.4, ge=67.8), 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)], 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 async def test_endpoint_parameters(self, number : Annotated[float, Field(le=543.2, ge=32.1, description="None")], double : Annotated[float, Field(le=123.4, ge=67.8, description="None")], pattern_without_delimiter : Annotated[str, Field(strict=True, description="None")], byte : Annotated[Union[StrictBytes, StrictStr], Field(description="None")], integer : Annotated[Optional[Annotated[int, Field(le=100, strict=True, ge=10)]], Field(description="None")] = None, int32 : Annotated[Optional[Annotated[int, Field(le=200, strict=True, ge=20)]], Field(description="None")] = None, int64 : Annotated[Optional[StrictInt], Field(description="None")] = None, float : Annotated[Optional[Annotated[float, Field(le=987.6)]], Field(description="None")] = None, string : Annotated[Optional[Annotated[str, Field(strict=True)]], Field(description="None")] = None, binary : Annotated[Optional[Union[StrictBytes, StrictStr]], Field(description="None")] = None, byte_with_max_length : Annotated[Optional[Union[Annotated[bytes, Field(strict=True, max_length=64)], Annotated[str, Field(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[Annotated[str, Field(min_length=10, strict=True, max_length=64)]], 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
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501
@ -2130,7 +2130,7 @@ class FakeApi:
return await 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 return await 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_arguments @validate_arguments
async def test_endpoint_parameters_with_http_info(self, number : Annotated[confloat(le=543.2, ge=32.1), Field(..., description="None")], double : Annotated[confloat(le=123.4, ge=67.8), 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)], 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 async def test_endpoint_parameters_with_http_info(self, number : Annotated[float, Field(le=543.2, ge=32.1, description="None")], double : Annotated[float, Field(le=123.4, ge=67.8, description="None")], pattern_without_delimiter : Annotated[str, Field(strict=True, description="None")], byte : Annotated[Union[StrictBytes, StrictStr], Field(description="None")], integer : Annotated[Optional[Annotated[int, Field(le=100, strict=True, ge=10)]], Field(description="None")] = None, int32 : Annotated[Optional[Annotated[int, Field(le=200, strict=True, ge=20)]], Field(description="None")] = None, int64 : Annotated[Optional[StrictInt], Field(description="None")] = None, float : Annotated[Optional[Annotated[float, Field(le=987.6)]], Field(description="None")] = None, string : Annotated[Optional[Annotated[str, Field(strict=True)]], Field(description="None")] = None, binary : Annotated[Optional[Union[StrictBytes, StrictStr]], Field(description="None")] = None, byte_with_max_length : Annotated[Optional[Union[Annotated[bytes, Field(strict=True, max_length=64)], Annotated[str, Field(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[Annotated[str, Field(min_length=10, strict=True, max_length=64)]], 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
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501
@ -2316,7 +2316,7 @@ class FakeApi:
_request_auth=_params.get('_request_auth')) _request_auth=_params.get('_request_auth'))
@validate_arguments @validate_arguments
async 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 async 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
Fake endpoint to test group parameters (optional) # noqa: E501 Fake endpoint to test group parameters (optional) # noqa: E501
@ -2349,7 +2349,7 @@ class FakeApi:
return await 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 return await 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_arguments @validate_arguments
async 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 async 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
Fake endpoint to test group parameters (optional) # noqa: E501 Fake endpoint to test group parameters (optional) # noqa: E501
@ -2474,7 +2474,7 @@ class FakeApi:
_request_auth=_params.get('_request_auth')) _request_auth=_params.get('_request_auth'))
@validate_arguments @validate_arguments
async def test_inline_additional_properties(self, request_body : Annotated[Dict[str, StrictStr], Field(..., description="request body")], **kwargs) -> None: # noqa: E501 async 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 """test inline additionalProperties # noqa: E501
# noqa: E501 # noqa: E501
@ -2497,7 +2497,7 @@ class FakeApi:
return await self.test_inline_additional_properties_with_http_info(request_body, **kwargs) # noqa: E501 return await self.test_inline_additional_properties_with_http_info(request_body, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async def test_inline_additional_properties_with_http_info(self, request_body : Annotated[Dict[str, StrictStr], Field(..., description="request body")], **kwargs) -> ApiResponse: # noqa: E501 async 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 """test inline additionalProperties # noqa: E501
# noqa: E501 # noqa: E501
@ -2599,7 +2599,7 @@ class FakeApi:
_request_auth=_params.get('_request_auth')) _request_auth=_params.get('_request_auth'))
@validate_arguments @validate_arguments
async def test_inline_freeform_additional_properties(self, test_inline_freeform_additional_properties_request : Annotated[TestInlineFreeformAdditionalPropertiesRequest, Field(..., description="request body")], **kwargs) -> None: # noqa: E501 async def test_inline_freeform_additional_properties(self, test_inline_freeform_additional_properties_request : Annotated[TestInlineFreeformAdditionalPropertiesRequest, Field(description="request body")], **kwargs) -> None: # noqa: E501
"""test inline free-form additionalProperties # noqa: E501 """test inline free-form additionalProperties # noqa: E501
# noqa: E501 # noqa: E501
@ -2622,7 +2622,7 @@ class FakeApi:
return await self.test_inline_freeform_additional_properties_with_http_info(test_inline_freeform_additional_properties_request, **kwargs) # noqa: E501 return await self.test_inline_freeform_additional_properties_with_http_info(test_inline_freeform_additional_properties_request, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async def test_inline_freeform_additional_properties_with_http_info(self, test_inline_freeform_additional_properties_request : Annotated[TestInlineFreeformAdditionalPropertiesRequest, Field(..., description="request body")], **kwargs) -> ApiResponse: # noqa: E501 async def test_inline_freeform_additional_properties_with_http_info(self, test_inline_freeform_additional_properties_request : Annotated[TestInlineFreeformAdditionalPropertiesRequest, Field(description="request body")], **kwargs) -> ApiResponse: # noqa: E501
"""test inline free-form additionalProperties # noqa: E501 """test inline free-form additionalProperties # noqa: E501
# noqa: E501 # noqa: E501
@ -2724,7 +2724,7 @@ class FakeApi:
_request_auth=_params.get('_request_auth')) _request_auth=_params.get('_request_auth'))
@validate_arguments @validate_arguments
async def test_json_form_data(self, param : Annotated[StrictStr, Field(..., description="field1")], param2 : Annotated[StrictStr, Field(..., description="field2")], **kwargs) -> None: # noqa: E501 async 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 """test json serialization of form data # noqa: E501
# noqa: E501 # noqa: E501
@ -2749,7 +2749,7 @@ class FakeApi:
return await self.test_json_form_data_with_http_info(param, param2, **kwargs) # noqa: E501 return await self.test_json_form_data_with_http_info(param, param2, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async 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 async 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 """test json serialization of form data # noqa: E501
# noqa: E501 # noqa: E501
@ -2857,7 +2857,7 @@ class FakeApi:
_request_auth=_params.get('_request_auth')) _request_auth=_params.get('_request_auth'))
@validate_arguments @validate_arguments
async 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 async def test_query_parameter_collection_format(self, pipe : List[StrictStr], ioutil : List[StrictStr], http : List[StrictStr], url : List[StrictStr], context : List[StrictStr], allow_empty : StrictStr, language : Optional[Dict[str, StrictStr]] = None, **kwargs) -> None: # noqa: E501
"""test_query_parameter_collection_format # noqa: E501 """test_query_parameter_collection_format # noqa: E501
To test the collection format in query parameters # noqa: E501 To test the collection format in query parameters # noqa: E501
@ -2892,7 +2892,7 @@ class FakeApi:
return await self.test_query_parameter_collection_format_with_http_info(pipe, ioutil, http, url, context, allow_empty, language, **kwargs) # noqa: E501 return await self.test_query_parameter_collection_format_with_http_info(pipe, ioutil, http, url, context, allow_empty, language, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async 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 async def test_query_parameter_collection_format_with_http_info(self, pipe : List[StrictStr], ioutil : List[StrictStr], http : List[StrictStr], url : List[StrictStr], context : List[StrictStr], allow_empty : StrictStr, language : Optional[Dict[str, StrictStr]] = None, **kwargs) -> ApiResponse: # noqa: E501
"""test_query_parameter_collection_format # noqa: E501 """test_query_parameter_collection_format # noqa: E501
To test the collection format in query parameters # noqa: E501 To test the collection format in query parameters # noqa: E501

View File

@ -17,11 +17,9 @@ import io
import warnings import warnings
from pydantic import validate_arguments, ValidationError from pydantic import validate_arguments, ValidationError
from typing import overload, Optional, Union, Awaitable
from typing_extensions import Annotated
from pydantic import Field from pydantic import Field
from typing_extensions import Annotated
from petstore_api.models.client import Client from petstore_api.models.client import Client
from petstore_api.api_client import ApiClient from petstore_api.api_client import ApiClient
@ -45,7 +43,7 @@ class FakeClassnameTags123Api:
self.api_client = api_client self.api_client = api_client
@validate_arguments @validate_arguments
async def test_classname(self, client : Annotated[Client, Field(..., description="client model")], **kwargs) -> Client: # noqa: E501 async 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
To test class name in snake case # noqa: E501 To test class name in snake case # noqa: E501
@ -68,7 +66,7 @@ class FakeClassnameTags123Api:
return await self.test_classname_with_http_info(client, **kwargs) # noqa: E501 return await self.test_classname_with_http_info(client, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async def test_classname_with_http_info(self, client : Annotated[Client, Field(..., description="client model")], **kwargs) -> ApiResponse: # noqa: E501 async 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
To test class name in snake case # noqa: E501 To test class name in snake case # noqa: E501

View File

@ -17,10 +17,10 @@ import io
import warnings import warnings
from pydantic import validate_arguments, ValidationError from pydantic import validate_arguments, ValidationError
from typing import overload, Optional, Union, Awaitable
from pydantic import Field
from typing_extensions import Annotated from typing_extensions import Annotated
from pydantic import Field, StrictBytes, StrictInt, StrictStr, conlist, validator from pydantic import StrictBytes, StrictInt, StrictStr, validator
from typing import List, Optional, Union from typing import List, Optional, Union
@ -48,7 +48,7 @@ class PetApi:
self.api_client = api_client self.api_client = api_client
@validate_arguments @validate_arguments
async def add_pet(self, pet : Annotated[Pet, Field(..., description="Pet object that needs to be added to the store")], **kwargs) -> None: # noqa: E501 async 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 """Add a new pet to the store # noqa: E501
# noqa: E501 # noqa: E501
@ -71,7 +71,7 @@ class PetApi:
return await self.add_pet_with_http_info(pet, **kwargs) # noqa: E501 return await self.add_pet_with_http_info(pet, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async 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 async 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 """Add a new pet to the store # noqa: E501
# noqa: E501 # noqa: E501
@ -173,7 +173,7 @@ class PetApi:
_request_auth=_params.get('_request_auth')) _request_auth=_params.get('_request_auth'))
@validate_arguments @validate_arguments
async def delete_pet(self, pet_id : Annotated[StrictInt, Field(..., description="Pet id to delete")], api_key : Optional[StrictStr] = None, **kwargs) -> None: # noqa: E501 async 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 """Deletes a pet # noqa: E501
# noqa: E501 # noqa: E501
@ -198,7 +198,7 @@ class PetApi:
return await self.delete_pet_with_http_info(pet_id, api_key, **kwargs) # noqa: E501 return await self.delete_pet_with_http_info(pet_id, api_key, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async 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 async 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 """Deletes a pet # noqa: E501
# noqa: E501 # noqa: E501
@ -299,7 +299,7 @@ class PetApi:
_request_auth=_params.get('_request_auth')) _request_auth=_params.get('_request_auth'))
@validate_arguments @validate_arguments
async 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 async def find_pets_by_status(self, status : Annotated[List[StrictStr], Field(description="Status values that need to be considered for filter")], **kwargs) -> List[Pet]: # noqa: E501
"""Finds Pets by status # noqa: E501 """Finds Pets by status # noqa: E501
Multiple status values can be provided with comma separated strings # noqa: E501 Multiple status values can be provided with comma separated strings # noqa: E501
@ -322,7 +322,7 @@ class PetApi:
return await self.find_pets_by_status_with_http_info(status, **kwargs) # noqa: E501 return await self.find_pets_by_status_with_http_info(status, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async 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 async def find_pets_by_status_with_http_info(self, status : Annotated[List[StrictStr], Field(description="Status values that need to be considered for filter")], **kwargs) -> ApiResponse: # noqa: E501
"""Finds Pets by status # noqa: E501 """Finds Pets by status # noqa: E501
Multiple status values can be provided with comma separated strings # noqa: E501 Multiple status values can be provided with comma separated strings # noqa: E501
@ -425,7 +425,7 @@ class PetApi:
_request_auth=_params.get('_request_auth')) _request_auth=_params.get('_request_auth'))
@validate_arguments @validate_arguments
async def find_pets_by_tags(self, tags : Annotated[conlist(StrictStr, unique_items=True), Field(..., description="Tags to filter by")], **kwargs) -> List[Pet]: # noqa: E501 async def find_pets_by_tags(self, tags : Annotated[List[StrictStr], Field(description="Tags to filter by")], **kwargs) -> List[Pet]: # noqa: E501
"""(Deprecated) Finds Pets by tags # 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 Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. # noqa: E501
@ -448,7 +448,7 @@ class PetApi:
return await self.find_pets_by_tags_with_http_info(tags, **kwargs) # noqa: E501 return await self.find_pets_by_tags_with_http_info(tags, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async def find_pets_by_tags_with_http_info(self, tags : Annotated[conlist(StrictStr, unique_items=True), Field(..., description="Tags to filter by")], **kwargs) -> ApiResponse: # noqa: E501 async def find_pets_by_tags_with_http_info(self, tags : Annotated[List[StrictStr], Field(description="Tags to filter by")], **kwargs) -> ApiResponse: # noqa: E501
"""(Deprecated) Finds Pets by tags # 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 Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. # noqa: E501
@ -553,7 +553,7 @@ class PetApi:
_request_auth=_params.get('_request_auth')) _request_auth=_params.get('_request_auth'))
@validate_arguments @validate_arguments
async def get_pet_by_id(self, pet_id : Annotated[StrictInt, Field(..., description="ID of pet to return")], **kwargs) -> Pet: # noqa: E501 async 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 """Find pet by ID # noqa: E501
Returns a single pet # noqa: E501 Returns a single pet # noqa: E501
@ -576,7 +576,7 @@ class PetApi:
return await self.get_pet_by_id_with_http_info(pet_id, **kwargs) # noqa: E501 return await self.get_pet_by_id_with_http_info(pet_id, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async def get_pet_by_id_with_http_info(self, pet_id : Annotated[StrictInt, Field(..., description="ID of pet to return")], **kwargs) -> ApiResponse: # noqa: E501 async 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 """Find pet by ID # noqa: E501
Returns a single pet # noqa: E501 Returns a single pet # noqa: E501
@ -679,7 +679,7 @@ class PetApi:
_request_auth=_params.get('_request_auth')) _request_auth=_params.get('_request_auth'))
@validate_arguments @validate_arguments
async def update_pet(self, pet : Annotated[Pet, Field(..., description="Pet object that needs to be added to the store")], **kwargs) -> None: # noqa: E501 async 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 """Update an existing pet # noqa: E501
# noqa: E501 # noqa: E501
@ -702,7 +702,7 @@ class PetApi:
return await self.update_pet_with_http_info(pet, **kwargs) # noqa: E501 return await self.update_pet_with_http_info(pet, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async 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 async 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 """Update an existing pet # noqa: E501
# noqa: E501 # noqa: E501
@ -804,7 +804,7 @@ class PetApi:
_request_auth=_params.get('_request_auth')) _request_auth=_params.get('_request_auth'))
@validate_arguments @validate_arguments
async 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 async 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 """Updates a pet in the store with form data # noqa: E501
# noqa: E501 # noqa: E501
@ -831,7 +831,7 @@ class PetApi:
return await self.update_pet_with_form_with_http_info(pet_id, name, status, **kwargs) # noqa: E501 return await self.update_pet_with_form_with_http_info(pet_id, name, status, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async 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 async 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 """Updates a pet in the store with form data # noqa: E501
# noqa: E501 # noqa: E501
@ -945,7 +945,7 @@ class PetApi:
_request_auth=_params.get('_request_auth')) _request_auth=_params.get('_request_auth'))
@validate_arguments @validate_arguments
async 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 async 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 """uploads an image # noqa: E501
# noqa: E501 # noqa: E501
@ -972,7 +972,7 @@ class PetApi:
return await self.upload_file_with_http_info(pet_id, additional_metadata, file, **kwargs) # noqa: E501 return await self.upload_file_with_http_info(pet_id, additional_metadata, file, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async 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 async 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 """uploads an image # noqa: E501
# noqa: E501 # noqa: E501
@ -1092,7 +1092,7 @@ class PetApi:
_request_auth=_params.get('_request_auth')) _request_auth=_params.get('_request_auth'))
@validate_arguments @validate_arguments
async 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 async 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 """uploads an image (required) # noqa: E501
# noqa: E501 # noqa: E501
@ -1119,7 +1119,7 @@ class PetApi:
return await self.upload_file_with_required_file_with_http_info(pet_id, required_file, additional_metadata, **kwargs) # noqa: E501 return await self.upload_file_with_required_file_with_http_info(pet_id, required_file, additional_metadata, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async 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 async 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 """uploads an image (required) # noqa: E501
# noqa: E501 # noqa: E501

View File

@ -17,10 +17,10 @@ import io
import warnings import warnings
from pydantic import validate_arguments, ValidationError from pydantic import validate_arguments, ValidationError
from typing import overload, Optional, Union, Awaitable
from pydantic import Field
from typing_extensions import Annotated from typing_extensions import Annotated
from pydantic import Field, StrictStr, conint from pydantic import StrictStr
from typing import Dict from typing import Dict
@ -47,7 +47,7 @@ class StoreApi:
self.api_client = api_client self.api_client = api_client
@validate_arguments @validate_arguments
async def delete_order(self, order_id : Annotated[StrictStr, Field(..., description="ID of the order that needs to be deleted")], **kwargs) -> None: # noqa: E501 async 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 """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 For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors # noqa: E501
@ -70,7 +70,7 @@ class StoreApi:
return await self.delete_order_with_http_info(order_id, **kwargs) # noqa: E501 return await self.delete_order_with_http_info(order_id, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async 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 async 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 """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 For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors # noqa: E501
@ -281,7 +281,7 @@ class StoreApi:
_request_auth=_params.get('_request_auth')) _request_auth=_params.get('_request_auth'))
@validate_arguments @validate_arguments
async 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 async def get_order_by_id(self, order_id : Annotated[int, Field(le=5, strict=True, ge=1, description="ID of pet that needs to be fetched")], **kwargs) -> Order: # noqa: E501
"""Find purchase order by ID # 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 For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions # noqa: E501
@ -304,7 +304,7 @@ class StoreApi:
return await self.get_order_by_id_with_http_info(order_id, **kwargs) # noqa: E501 return await self.get_order_by_id_with_http_info(order_id, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async 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 async def get_order_by_id_with_http_info(self, order_id : Annotated[int, Field(le=5, strict=True, ge=1, description="ID of pet that needs to be fetched")], **kwargs) -> ApiResponse: # noqa: E501
"""Find purchase order by ID # 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 For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions # noqa: E501
@ -407,7 +407,7 @@ class StoreApi:
_request_auth=_params.get('_request_auth')) _request_auth=_params.get('_request_auth'))
@validate_arguments @validate_arguments
async def place_order(self, order : Annotated[Order, Field(..., description="order placed for purchasing the pet")], **kwargs) -> Order: # noqa: E501 async 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 """Place an order for a pet # noqa: E501
# noqa: E501 # noqa: E501
@ -430,7 +430,7 @@ class StoreApi:
return await self.place_order_with_http_info(order, **kwargs) # noqa: E501 return await self.place_order_with_http_info(order, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async def place_order_with_http_info(self, order : Annotated[Order, Field(..., description="order placed for purchasing the pet")], **kwargs) -> ApiResponse: # noqa: E501 async 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 """Place an order for a pet # noqa: E501
# noqa: E501 # noqa: E501

View File

@ -17,10 +17,12 @@ import io
import warnings import warnings
from pydantic import validate_arguments, ValidationError from pydantic import validate_arguments, ValidationError
from typing import overload, Optional, Union, Awaitable
from pydantic import Field
from typing_extensions import Annotated from typing_extensions import Annotated
from pydantic import Field, StrictStr, conlist from pydantic import StrictStr
from typing import List
from petstore_api.models.user import User from petstore_api.models.user import User
@ -45,7 +47,7 @@ class UserApi:
self.api_client = api_client self.api_client = api_client
@validate_arguments @validate_arguments
async def create_user(self, user : Annotated[User, Field(..., description="Created user object")], **kwargs) -> None: # noqa: E501 async def create_user(self, user : Annotated[User, Field(description="Created user object")], **kwargs) -> None: # noqa: E501
"""Create user # noqa: E501 """Create user # noqa: E501
This can only be done by the logged in user. # noqa: E501 This can only be done by the logged in user. # noqa: E501
@ -68,7 +70,7 @@ class UserApi:
return await self.create_user_with_http_info(user, **kwargs) # noqa: E501 return await self.create_user_with_http_info(user, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async def create_user_with_http_info(self, user : Annotated[User, Field(..., description="Created user object")], **kwargs) -> ApiResponse: # noqa: E501 async def create_user_with_http_info(self, user : Annotated[User, Field(description="Created user object")], **kwargs) -> ApiResponse: # noqa: E501
"""Create user # noqa: E501 """Create user # noqa: E501
This can only be done by the logged in user. # noqa: E501 This can only be done by the logged in user. # noqa: E501
@ -185,7 +187,7 @@ class UserApi:
_request_auth=_params.get('_request_auth')) _request_auth=_params.get('_request_auth'))
@validate_arguments @validate_arguments
async def create_users_with_array_input(self, user : Annotated[conlist(User), Field(..., description="List of user object")], **kwargs) -> None: # noqa: E501 async def create_users_with_array_input(self, user : Annotated[List[User], Field(description="List of user object")], **kwargs) -> None: # noqa: E501
"""Creates list of users with given input array # noqa: E501 """Creates list of users with given input array # noqa: E501
# noqa: E501 # noqa: E501
@ -208,7 +210,7 @@ class UserApi:
return await self.create_users_with_array_input_with_http_info(user, **kwargs) # noqa: E501 return await self.create_users_with_array_input_with_http_info(user, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async def create_users_with_array_input_with_http_info(self, user : Annotated[conlist(User), Field(..., description="List of user object")], **kwargs) -> ApiResponse: # noqa: E501 async def create_users_with_array_input_with_http_info(self, user : Annotated[List[User], Field(description="List of user object")], **kwargs) -> ApiResponse: # noqa: E501
"""Creates list of users with given input array # noqa: E501 """Creates list of users with given input array # noqa: E501
# noqa: E501 # noqa: E501
@ -310,7 +312,7 @@ class UserApi:
_request_auth=_params.get('_request_auth')) _request_auth=_params.get('_request_auth'))
@validate_arguments @validate_arguments
async def create_users_with_list_input(self, user : Annotated[conlist(User), Field(..., description="List of user object")], **kwargs) -> None: # noqa: E501 async def create_users_with_list_input(self, user : Annotated[List[User], Field(description="List of user object")], **kwargs) -> None: # noqa: E501
"""Creates list of users with given input array # noqa: E501 """Creates list of users with given input array # noqa: E501
# noqa: E501 # noqa: E501
@ -333,7 +335,7 @@ class UserApi:
return await self.create_users_with_list_input_with_http_info(user, **kwargs) # noqa: E501 return await self.create_users_with_list_input_with_http_info(user, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async def create_users_with_list_input_with_http_info(self, user : Annotated[conlist(User), Field(..., description="List of user object")], **kwargs) -> ApiResponse: # noqa: E501 async def create_users_with_list_input_with_http_info(self, user : Annotated[List[User], Field(description="List of user object")], **kwargs) -> ApiResponse: # noqa: E501
"""Creates list of users with given input array # noqa: E501 """Creates list of users with given input array # noqa: E501
# noqa: E501 # noqa: E501
@ -435,7 +437,7 @@ class UserApi:
_request_auth=_params.get('_request_auth')) _request_auth=_params.get('_request_auth'))
@validate_arguments @validate_arguments
async def delete_user(self, username : Annotated[StrictStr, Field(..., description="The name that needs to be deleted")], **kwargs) -> None: # noqa: E501 async def delete_user(self, username : Annotated[StrictStr, Field(description="The name that needs to be deleted")], **kwargs) -> None: # noqa: E501
"""Delete user # noqa: E501 """Delete user # noqa: E501
This can only be done by the logged in user. # noqa: E501 This can only be done by the logged in user. # noqa: E501
@ -458,7 +460,7 @@ class UserApi:
return await self.delete_user_with_http_info(username, **kwargs) # noqa: E501 return await self.delete_user_with_http_info(username, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async def delete_user_with_http_info(self, username : Annotated[StrictStr, Field(..., description="The name that needs to be deleted")], **kwargs) -> ApiResponse: # noqa: E501 async 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 """Delete user # noqa: E501
This can only be done by the logged in user. # noqa: E501 This can only be done by the logged in user. # noqa: E501
@ -553,7 +555,7 @@ class UserApi:
_request_auth=_params.get('_request_auth')) _request_auth=_params.get('_request_auth'))
@validate_arguments @validate_arguments
async 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 async 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 """Get user by user name # noqa: E501
# noqa: E501 # noqa: E501
@ -576,7 +578,7 @@ class UserApi:
return await self.get_user_by_name_with_http_info(username, **kwargs) # noqa: E501 return await self.get_user_by_name_with_http_info(username, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async 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 async 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 """Get user by user name # noqa: E501
# noqa: E501 # noqa: E501
@ -679,7 +681,7 @@ class UserApi:
_request_auth=_params.get('_request_auth')) _request_auth=_params.get('_request_auth'))
@validate_arguments @validate_arguments
async 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 async 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 """Logs user into the system # noqa: E501
# noqa: E501 # noqa: E501
@ -704,7 +706,7 @@ class UserApi:
return await self.login_user_with_http_info(username, password, **kwargs) # noqa: E501 return await self.login_user_with_http_info(username, password, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async 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 async 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 """Logs user into the system # noqa: E501
# noqa: E501 # noqa: E501
@ -922,7 +924,7 @@ class UserApi:
_request_auth=_params.get('_request_auth')) _request_auth=_params.get('_request_auth'))
@validate_arguments @validate_arguments
async 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 async 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 """Updated user # noqa: E501
This can only be done by the logged in user. # noqa: E501 This can only be done by the logged in user. # noqa: E501
@ -947,7 +949,7 @@ class UserApi:
return await self.update_user_with_http_info(username, user, **kwargs) # noqa: E501 return await self.update_user_with_http_info(username, user, **kwargs) # noqa: E501
@validate_arguments @validate_arguments
async 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 async 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 """Updated user # noqa: E501
This can only be done by the logged in user. # noqa: E501 This can only be done by the logged in user. # noqa: E501

View File

@ -40,6 +40,7 @@ class AdditionalPropertiesAnyType(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -75,7 +76,7 @@ class AdditionalPropertiesAnyType(BaseModel):
}) })
# store additional fields in additional_properties # store additional fields in additional_properties
for _key in obj.keys(): for _key in obj.keys():
if _key not in cls.__properties: if _key not in cls.__properties.default:
_obj.additional_properties[_key] = obj.get(_key) _obj.additional_properties[_key] = obj.get(_key)
return _obj return _obj

View File

@ -40,6 +40,7 @@ class AdditionalPropertiesClass(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod

View File

@ -40,6 +40,7 @@ class AdditionalPropertiesObject(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -75,7 +76,7 @@ class AdditionalPropertiesObject(BaseModel):
}) })
# store additional fields in additional_properties # store additional fields in additional_properties
for _key in obj.keys(): for _key in obj.keys():
if _key not in cls.__properties: if _key not in cls.__properties.default:
_obj.additional_properties[_key] = obj.get(_key) _obj.additional_properties[_key] = obj.get(_key)
return _obj return _obj

View File

@ -40,6 +40,7 @@ class AdditionalPropertiesWithDescriptionOnly(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -75,7 +76,7 @@ class AdditionalPropertiesWithDescriptionOnly(BaseModel):
}) })
# store additional fields in additional_properties # store additional fields in additional_properties
for _key in obj.keys(): for _key in obj.keys():
if _key not in cls.__properties: if _key not in cls.__properties.default:
_obj.additional_properties[_key] = obj.get(_key) _obj.additional_properties[_key] = obj.get(_key)
return _obj return _obj

View File

@ -19,7 +19,8 @@ import json
from typing import Optional from typing import Optional
from pydantic import BaseModel, Field, StrictStr from pydantic import BaseModel, StrictStr
from pydantic import Field
from petstore_api.models.single_ref_type import SingleRefType from petstore_api.models.single_ref_type import SingleRefType
class AllOfWithSingleRef(BaseModel): class AllOfWithSingleRef(BaseModel):
@ -27,7 +28,7 @@ class AllOfWithSingleRef(BaseModel):
AllOfWithSingleRef AllOfWithSingleRef
""" """
username: Optional[StrictStr] = None username: Optional[StrictStr] = None
single_ref_type: Optional[SingleRefType] = Field(None, alias="SingleRefType") single_ref_type: Optional[SingleRefType] = Field(default=None, alias="SingleRefType")
__properties = ["username", "SingleRefType"] __properties = ["username", "SingleRefType"]
class Config: class Config:
@ -41,6 +42,7 @@ class AllOfWithSingleRef(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -67,7 +69,7 @@ class AllOfWithSingleRef(BaseModel):
_obj = AllOfWithSingleRef.parse_obj({ _obj = AllOfWithSingleRef.parse_obj({
"username": obj.get("username"), "username": obj.get("username"),
"single_ref_type": obj.get("SingleRefType") "SingleRefType": obj.get("SingleRefType")
}) })
return _obj return _obj

View File

@ -19,13 +19,14 @@ import json
from typing import Optional, Union from typing import Optional, Union
from pydantic import BaseModel, Field, StrictStr from pydantic import BaseModel, StrictStr
from pydantic import Field
class Animal(BaseModel): class Animal(BaseModel):
""" """
Animal Animal
""" """
class_name: StrictStr = Field(..., alias="className") class_name: StrictStr = Field(alias="className")
color: Optional[StrictStr] = 'red' color: Optional[StrictStr] = 'red'
__properties = ["className", "color"] __properties = ["className", "color"]
@ -46,9 +47,9 @@ class Animal(BaseModel):
@classmethod @classmethod
def get_discriminator_value(cls, obj: dict) -> str: def get_discriminator_value(cls, obj: dict) -> str:
"""Returns the discriminator value (object type) of the data""" """Returns the discriminator value (object type) of the data"""
discriminator_value = obj[cls.__discriminator_property_name] discriminator_value = obj[cls.__discriminator_property_name.default]
if discriminator_value: if discriminator_value:
return cls.__discriminator_value_class_map.get(discriminator_value) return cls.__discriminator_value_class_map.default.get(discriminator_value)
else: else:
return None return None
@ -58,6 +59,7 @@ class Animal(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -83,10 +85,14 @@ class Animal(BaseModel):
return klass.from_dict(obj) return klass.from_dict(obj)
else: else:
raise ValueError("Animal failed to lookup discriminator value from " + raise ValueError("Animal failed to lookup discriminator value from " +
json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name + json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name.default +
", mapping: " + json.dumps(cls.__discriminator_value_class_map)) ", mapping: " + json.dumps(cls.__discriminator_value_class_map.default))
from petstore_api.models.cat import Cat from petstore_api.models.cat import Cat
from petstore_api.models.dog import Dog from petstore_api.models.dog import Dog
Animal.update_forward_refs() from typing import TYPE_CHECKING
if TYPE_CHECKING:
# TODO: pydantic v2
# Animal.model_rebuild()
pass

View File

@ -19,8 +19,11 @@ import pprint
import re # noqa: F401 import re # noqa: F401
from typing import List, Optional from typing import List, Optional
from pydantic import BaseModel, Field, StrictStr, ValidationError, conint, conlist, constr, validator from pydantic import BaseModel, Field, StrictStr, ValidationError, validator
from typing import Union, Any, List, TYPE_CHECKING from pydantic import Field
from typing_extensions import Annotated
from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict
from typing_extensions import Literal
from pydantic import StrictStr, Field from pydantic import StrictStr, Field
ANYOFCOLOR_ANY_OF_SCHEMAS = ["List[int]", "str"] ANYOFCOLOR_ANY_OF_SCHEMAS = ["List[int]", "str"]
@ -31,16 +34,16 @@ class AnyOfColor(BaseModel):
""" """
# data type: List[int] # data type: List[int]
anyof_schema_1_validator: Optional[conlist(conint(strict=True, le=255, ge=0), max_items=3, min_items=3)] = Field(None, description="RGB three element array with values 0-255.") anyof_schema_1_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_items=3, max_items=3)]] = Field(default=None, description="RGB three element array with values 0-255.")
# data type: List[int] # data type: List[int]
anyof_schema_2_validator: Optional[conlist(conint(strict=True, le=255, ge=0), max_items=4, min_items=4)] = Field(None, description="RGBA four element array with values 0-255.") anyof_schema_2_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_items=4, max_items=4)]] = Field(default=None, description="RGBA four element array with values 0-255.")
# data type: str # 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.") anyof_schema_3_validator: Optional[Annotated[str, Field(min_length=7, strict=True, max_length=7)]] = Field(default=None, description="Hex color string, such as #00FF00.")
if TYPE_CHECKING: if TYPE_CHECKING:
actual_instance: Union[List[int], str] actual_instance: Optional[Union[List[int], str]] = None
else: else:
actual_instance: Any actual_instance: Any = None
any_of_schemas: List[str] = Field(ANYOFCOLOR_ANY_OF_SCHEMAS, const=True) any_of_schemas: List[str] = Literal[ANYOFCOLOR_ANY_OF_SCHEMAS]
class Config: class Config:
validate_assignment = True validate_assignment = True

View File

@ -22,7 +22,8 @@ from typing import Optional
from pydantic import BaseModel, Field, StrictStr, ValidationError, validator from pydantic import BaseModel, Field, StrictStr, ValidationError, validator
from petstore_api.models.basque_pig import BasquePig from petstore_api.models.basque_pig import BasquePig
from petstore_api.models.danish_pig import DanishPig from petstore_api.models.danish_pig import DanishPig
from typing import Union, Any, List, TYPE_CHECKING from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict
from typing_extensions import Literal
from pydantic import StrictStr, Field from pydantic import StrictStr, Field
ANYOFPIG_ANY_OF_SCHEMAS = ["BasquePig", "DanishPig"] ANYOFPIG_ANY_OF_SCHEMAS = ["BasquePig", "DanishPig"]
@ -37,10 +38,10 @@ class AnyOfPig(BaseModel):
# data type: DanishPig # data type: DanishPig
anyof_schema_2_validator: Optional[DanishPig] = None anyof_schema_2_validator: Optional[DanishPig] = None
if TYPE_CHECKING: if TYPE_CHECKING:
actual_instance: Union[BasquePig, DanishPig] actual_instance: Optional[Union[BasquePig, DanishPig]] = None
else: else:
actual_instance: Any actual_instance: Any = None
any_of_schemas: List[str] = Field(ANYOFPIG_ANY_OF_SCHEMAS, const=True) any_of_schemas: List[str] = Literal[ANYOFPIG_ANY_OF_SCHEMAS]
class Config: class Config:
validate_assignment = True validate_assignment = True

View File

@ -41,6 +41,7 @@ class ApiResponse(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod

View File

@ -19,14 +19,14 @@ import json
from typing import List, Optional from typing import List, Optional
from pydantic import BaseModel, conlist from pydantic import BaseModel
from petstore_api.models.tag import Tag from petstore_api.models.tag import Tag
class ArrayOfArrayOfModel(BaseModel): class ArrayOfArrayOfModel(BaseModel):
""" """
ArrayOfArrayOfModel ArrayOfArrayOfModel
""" """
another_property: Optional[conlist(conlist(Tag))] = None another_property: Optional[List[List[Tag]]] = None
__properties = ["another_property"] __properties = ["another_property"]
class Config: class Config:
@ -40,6 +40,7 @@ class ArrayOfArrayOfModel(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod

View File

@ -19,13 +19,14 @@ import json
from typing import List, Optional from typing import List, Optional
from pydantic import BaseModel, Field, conlist from pydantic import BaseModel
from pydantic import Field
class ArrayOfArrayOfNumberOnly(BaseModel): class ArrayOfArrayOfNumberOnly(BaseModel):
""" """
ArrayOfArrayOfNumberOnly ArrayOfArrayOfNumberOnly
""" """
array_array_number: Optional[conlist(conlist(float))] = Field(None, alias="ArrayArrayNumber") array_array_number: Optional[List[List[float]]] = Field(default=None, alias="ArrayArrayNumber")
__properties = ["ArrayArrayNumber"] __properties = ["ArrayArrayNumber"]
class Config: class Config:
@ -39,6 +40,7 @@ class ArrayOfArrayOfNumberOnly(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -64,7 +66,7 @@ class ArrayOfArrayOfNumberOnly(BaseModel):
return ArrayOfArrayOfNumberOnly.parse_obj(obj) return ArrayOfArrayOfNumberOnly.parse_obj(obj)
_obj = ArrayOfArrayOfNumberOnly.parse_obj({ _obj = ArrayOfArrayOfNumberOnly.parse_obj({
"array_array_number": obj.get("ArrayArrayNumber") "ArrayArrayNumber": obj.get("ArrayArrayNumber")
}) })
return _obj return _obj

View File

@ -19,13 +19,14 @@ import json
from typing import List, Optional from typing import List, Optional
from pydantic import BaseModel, Field, conlist from pydantic import BaseModel
from pydantic import Field
class ArrayOfNumberOnly(BaseModel): class ArrayOfNumberOnly(BaseModel):
""" """
ArrayOfNumberOnly ArrayOfNumberOnly
""" """
array_number: Optional[conlist(float)] = Field(None, alias="ArrayNumber") array_number: Optional[List[float]] = Field(default=None, alias="ArrayNumber")
__properties = ["ArrayNumber"] __properties = ["ArrayNumber"]
class Config: class Config:
@ -39,6 +40,7 @@ class ArrayOfNumberOnly(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -64,7 +66,7 @@ class ArrayOfNumberOnly(BaseModel):
return ArrayOfNumberOnly.parse_obj(obj) return ArrayOfNumberOnly.parse_obj(obj)
_obj = ArrayOfNumberOnly.parse_obj({ _obj = ArrayOfNumberOnly.parse_obj({
"array_number": obj.get("ArrayNumber") "ArrayNumber": obj.get("ArrayNumber")
}) })
return _obj return _obj

View File

@ -19,16 +19,18 @@ import json
from typing import List, Optional from typing import List, Optional
from pydantic import BaseModel, StrictInt, StrictStr, conlist from pydantic import BaseModel, StrictInt, StrictStr
from pydantic import Field
from typing_extensions import Annotated
from petstore_api.models.read_only_first import ReadOnlyFirst from petstore_api.models.read_only_first import ReadOnlyFirst
class ArrayTest(BaseModel): class ArrayTest(BaseModel):
""" """
ArrayTest ArrayTest
""" """
array_of_string: Optional[conlist(StrictStr, max_items=3, min_items=0)] = None array_of_string: Optional[Annotated[List[StrictStr], Field(min_items=0, max_items=3)]] = None
array_array_of_integer: Optional[conlist(conlist(StrictInt))] = None array_array_of_integer: Optional[List[List[StrictInt]]] = None
array_array_of_model: Optional[conlist(conlist(ReadOnlyFirst))] = None array_array_of_model: Optional[List[List[ReadOnlyFirst]]] = None
__properties = ["array_of_string", "array_array_of_integer", "array_array_of_model"] __properties = ["array_of_string", "array_array_of_integer", "array_array_of_model"]
class Config: class Config:
@ -42,6 +44,7 @@ class ArrayTest(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod

View File

@ -19,14 +19,15 @@ import json
from pydantic import BaseModel, Field, StrictStr from pydantic import BaseModel, StrictStr
from pydantic import Field
class BasquePig(BaseModel): class BasquePig(BaseModel):
""" """
BasquePig BasquePig
""" """
class_name: StrictStr = Field(..., alias="className") class_name: StrictStr = Field(alias="className")
color: StrictStr = Field(...) color: StrictStr
__properties = ["className", "color"] __properties = ["className", "color"]
class Config: class Config:
@ -40,6 +41,7 @@ class BasquePig(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -65,7 +67,7 @@ class BasquePig(BaseModel):
return BasquePig.parse_obj(obj) return BasquePig.parse_obj(obj)
_obj = BasquePig.parse_obj({ _obj = BasquePig.parse_obj({
"class_name": obj.get("className"), "className": obj.get("className"),
"color": obj.get("color") "color": obj.get("color")
}) })
return _obj return _obj

View File

@ -19,18 +19,19 @@ import json
from typing import Optional from typing import Optional
from pydantic import BaseModel, Field, StrictStr from pydantic import BaseModel, StrictStr
from pydantic import Field
class Capitalization(BaseModel): class Capitalization(BaseModel):
""" """
Capitalization Capitalization
""" """
small_camel: Optional[StrictStr] = Field(None, alias="smallCamel") small_camel: Optional[StrictStr] = Field(default=None, alias="smallCamel")
capital_camel: Optional[StrictStr] = Field(None, alias="CapitalCamel") capital_camel: Optional[StrictStr] = Field(default=None, alias="CapitalCamel")
small_snake: Optional[StrictStr] = Field(None, alias="small_Snake") small_snake: Optional[StrictStr] = Field(default=None, alias="small_Snake")
capital_snake: Optional[StrictStr] = Field(None, alias="Capital_Snake") capital_snake: Optional[StrictStr] = Field(default=None, alias="Capital_Snake")
sca_eth_flow_points: Optional[StrictStr] = Field(None, alias="SCA_ETH_Flow_Points") sca_eth_flow_points: Optional[StrictStr] = Field(default=None, alias="SCA_ETH_Flow_Points")
att_name: Optional[StrictStr] = Field(None, alias="ATT_NAME", description="Name of the pet ") att_name: Optional[StrictStr] = Field(default=None, description="Name of the pet ", alias="ATT_NAME")
__properties = ["smallCamel", "CapitalCamel", "small_Snake", "Capital_Snake", "SCA_ETH_Flow_Points", "ATT_NAME"] __properties = ["smallCamel", "CapitalCamel", "small_Snake", "Capital_Snake", "SCA_ETH_Flow_Points", "ATT_NAME"]
class Config: class Config:
@ -44,6 +45,7 @@ class Capitalization(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -69,12 +71,12 @@ class Capitalization(BaseModel):
return Capitalization.parse_obj(obj) return Capitalization.parse_obj(obj)
_obj = Capitalization.parse_obj({ _obj = Capitalization.parse_obj({
"small_camel": obj.get("smallCamel"), "smallCamel": obj.get("smallCamel"),
"capital_camel": obj.get("CapitalCamel"), "CapitalCamel": obj.get("CapitalCamel"),
"small_snake": obj.get("small_Snake"), "small_Snake": obj.get("small_Snake"),
"capital_snake": obj.get("Capital_Snake"), "Capital_Snake": obj.get("Capital_Snake"),
"sca_eth_flow_points": obj.get("SCA_ETH_Flow_Points"), "SCA_ETH_Flow_Points": obj.get("SCA_ETH_Flow_Points"),
"att_name": obj.get("ATT_NAME") "ATT_NAME": obj.get("ATT_NAME")
}) })
return _obj return _obj

View File

@ -40,6 +40,7 @@ class Cat(Animal):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -65,7 +66,7 @@ class Cat(Animal):
return Cat.parse_obj(obj) return Cat.parse_obj(obj)
_obj = Cat.parse_obj({ _obj = Cat.parse_obj({
"class_name": obj.get("className"), "className": obj.get("className"),
"color": obj.get("color") if obj.get("color") is not None else 'red', "color": obj.get("color") if obj.get("color") is not None else 'red',
"declawed": obj.get("declawed") "declawed": obj.get("declawed")
}) })

View File

@ -19,14 +19,14 @@ import json
from typing import Optional from typing import Optional
from pydantic import BaseModel, Field, StrictInt, StrictStr from pydantic import BaseModel, StrictInt, StrictStr
class Category(BaseModel): class Category(BaseModel):
""" """
Category Category
""" """
id: Optional[StrictInt] = None id: Optional[StrictInt] = None
name: StrictStr = Field(...) name: StrictStr
__properties = ["id", "name"] __properties = ["id", "name"]
class Config: class Config:
@ -40,6 +40,7 @@ class Category(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod

View File

@ -40,6 +40,7 @@ class CircularReferenceModel(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -74,5 +75,9 @@ class CircularReferenceModel(BaseModel):
return _obj return _obj
from petstore_api.models.first_ref import FirstRef from petstore_api.models.first_ref import FirstRef
CircularReferenceModel.update_forward_refs() from typing import TYPE_CHECKING
if TYPE_CHECKING:
# TODO: pydantic v2
# CircularReferenceModel.model_rebuild()
pass

View File

@ -19,13 +19,14 @@ import json
from typing import Optional from typing import Optional
from pydantic import BaseModel, Field, StrictStr from pydantic import BaseModel, StrictStr
from pydantic import Field
class ClassModel(BaseModel): class ClassModel(BaseModel):
""" """
Model for testing model with \"_class\" property # noqa: E501 Model for testing model with \"_class\" property # noqa: E501
""" """
var_class: Optional[StrictStr] = Field(None, alias="_class") var_class: Optional[StrictStr] = Field(default=None, alias="_class")
__properties = ["_class"] __properties = ["_class"]
class Config: class Config:
@ -39,6 +40,7 @@ class ClassModel(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -64,7 +66,7 @@ class ClassModel(BaseModel):
return ClassModel.parse_obj(obj) return ClassModel.parse_obj(obj)
_obj = ClassModel.parse_obj({ _obj = ClassModel.parse_obj({
"var_class": obj.get("_class") "_class": obj.get("_class")
}) })
return _obj return _obj

View File

@ -39,6 +39,7 @@ class Client(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod

View File

@ -19,8 +19,11 @@ import pprint
import re # noqa: F401 import re # noqa: F401
from typing import Any, List, Optional from typing import Any, List, Optional
from pydantic import BaseModel, Field, StrictStr, ValidationError, conint, conlist, constr, validator from pydantic import BaseModel, Field, StrictStr, ValidationError, validator
from typing import Union, Any, List, TYPE_CHECKING from pydantic import Field
from typing_extensions import Annotated
from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict
from typing_extensions import Literal
from pydantic import StrictStr, Field from pydantic import StrictStr, Field
COLOR_ONE_OF_SCHEMAS = ["List[int]", "str"] COLOR_ONE_OF_SCHEMAS = ["List[int]", "str"]
@ -30,16 +33,13 @@ class Color(BaseModel):
RGB array, RGBA array, or hex string. RGB array, RGBA array, or hex string.
""" """
# data type: List[int] # data type: List[int]
oneof_schema_1_validator: Optional[conlist(conint(strict=True, le=255, ge=0), max_items=3, min_items=3)] = Field(None, description="RGB three element array with values 0-255.") oneof_schema_1_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_items=3, max_items=3)]] = Field(default=None, description="RGB three element array with values 0-255.")
# data type: List[int] # data type: List[int]
oneof_schema_2_validator: Optional[conlist(conint(strict=True, le=255, ge=0), max_items=4, min_items=4)] = Field(None, description="RGBA four element array with values 0-255.") oneof_schema_2_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_items=4, max_items=4)]] = Field(default=None, description="RGBA four element array with values 0-255.")
# data type: str # 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.") oneof_schema_3_validator: Optional[Annotated[str, Field(min_length=7, strict=True, max_length=7)]] = Field(default=None, description="Hex color string, such as #00FF00.")
if TYPE_CHECKING: actual_instance: Optional[Union[List[int], str]] = None
actual_instance: Union[List[int], str] one_of_schemas: List[str] = Literal[COLOR_ONE_OF_SCHEMAS]
else:
actual_instance: Any
one_of_schemas: List[str] = Field(COLOR_ONE_OF_SCHEMAS, const=True)
class Config: class Config:
validate_assignment = True validate_assignment = True

View File

@ -19,15 +19,15 @@ import json
from pydantic import BaseModel, Field, StrictStr from pydantic import BaseModel, StrictStr
from petstore_api.models.creature_info import CreatureInfo from petstore_api.models.creature_info import CreatureInfo
class Creature(BaseModel): class Creature(BaseModel):
""" """
Creature Creature
""" """
info: CreatureInfo = Field(...) info: CreatureInfo
type: StrictStr = Field(...) type: StrictStr
__properties = ["info", "type"] __properties = ["info", "type"]
class Config: class Config:
@ -41,6 +41,7 @@ class Creature(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod

View File

@ -19,13 +19,13 @@ import json
from pydantic import BaseModel, Field, StrictStr from pydantic import BaseModel, StrictStr
class CreatureInfo(BaseModel): class CreatureInfo(BaseModel):
""" """
CreatureInfo CreatureInfo
""" """
name: StrictStr = Field(...) name: StrictStr
__properties = ["name"] __properties = ["name"]
class Config: class Config:
@ -39,6 +39,7 @@ class CreatureInfo(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod

View File

@ -19,14 +19,15 @@ import json
from pydantic import BaseModel, Field, StrictInt, StrictStr from pydantic import BaseModel, StrictInt, StrictStr
from pydantic import Field
class DanishPig(BaseModel): class DanishPig(BaseModel):
""" """
DanishPig DanishPig
""" """
class_name: StrictStr = Field(..., alias="className") class_name: StrictStr = Field(alias="className")
size: StrictInt = Field(...) size: StrictInt
__properties = ["className", "size"] __properties = ["className", "size"]
class Config: class Config:
@ -40,6 +41,7 @@ class DanishPig(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -65,7 +67,7 @@ class DanishPig(BaseModel):
return DanishPig.parse_obj(obj) return DanishPig.parse_obj(obj)
_obj = DanishPig.parse_obj({ _obj = DanishPig.parse_obj({
"class_name": obj.get("className"), "className": obj.get("className"),
"size": obj.get("size") "size": obj.get("size")
}) })
return _obj return _obj

View File

@ -39,6 +39,7 @@ class DeprecatedObject(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod

View File

@ -40,6 +40,7 @@ class Dog(Animal):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -65,7 +66,7 @@ class Dog(Animal):
return Dog.parse_obj(obj) return Dog.parse_obj(obj)
_obj = Dog.parse_obj({ _obj = Dog.parse_obj({
"class_name": obj.get("className"), "className": obj.get("className"),
"color": obj.get("color") if obj.get("color") is not None else 'red', "color": obj.get("color") if obj.get("color") is not None else 'red',
"breed": obj.get("breed") "breed": obj.get("breed")
}) })

View File

@ -40,6 +40,7 @@ class DummyModel(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -74,5 +75,9 @@ class DummyModel(BaseModel):
return _obj return _obj
from petstore_api.models.self_reference_model import SelfReferenceModel from petstore_api.models.self_reference_model import SelfReferenceModel
DummyModel.update_forward_refs() from typing import TYPE_CHECKING
if TYPE_CHECKING:
# TODO: pydantic v2
# DummyModel.model_rebuild()
pass

View File

@ -19,14 +19,14 @@ import json
from typing import List, Optional from typing import List, Optional
from pydantic import BaseModel, StrictStr, conlist, validator from pydantic import BaseModel, StrictStr, validator
class EnumArrays(BaseModel): class EnumArrays(BaseModel):
""" """
EnumArrays EnumArrays
""" """
just_symbol: Optional[StrictStr] = None just_symbol: Optional[StrictStr] = None
array_enum: Optional[conlist(StrictStr)] = None array_enum: Optional[List[StrictStr]] = None
__properties = ["just_symbol", "array_enum"] __properties = ["just_symbol", "array_enum"]
@validator('just_symbol') @validator('just_symbol')
@ -61,6 +61,7 @@ class EnumArrays(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod

View File

@ -19,7 +19,8 @@ import json
from typing import Optional from typing import Optional
from pydantic import BaseModel, Field, StrictInt, StrictStr, validator from pydantic import BaseModel, StrictInt, StrictStr, validator
from pydantic import Field
from petstore_api.models.outer_enum import OuterEnum from petstore_api.models.outer_enum import OuterEnum
from petstore_api.models.outer_enum_default_value import OuterEnumDefaultValue 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 import OuterEnumInteger
@ -30,14 +31,14 @@ class EnumTest(BaseModel):
EnumTest EnumTest
""" """
enum_string: Optional[StrictStr] = None enum_string: Optional[StrictStr] = None
enum_string_required: StrictStr = Field(...) enum_string_required: StrictStr
enum_integer_default: Optional[StrictInt] = 5 enum_integer_default: Optional[StrictInt] = 5
enum_integer: Optional[StrictInt] = None enum_integer: Optional[StrictInt] = None
enum_number: Optional[float] = None enum_number: Optional[float] = None
outer_enum: Optional[OuterEnum] = Field(None, alias="outerEnum") outer_enum: Optional[OuterEnum] = Field(default=None, alias="outerEnum")
outer_enum_integer: Optional[OuterEnumInteger] = Field(None, alias="outerEnumInteger") outer_enum_integer: Optional[OuterEnumInteger] = Field(default=None, alias="outerEnumInteger")
outer_enum_default_value: Optional[OuterEnumDefaultValue] = Field(None, alias="outerEnumDefaultValue") outer_enum_default_value: Optional[OuterEnumDefaultValue] = Field(default=None, alias="outerEnumDefaultValue")
outer_enum_integer_default_value: Optional[OuterEnumIntegerDefaultValue] = Field(None, alias="outerEnumIntegerDefaultValue") outer_enum_integer_default_value: Optional[OuterEnumIntegerDefaultValue] = Field(default=None, alias="outerEnumIntegerDefaultValue")
__properties = ["enum_string", "enum_string_required", "enum_integer_default", "enum_integer", "enum_number", "outerEnum", "outerEnumInteger", "outerEnumDefaultValue", "outerEnumIntegerDefaultValue"] __properties = ["enum_string", "enum_string_required", "enum_integer_default", "enum_integer", "enum_number", "outerEnum", "outerEnumInteger", "outerEnumDefaultValue", "outerEnumIntegerDefaultValue"]
@validator('enum_string') @validator('enum_string')
@ -98,6 +99,7 @@ class EnumTest(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -133,10 +135,10 @@ class EnumTest(BaseModel):
"enum_integer_default": obj.get("enum_integer_default") if obj.get("enum_integer_default") is not None else 5, "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_integer": obj.get("enum_integer"),
"enum_number": obj.get("enum_number"), "enum_number": obj.get("enum_number"),
"outer_enum": obj.get("outerEnum"), "outerEnum": obj.get("outerEnum"),
"outer_enum_integer": obj.get("outerEnumInteger"), "outerEnumInteger": obj.get("outerEnumInteger"),
"outer_enum_default_value": obj.get("outerEnumDefaultValue"), "outerEnumDefaultValue": obj.get("outerEnumDefaultValue"),
"outer_enum_integer_default_value": obj.get("outerEnumIntegerDefaultValue") "outerEnumIntegerDefaultValue": obj.get("outerEnumIntegerDefaultValue")
}) })
return _obj return _obj

View File

@ -19,13 +19,14 @@ import json
from typing import Optional from typing import Optional
from pydantic import BaseModel, Field, StrictStr from pydantic import BaseModel, StrictStr
from pydantic import Field
class File(BaseModel): class File(BaseModel):
""" """
Must be named `File` for test. # noqa: E501 Must be named `File` for test. # noqa: E501
""" """
source_uri: Optional[StrictStr] = Field(None, alias="sourceURI", description="Test capitalization") source_uri: Optional[StrictStr] = Field(default=None, description="Test capitalization", alias="sourceURI")
__properties = ["sourceURI"] __properties = ["sourceURI"]
class Config: class Config:
@ -39,6 +40,7 @@ class File(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -64,7 +66,7 @@ class File(BaseModel):
return File.parse_obj(obj) return File.parse_obj(obj)
_obj = File.parse_obj({ _obj = File.parse_obj({
"source_uri": obj.get("sourceURI") "sourceURI": obj.get("sourceURI")
}) })
return _obj return _obj

View File

@ -19,7 +19,7 @@ import json
from typing import List, Optional from typing import List, Optional
from pydantic import BaseModel, conlist from pydantic import BaseModel
from petstore_api.models.file import File from petstore_api.models.file import File
class FileSchemaTestClass(BaseModel): class FileSchemaTestClass(BaseModel):
@ -27,7 +27,7 @@ class FileSchemaTestClass(BaseModel):
FileSchemaTestClass FileSchemaTestClass
""" """
file: Optional[File] = None file: Optional[File] = None
files: Optional[conlist(File)] = None files: Optional[List[File]] = None
__properties = ["file", "files"] __properties = ["file", "files"]
class Config: class Config:
@ -41,6 +41,7 @@ class FileSchemaTestClass(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod

View File

@ -40,6 +40,7 @@ class FirstRef(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -74,5 +75,9 @@ class FirstRef(BaseModel):
return _obj return _obj
from petstore_api.models.second_ref import SecondRef from petstore_api.models.second_ref import SecondRef
FirstRef.update_forward_refs() from typing import TYPE_CHECKING
if TYPE_CHECKING:
# TODO: pydantic v2
# FirstRef.model_rebuild()
pass

View File

@ -39,6 +39,7 @@ class Foo(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod

View File

@ -40,6 +40,7 @@ class FooGetDefaultResponse(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod

View File

@ -19,30 +19,32 @@ import json
from datetime import date, datetime from datetime import date, datetime
from typing import Optional, Union from typing import Optional, Union
from pydantic import BaseModel, Field, StrictBytes, StrictInt, StrictStr, condecimal, confloat, conint, constr, validator from pydantic import BaseModel, StrictBytes, StrictInt, StrictStr, validator
from decimal import Decimal
from pydantic import Field
from typing_extensions import Annotated
class FormatTest(BaseModel): class FormatTest(BaseModel):
""" """
FormatTest FormatTest
""" """
integer: Optional[conint(strict=True, le=100, ge=10)] = None integer: Optional[Annotated[int, Field(le=100, strict=True, ge=10)]] = None
int32: Optional[conint(strict=True, le=200, ge=20)] = None int32: Optional[Annotated[int, Field(le=200, strict=True, ge=20)]] = None
int64: Optional[StrictInt] = None int64: Optional[StrictInt] = None
number: confloat(le=543.2, ge=32.1) = Field(...) number: Annotated[float, Field(le=543.2, ge=32.1)]
float: Optional[confloat(le=987.6, ge=54.3)] = None double: Optional[Annotated[float, Field(le=123.4, ge=67.8)]] = None
double: Optional[confloat(le=123.4, ge=67.8)] = None decimal: Optional[Decimal] = None
decimal: Optional[condecimal()] = None string: Optional[Annotated[str, Field(strict=True)]] = None
string: Optional[constr(strict=True)] = None string_with_double_quote_pattern: Optional[Annotated[str, Field(strict=True)]] = None
string_with_double_quote_pattern: Optional[constr(strict=True)] = None
byte: Optional[Union[StrictBytes, StrictStr]] = None byte: Optional[Union[StrictBytes, StrictStr]] = None
binary: Optional[Union[StrictBytes, StrictStr]] = None binary: Optional[Union[StrictBytes, StrictStr]] = None
var_date: date = Field(..., alias="date") var_date: date = Field(alias="date")
date_time: Optional[datetime] = Field(None, alias="dateTime") date_time: Optional[datetime] = Field(default=None, alias="dateTime")
uuid: Optional[StrictStr] = None uuid: Optional[StrictStr] = None
password: constr(strict=True, max_length=64, min_length=10) = Field(...) password: Annotated[str, Field(min_length=10, strict=True, max_length=64)]
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: Optional[Annotated[str, Field(strict=True)]] = Field(default=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.") pattern_with_digits_and_delimiter: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.")
__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"] __properties = ["integer", "int32", "int64", "number", "double", "decimal", "string", "string_with_double_quote_pattern", "byte", "binary", "date", "dateTime", "uuid", "password", "pattern_with_digits", "pattern_with_digits_and_delimiter"]
@validator('string') @validator('string')
def string_validate_regular_expression(cls, value): def string_validate_regular_expression(cls, value):
@ -95,6 +97,7 @@ class FormatTest(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -124,15 +127,14 @@ class FormatTest(BaseModel):
"int32": obj.get("int32"), "int32": obj.get("int32"),
"int64": obj.get("int64"), "int64": obj.get("int64"),
"number": obj.get("number"), "number": obj.get("number"),
"float": obj.get("float"),
"double": obj.get("double"), "double": obj.get("double"),
"decimal": obj.get("decimal"), "decimal": obj.get("decimal"),
"string": obj.get("string"), "string": obj.get("string"),
"string_with_double_quote_pattern": obj.get("string_with_double_quote_pattern"), "string_with_double_quote_pattern": obj.get("string_with_double_quote_pattern"),
"byte": obj.get("byte"), "byte": obj.get("byte"),
"binary": obj.get("binary"), "binary": obj.get("binary"),
"var_date": obj.get("date"), "date": obj.get("date"),
"date_time": obj.get("dateTime"), "dateTime": obj.get("dateTime"),
"uuid": obj.get("uuid"), "uuid": obj.get("uuid"),
"password": obj.get("password"), "password": obj.get("password"),
"pattern_with_digits": obj.get("pattern_with_digits"), "pattern_with_digits": obj.get("pattern_with_digits"),

View File

@ -40,6 +40,7 @@ class HasOnlyReadOnly(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod

View File

@ -19,13 +19,14 @@ import json
from typing import Optional from typing import Optional
from pydantic import BaseModel, Field, StrictStr from pydantic import BaseModel, StrictStr
from pydantic import Field
class HealthCheckResult(BaseModel): 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 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") nullable_message: Optional[StrictStr] = Field(default=None, alias="NullableMessage")
__properties = ["NullableMessage"] __properties = ["NullableMessage"]
class Config: class Config:
@ -39,6 +40,7 @@ class HealthCheckResult(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -69,7 +71,7 @@ class HealthCheckResult(BaseModel):
return HealthCheckResult.parse_obj(obj) return HealthCheckResult.parse_obj(obj)
_obj = HealthCheckResult.parse_obj({ _obj = HealthCheckResult.parse_obj({
"nullable_message": obj.get("NullableMessage") "NullableMessage": obj.get("NullableMessage")
}) })
return _obj return _obj

View File

@ -18,14 +18,15 @@ import re # noqa: F401
import json import json
from typing import Any, Dict, Optional from typing import Any, Dict, Optional, Union
from pydantic import BaseModel, Field from pydantic import BaseModel
from pydantic import Field
class InnerDictWithProperty(BaseModel): class InnerDictWithProperty(BaseModel):
""" """
InnerDictWithProperty InnerDictWithProperty
""" """
a_property: Optional[Dict[str, Any]] = Field(None, alias="aProperty") a_property: Optional[Union[str, Any]] = Field(default=None, alias="aProperty")
__properties = ["aProperty"] __properties = ["aProperty"]
class Config: class Config:
@ -39,6 +40,7 @@ class InnerDictWithProperty(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -64,7 +66,7 @@ class InnerDictWithProperty(BaseModel):
return InnerDictWithProperty.parse_obj(obj) return InnerDictWithProperty.parse_obj(obj)
_obj = InnerDictWithProperty.parse_obj({ _obj = InnerDictWithProperty.parse_obj({
"a_property": obj.get("aProperty") "aProperty": obj.get("aProperty")
}) })
return _obj return _obj

View File

@ -19,8 +19,11 @@ import pprint
import re # noqa: F401 import re # noqa: F401
from typing import Any, List, Optional from typing import Any, List, Optional
from pydantic import BaseModel, Field, StrictStr, ValidationError, conint, validator from pydantic import BaseModel, Field, StrictStr, ValidationError, validator
from typing import Union, Any, List, TYPE_CHECKING from pydantic import Field
from typing_extensions import Annotated
from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict
from typing_extensions import Literal
from pydantic import StrictStr, Field from pydantic import StrictStr, Field
INTORSTRING_ONE_OF_SCHEMAS = ["int", "str"] INTORSTRING_ONE_OF_SCHEMAS = ["int", "str"]
@ -30,14 +33,11 @@ class IntOrString(BaseModel):
IntOrString IntOrString
""" """
# data type: int # data type: int
oneof_schema_1_validator: Optional[conint(strict=True, ge=10)] = None oneof_schema_1_validator: Optional[Annotated[int, Field(strict=True, ge=10)]] = None
# data type: str # data type: str
oneof_schema_2_validator: Optional[StrictStr] = None oneof_schema_2_validator: Optional[StrictStr] = None
if TYPE_CHECKING: actual_instance: Optional[Union[int, str]] = None
actual_instance: Union[int, str] one_of_schemas: List[str] = Literal[INTORSTRING_ONE_OF_SCHEMAS]
else:
actual_instance: Any
one_of_schemas: List[str] = Field(INTORSTRING_ONE_OF_SCHEMAS, const=True)
class Config: class Config:
validate_assignment = True validate_assignment = True

View File

@ -19,13 +19,14 @@ import json
from typing import Optional from typing import Optional
from pydantic import BaseModel, Field, StrictStr from pydantic import BaseModel, StrictStr
from pydantic import Field
class List(BaseModel): class List(BaseModel):
""" """
List List
""" """
var_123_list: Optional[StrictStr] = Field(None, alias="123-list") var_123_list: Optional[StrictStr] = Field(default=None, alias="123-list")
__properties = ["123-list"] __properties = ["123-list"]
class Config: class Config:
@ -39,6 +40,7 @@ class List(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -64,7 +66,7 @@ class List(BaseModel):
return List.parse_obj(obj) return List.parse_obj(obj)
_obj = List.parse_obj({ _obj = List.parse_obj({
"var_123_list": obj.get("123-list") "123-list": obj.get("123-list")
}) })
return _obj return _obj

View File

@ -19,14 +19,15 @@ import json
from typing import Dict, List, Optional from typing import Dict, List, Optional
from pydantic import BaseModel, Field, conlist from pydantic import BaseModel
from pydantic import Field
from petstore_api.models.tag import Tag from petstore_api.models.tag import Tag
class MapOfArrayOfModel(BaseModel): class MapOfArrayOfModel(BaseModel):
""" """
MapOfArrayOfModel MapOfArrayOfModel
""" """
shop_id_to_org_online_lip_map: Optional[Dict[str, conlist(Tag)]] = Field(None, alias="shopIdToOrgOnlineLipMap") shop_id_to_org_online_lip_map: Optional[Dict[str, List[Tag]]] = Field(default=None, alias="shopIdToOrgOnlineLipMap")
__properties = ["shopIdToOrgOnlineLipMap"] __properties = ["shopIdToOrgOnlineLipMap"]
class Config: class Config:
@ -40,6 +41,7 @@ class MapOfArrayOfModel(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -74,7 +76,7 @@ class MapOfArrayOfModel(BaseModel):
return MapOfArrayOfModel.parse_obj(obj) return MapOfArrayOfModel.parse_obj(obj)
_obj = MapOfArrayOfModel.parse_obj({ _obj = MapOfArrayOfModel.parse_obj({
"shop_id_to_org_online_lip_map": dict( "shopIdToOrgOnlineLipMap": dict(
(_k, (_k,
[Tag.from_dict(_item) for _item in _v] [Tag.from_dict(_item) for _item in _v]
if _v is not None if _v is not None

View File

@ -52,6 +52,7 @@ class MapTest(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod

View File

@ -19,7 +19,8 @@ import json
from datetime import datetime from datetime import datetime
from typing import Dict, Optional from typing import Dict, Optional
from pydantic import BaseModel, Field, StrictStr from pydantic import BaseModel, StrictStr
from pydantic import Field
from petstore_api.models.animal import Animal from petstore_api.models.animal import Animal
class MixedPropertiesAndAdditionalPropertiesClass(BaseModel): class MixedPropertiesAndAdditionalPropertiesClass(BaseModel):
@ -27,7 +28,7 @@ class MixedPropertiesAndAdditionalPropertiesClass(BaseModel):
MixedPropertiesAndAdditionalPropertiesClass MixedPropertiesAndAdditionalPropertiesClass
""" """
uuid: Optional[StrictStr] = None uuid: Optional[StrictStr] = None
date_time: Optional[datetime] = Field(None, alias="dateTime") date_time: Optional[datetime] = Field(default=None, alias="dateTime")
map: Optional[Dict[str, Animal]] = None map: Optional[Dict[str, Animal]] = None
__properties = ["uuid", "dateTime", "map"] __properties = ["uuid", "dateTime", "map"]
@ -42,6 +43,7 @@ class MixedPropertiesAndAdditionalPropertiesClass(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -75,7 +77,7 @@ class MixedPropertiesAndAdditionalPropertiesClass(BaseModel):
_obj = MixedPropertiesAndAdditionalPropertiesClass.parse_obj({ _obj = MixedPropertiesAndAdditionalPropertiesClass.parse_obj({
"uuid": obj.get("uuid"), "uuid": obj.get("uuid"),
"date_time": obj.get("dateTime"), "dateTime": obj.get("dateTime"),
"map": dict( "map": dict(
(_k, Animal.from_dict(_v)) (_k, Animal.from_dict(_v))
for _k, _v in obj.get("map").items() for _k, _v in obj.get("map").items()

View File

@ -19,14 +19,15 @@ import json
from typing import Optional from typing import Optional
from pydantic import BaseModel, Field, StrictInt, StrictStr from pydantic import BaseModel, StrictInt, StrictStr
from pydantic import Field
class Model200Response(BaseModel): class Model200Response(BaseModel):
""" """
Model for testing model name starting with number # noqa: E501 Model for testing model name starting with number # noqa: E501
""" """
name: Optional[StrictInt] = None name: Optional[StrictInt] = None
var_class: Optional[StrictStr] = Field(None, alias="class") var_class: Optional[StrictStr] = Field(default=None, alias="class")
__properties = ["name", "class"] __properties = ["name", "class"]
class Config: class Config:
@ -40,6 +41,7 @@ class Model200Response(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -66,7 +68,7 @@ class Model200Response(BaseModel):
_obj = Model200Response.parse_obj({ _obj = Model200Response.parse_obj({
"name": obj.get("name"), "name": obj.get("name"),
"var_class": obj.get("class") "class": obj.get("class")
}) })
return _obj return _obj

View File

@ -19,13 +19,14 @@ import json
from typing import Optional from typing import Optional
from pydantic import BaseModel, Field, StrictInt from pydantic import BaseModel, StrictInt
from pydantic import Field
class ModelReturn(BaseModel): class ModelReturn(BaseModel):
""" """
Model for testing reserved words # noqa: E501 Model for testing reserved words # noqa: E501
""" """
var_return: Optional[StrictInt] = Field(None, alias="return") var_return: Optional[StrictInt] = Field(default=None, alias="return")
__properties = ["return"] __properties = ["return"]
class Config: class Config:
@ -39,6 +40,7 @@ class ModelReturn(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -64,7 +66,7 @@ class ModelReturn(BaseModel):
return ModelReturn.parse_obj(obj) return ModelReturn.parse_obj(obj)
_obj = ModelReturn.parse_obj({ _obj = ModelReturn.parse_obj({
"var_return": obj.get("return") "return": obj.get("return")
}) })
return _obj return _obj

View File

@ -19,16 +19,17 @@ import json
from typing import Optional from typing import Optional
from pydantic import BaseModel, Field, StrictInt, StrictStr from pydantic import BaseModel, StrictInt, StrictStr
from pydantic import Field
class Name(BaseModel): class Name(BaseModel):
""" """
Model for testing model name same as property name # noqa: E501 Model for testing model name same as property name # noqa: E501
""" """
name: StrictInt = Field(...) name: StrictInt
snake_case: Optional[StrictInt] = None snake_case: Optional[StrictInt] = None
var_property: Optional[StrictStr] = Field(None, alias="property") var_property: Optional[StrictStr] = Field(default=None, alias="property")
var_123_number: Optional[StrictInt] = Field(None, alias="123Number") var_123_number: Optional[StrictInt] = Field(default=None, alias="123Number")
__properties = ["name", "snake_case", "property", "123Number"] __properties = ["name", "snake_case", "property", "123Number"]
class Config: class Config:
@ -42,6 +43,7 @@ class Name(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -71,8 +73,8 @@ class Name(BaseModel):
_obj = Name.parse_obj({ _obj = Name.parse_obj({
"name": obj.get("name"), "name": obj.get("name"),
"snake_case": obj.get("snake_case"), "snake_case": obj.get("snake_case"),
"var_property": obj.get("property"), "property": obj.get("property"),
"var_123_number": obj.get("123Number") "123Number": obj.get("123Number")
}) })
return _obj return _obj

View File

@ -18,26 +18,26 @@ import re # noqa: F401
import json import json
from datetime import date, datetime from datetime import date, datetime
from typing import Any, Dict, List, Optional from typing import Any, Dict, List, Optional, Union
from pydantic import BaseModel, Field, StrictBool, StrictInt, StrictStr, conlist from pydantic import BaseModel, StrictBool, StrictInt, StrictStr
class NullableClass(BaseModel): class NullableClass(BaseModel):
""" """
NullableClass NullableClass
""" """
required_integer_prop: Optional[StrictInt] = Field(...) required_integer_prop: Optional[StrictInt]
integer_prop: Optional[StrictInt] = None integer_prop: Optional[StrictInt] = None
number_prop: Optional[float] = None number_prop: Optional[float] = None
boolean_prop: Optional[StrictBool] = None boolean_prop: Optional[StrictBool] = None
string_prop: Optional[StrictStr] = None string_prop: Optional[StrictStr] = None
date_prop: Optional[date] = None date_prop: Optional[date] = None
datetime_prop: Optional[datetime] = None datetime_prop: Optional[datetime] = None
array_nullable_prop: Optional[conlist(Dict[str, Any])] = None array_nullable_prop: Optional[List[Union[str, Any]]] = None
array_and_items_nullable_prop: Optional[conlist(Dict[str, Any])] = None array_and_items_nullable_prop: Optional[List[Union[str, Any]]] = None
array_items_nullable: Optional[conlist(Dict[str, Any])] = None array_items_nullable: Optional[List[Union[str, Any]]] = None
object_nullable_prop: Optional[Dict[str, Dict[str, Any]]] = None object_nullable_prop: Optional[Dict[str, Union[str, Any]]] = None
object_and_items_nullable_prop: Optional[Dict[str, Dict[str, Any]]] = None object_and_items_nullable_prop: Optional[Dict[str, Union[str, Any]]] = None
object_items_nullable: Optional[Dict[str, Dict[str, Any]]] = None object_items_nullable: Optional[Dict[str, Union[str, Any]]] = None
additional_properties: Dict[str, Any] = {} 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"] __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"]
@ -52,6 +52,7 @@ class NullableClass(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -154,7 +155,7 @@ class NullableClass(BaseModel):
}) })
# store additional fields in additional_properties # store additional fields in additional_properties
for _key in obj.keys(): for _key in obj.keys():
if _key not in cls.__properties: if _key not in cls.__properties.default:
_obj.additional_properties[_key] = obj.get(_key) _obj.additional_properties[_key] = obj.get(_key)
return _obj return _obj

View File

@ -19,14 +19,16 @@ import json
from typing import Optional from typing import Optional
from pydantic import BaseModel, Field, StrictInt, constr, validator from pydantic import BaseModel, StrictInt, validator
from pydantic import Field
from typing_extensions import Annotated
class NullableProperty(BaseModel): class NullableProperty(BaseModel):
""" """
NullableProperty NullableProperty
""" """
id: StrictInt = Field(...) id: StrictInt
name: Optional[constr(strict=True)] = Field(...) name: Optional[Annotated[str, Field(strict=True)]]
__properties = ["id", "name"] __properties = ["id", "name"]
@validator('name') @validator('name')
@ -50,6 +52,7 @@ class NullableProperty(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod

View File

@ -19,13 +19,14 @@ import json
from typing import Optional from typing import Optional
from pydantic import BaseModel, Field from pydantic import BaseModel
from pydantic import Field
class NumberOnly(BaseModel): class NumberOnly(BaseModel):
""" """
NumberOnly NumberOnly
""" """
just_number: Optional[float] = Field(None, alias="JustNumber") just_number: Optional[float] = Field(default=None, alias="JustNumber")
__properties = ["JustNumber"] __properties = ["JustNumber"]
class Config: class Config:
@ -39,6 +40,7 @@ class NumberOnly(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -64,7 +66,7 @@ class NumberOnly(BaseModel):
return NumberOnly.parse_obj(obj) return NumberOnly.parse_obj(obj)
_obj = NumberOnly.parse_obj({ _obj = NumberOnly.parse_obj({
"just_number": obj.get("JustNumber") "JustNumber": obj.get("JustNumber")
}) })
return _obj return _obj

View File

@ -19,13 +19,14 @@ import json
from typing import Optional from typing import Optional
from pydantic import BaseModel, Field, StrictBool from pydantic import BaseModel, StrictBool
from pydantic import Field
class ObjectToTestAdditionalProperties(BaseModel): class ObjectToTestAdditionalProperties(BaseModel):
""" """
Minimal object # noqa: E501 Minimal object # noqa: E501
""" """
var_property: Optional[StrictBool] = Field(False, alias="property", description="Property") var_property: Optional[StrictBool] = Field(default=False, description="Property", alias="property")
__properties = ["property"] __properties = ["property"]
class Config: class Config:
@ -39,6 +40,7 @@ class ObjectToTestAdditionalProperties(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -64,7 +66,7 @@ class ObjectToTestAdditionalProperties(BaseModel):
return ObjectToTestAdditionalProperties.parse_obj(obj) return ObjectToTestAdditionalProperties.parse_obj(obj)
_obj = ObjectToTestAdditionalProperties.parse_obj({ _obj = ObjectToTestAdditionalProperties.parse_obj({
"var_property": obj.get("property") if obj.get("property") is not None else False "property": obj.get("property") if obj.get("property") is not None else False
}) })
return _obj return _obj

View File

@ -19,7 +19,8 @@ import json
from typing import List, Optional from typing import List, Optional
from pydantic import BaseModel, Field, StrictStr, conlist from pydantic import BaseModel, StrictStr
from pydantic import Field
from petstore_api.models.deprecated_object import DeprecatedObject from petstore_api.models.deprecated_object import DeprecatedObject
class ObjectWithDeprecatedFields(BaseModel): class ObjectWithDeprecatedFields(BaseModel):
@ -28,8 +29,8 @@ class ObjectWithDeprecatedFields(BaseModel):
""" """
uuid: Optional[StrictStr] = None uuid: Optional[StrictStr] = None
id: Optional[float] = None id: Optional[float] = None
deprecated_ref: Optional[DeprecatedObject] = Field(None, alias="deprecatedRef") deprecated_ref: Optional[DeprecatedObject] = Field(default=None, alias="deprecatedRef")
bars: Optional[conlist(StrictStr)] = None bars: Optional[List[StrictStr]] = None
__properties = ["uuid", "id", "deprecatedRef", "bars"] __properties = ["uuid", "id", "deprecatedRef", "bars"]
class Config: class Config:
@ -43,6 +44,7 @@ class ObjectWithDeprecatedFields(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -73,7 +75,7 @@ class ObjectWithDeprecatedFields(BaseModel):
_obj = ObjectWithDeprecatedFields.parse_obj({ _obj = ObjectWithDeprecatedFields.parse_obj({
"uuid": obj.get("uuid"), "uuid": obj.get("uuid"),
"id": obj.get("id"), "id": obj.get("id"),
"deprecated_ref": DeprecatedObject.from_dict(obj.get("deprecatedRef")) if obj.get("deprecatedRef") is not None else None, "deprecatedRef": DeprecatedObject.from_dict(obj.get("deprecatedRef")) if obj.get("deprecatedRef") is not None else None,
"bars": obj.get("bars") "bars": obj.get("bars")
}) })
return _obj return _obj

View File

@ -22,7 +22,8 @@ from typing import Any, List, Optional
from pydantic import BaseModel, Field, StrictStr, ValidationError, validator from pydantic import BaseModel, Field, StrictStr, ValidationError, validator
from petstore_api.models.enum_string1 import EnumString1 from petstore_api.models.enum_string1 import EnumString1
from petstore_api.models.enum_string2 import EnumString2 from petstore_api.models.enum_string2 import EnumString2
from typing import Union, Any, List, TYPE_CHECKING from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict
from typing_extensions import Literal
from pydantic import StrictStr, Field from pydantic import StrictStr, Field
ONEOFENUMSTRING_ONE_OF_SCHEMAS = ["EnumString1", "EnumString2"] ONEOFENUMSTRING_ONE_OF_SCHEMAS = ["EnumString1", "EnumString2"]
@ -35,11 +36,8 @@ class OneOfEnumString(BaseModel):
oneof_schema_1_validator: Optional[EnumString1] = None oneof_schema_1_validator: Optional[EnumString1] = None
# data type: EnumString2 # data type: EnumString2
oneof_schema_2_validator: Optional[EnumString2] = None oneof_schema_2_validator: Optional[EnumString2] = None
if TYPE_CHECKING: actual_instance: Optional[Union[EnumString1, EnumString2]] = None
actual_instance: Union[EnumString1, EnumString2] one_of_schemas: List[str] = Literal[ONEOFENUMSTRING_ONE_OF_SCHEMAS]
else:
actual_instance: Any
one_of_schemas: List[str] = Field(ONEOFENUMSTRING_ONE_OF_SCHEMAS, const=True)
class Config: class Config:
validate_assignment = True validate_assignment = True

View File

@ -19,17 +19,18 @@ import json
from datetime import datetime from datetime import datetime
from typing import Optional from typing import Optional
from pydantic import BaseModel, Field, StrictBool, StrictInt, StrictStr, validator from pydantic import BaseModel, StrictBool, StrictInt, StrictStr, validator
from pydantic import Field
class Order(BaseModel): class Order(BaseModel):
""" """
Order Order
""" """
id: Optional[StrictInt] = None id: Optional[StrictInt] = None
pet_id: Optional[StrictInt] = Field(None, alias="petId") pet_id: Optional[StrictInt] = Field(default=None, alias="petId")
quantity: Optional[StrictInt] = None quantity: Optional[StrictInt] = None
ship_date: Optional[datetime] = Field(None, alias="shipDate") ship_date: Optional[datetime] = Field(default=None, alias="shipDate")
status: Optional[StrictStr] = Field(None, description="Order Status") status: Optional[StrictStr] = Field(default=None, description="Order Status")
complete: Optional[StrictBool] = False complete: Optional[StrictBool] = False
__properties = ["id", "petId", "quantity", "shipDate", "status", "complete"] __properties = ["id", "petId", "quantity", "shipDate", "status", "complete"]
@ -54,6 +55,7 @@ class Order(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -80,9 +82,9 @@ class Order(BaseModel):
_obj = Order.parse_obj({ _obj = Order.parse_obj({
"id": obj.get("id"), "id": obj.get("id"),
"pet_id": obj.get("petId"), "petId": obj.get("petId"),
"quantity": obj.get("quantity"), "quantity": obj.get("quantity"),
"ship_date": obj.get("shipDate"), "shipDate": obj.get("shipDate"),
"status": obj.get("status"), "status": obj.get("status"),
"complete": obj.get("complete") if obj.get("complete") is not None else False "complete": obj.get("complete") if obj.get("complete") is not None else False
}) })

View File

@ -41,6 +41,7 @@ class OuterComposite(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod

View File

@ -19,7 +19,7 @@ import json
from typing import Optional from typing import Optional
from pydantic import BaseModel, Field from pydantic import BaseModel
from petstore_api.models.outer_enum import OuterEnum from petstore_api.models.outer_enum import OuterEnum
from petstore_api.models.outer_enum_integer import OuterEnumInteger from petstore_api.models.outer_enum_integer import OuterEnumInteger
@ -28,7 +28,7 @@ class OuterObjectWithEnumProperty(BaseModel):
OuterObjectWithEnumProperty OuterObjectWithEnumProperty
""" """
str_value: Optional[OuterEnum] = None str_value: Optional[OuterEnum] = None
value: OuterEnumInteger = Field(...) value: OuterEnumInteger
__properties = ["str_value", "value"] __properties = ["str_value", "value"]
class Config: class Config:
@ -42,6 +42,7 @@ class OuterObjectWithEnumProperty(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod

View File

@ -19,14 +19,15 @@ import json
from typing import Dict, Optional from typing import Dict, Optional
from pydantic import BaseModel, Field from pydantic import BaseModel
from pydantic import Field
from petstore_api.models.inner_dict_with_property import InnerDictWithProperty from petstore_api.models.inner_dict_with_property import InnerDictWithProperty
class Parent(BaseModel): class Parent(BaseModel):
""" """
Parent Parent
""" """
optional_dict: Optional[Dict[str, InnerDictWithProperty]] = Field(None, alias="optionalDict") optional_dict: Optional[Dict[str, InnerDictWithProperty]] = Field(default=None, alias="optionalDict")
__properties = ["optionalDict"] __properties = ["optionalDict"]
class Config: class Config:
@ -40,6 +41,7 @@ class Parent(BaseModel):
def to_json(self) -> str: def to_json(self) -> str:
"""Returns the JSON representation of the model using alias""" """Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict()) return json.dumps(self.to_dict())
@classmethod @classmethod
@ -72,7 +74,7 @@ class Parent(BaseModel):
return Parent.parse_obj(obj) return Parent.parse_obj(obj)
_obj = Parent.parse_obj({ _obj = Parent.parse_obj({
"optional_dict": dict( "optionalDict": dict(
(_k, InnerDictWithProperty.from_dict(_v)) (_k, InnerDictWithProperty.from_dict(_v))
for _k, _v in obj.get("optionalDict").items() for _k, _v in obj.get("optionalDict").items()
) )

Some files were not shown because too many files have changed in this diff Show More