Documentation for the python Generator

METADATA

PropertyValueNotes
generator namepythonpass this to the generate command after -g
generator stabilitySTABLE
generator typeCLIENT
generator languagePython
generator language version>=3.7
generator default templating enginehandlebars
helpTxtGenerates a Python client library

Features in this generator:
- type hints on endpoints and model creation
- model parameter names use the spec defined keys and cases
- robust composition (oneOf/anyOf/allOf/not) where payload data is stored in one instance only
- endpoint parameter names use the spec defined keys and cases
- inline schemas are supported at any location including composition
- multiple content types supported in request body and response bodies
- run time type checking
- Sending/receiving decimals as strings supported with type:string format: number -> DecimalSchema
- Sending/receiving uuids as strings supported with type:string format: uuid -> UUIDSchema
- quicker load time for python modules (a single endpoint can be imported and used without loading others)
- all instances of schemas dynamically inherit from all matching schemas so one can use isinstance to check if validation passed
- composed schemas with type constraints supported (type:object + oneOf/anyOf/allOf)
- schemas are not coerced/cast. For example string + date are both stored as string, and there is a date accessor
- Exceptions: int/float is stored as Decimal, When receiving data from headers it will start as str and may need to be cast for example to int

CONFIG OPTIONS

These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to configuration docs for more details.

OptionDescriptionValuesDefault
generateSourceCodeOnlySpecifies that only a library source code is to be generated.false
hideGenerationTimestampHides the generation timestamp when files are generated.true
librarylibrary template (sub-template) to use: urllib3urllib3
nonCompliantUseDiscriminatorIfCompositionFailsWhen true, If the payload fails to validate against composed schemas (allOf/anyOf/oneOf/not) and a discriminator is present, then ignore the composition validation errors and attempt to use the discriminator to validate the payload.<br />Note: setting this to true makes the generated client not comply with json schema because it ignores composition validation errors. Please consider making your schemas more restrictive rather than setting this to true. You can do that by:<ul><li>defining the propertyName as an enum with only one value in the schemas that are in your discriminator map</li><li>setting additionalProperties: false in your schemas</li></ul>
true
If composition fails and a discriminator exists, the composition errors will be ignored and validation will be attempted with the discriminator
false
Composition validation must succeed. Discriminator validation must succeed.
false
packageNamepython package name (convention: snake_case).openapi_client
packageUrlpython package URL.null
packageVersionpython package version.1.0.0
projectNamepython project name in setup.py (e.g. petstore-api).null
recursionLimitSet the recursion limit. If not set, use the system default value.null
useInlineModelResolveruse the inline model resolver, if true inline complex models will be extracted into components and $refs to them will be usedfalse
useNoseuse the nose test frameworkfalse

IMPORT MAPPING

Type/AliasImports

INSTANTIATION TYPES

Type/AliasInstantiated By
mapdict

LANGUAGE PRIMITIVES

  • Dict
  • List
  • bool
  • bytes
  • date
  • datetime
  • dict
  • file
  • file_type
  • float
  • int
  • list
  • none_type
  • object
  • str

RESERVED WORDS

  • all_params
  • and
  • as
  • assert
  • async
  • auth_settings
  • await
  • body_params
  • bool
  • break
  • class
  • continue
  • def
  • del
  • dict
  • elif
  • else
  • except
  • exec
  • false
  • file_type
  • finally
  • float
  • for
  • form_params
  • from
  • frozendict
  • global
  • header_params
  • if
  • import
  • in
  • int
  • is
  • lambda
  • list
  • local_var_files
  • none
  • none_type
  • nonlocal
  • not
  • or
  • pass
  • path_params
  • print
  • property
  • query_params
  • raise
  • resource_path
  • return
  • self
  • str
  • true
  • try
  • tuple
  • while
  • with
  • yield

FEATURE SET

Client Modification Feature

NameSupportedDefined By
BasePathToolingExtension
AuthorizationsToolingExtension
UserAgentToolingExtension
MockServerToolingExtension

Data Type Feature

NameSupportedDefined By
CustomOAS2,OAS3
Int32OAS2,OAS3
Int64OAS2,OAS3
FloatOAS2,OAS3
DoubleOAS2,OAS3
DecimalToolingExtension
StringOAS2,OAS3
ByteOAS2,OAS3
BinaryOAS2,OAS3
BooleanOAS2,OAS3
DateOAS2,OAS3
DateTimeOAS2,OAS3
PasswordOAS2,OAS3
FileOAS2
Uuid
ArrayOAS2,OAS3
NullOAS3
AnyTypeOAS2,OAS3
ObjectOAS2,OAS3
MapsToolingExtension
CollectionFormatOAS2
CollectionFormatMultiOAS2
EnumOAS2,OAS3
ArrayOfEnumToolingExtension
ArrayOfModelToolingExtension
ArrayOfCollectionOfPrimitivesToolingExtension
ArrayOfCollectionOfModelToolingExtension
ArrayOfCollectionOfEnumToolingExtension
MapOfEnumToolingExtension
MapOfModelToolingExtension
MapOfCollectionOfPrimitivesToolingExtension
MapOfCollectionOfModelToolingExtension
MapOfCollectionOfEnumToolingExtension

Documentation Feature

NameSupportedDefined By
ReadmeToolingExtension
ModelToolingExtension
ApiToolingExtension

Global Feature

NameSupportedDefined By
HostOAS2,OAS3
BasePathOAS2,OAS3
InfoOAS2,OAS3
SchemesOAS2,OAS3
PartialSchemesOAS2,OAS3
ConsumesOAS2
ProducesOAS2
ExternalDocumentationOAS2,OAS3
ExamplesOAS2,OAS3
XMLStructureDefinitionsOAS2,OAS3
MultiServerOAS3
ParameterizedServerOAS3
ParameterStylingOAS3
CallbacksOAS3
LinkObjectsOAS3

Parameter Feature

NameSupportedDefined By
PathOAS2,OAS3
QueryOAS2,OAS3
HeaderOAS2,OAS3
BodyOAS2
FormUnencodedOAS2
FormMultipartOAS2
CookieOAS3

Schema Support Feature

NameSupportedDefined By
SimpleOAS2,OAS3
CompositeOAS2,OAS3
PolymorphismOAS2,OAS3
UnionOAS3
allOfOAS2,OAS3
anyOfOAS3
oneOfOAS3
notOAS3

Security Feature

NameSupportedDefined By
BasicAuthOAS2,OAS3
ApiKeyOAS2,OAS3
OpenIDConnectOAS3
BearerTokenOAS3
OAuth2_ImplicitOAS2,OAS3
OAuth2_PasswordOAS2,OAS3
OAuth2_ClientCredentialsOAS2,OAS3
OAuth2_AuthorizationCodeOAS2,OAS3

Wire Format Feature

NameSupportedDefined By
JSONOAS2,OAS3
XMLOAS2,OAS3
PROTOBUFToolingExtension
CustomOAS2,OAS3
Last updated on by julien Lengrand-Lambert