59 Commits

Author SHA1 Message Date
Justin Black
798ad2f87d
[python-experimental] simplifies json serialization (#7061)
* Requires python >= 3.5, adds type hints to call_api method

* Adds type hints to files_parameters and __call_api

* Adds and uses a new json encoded to prepare data before it is sent

* Removes nose name from gitlab testing invocations

* Also updates travis to py>=3.5

* Collapses encoder back into sanitize_for_serialization
2020-07-28 08:16:19 -07:00
Justin Black
ee0686e13f
Python-exp clean up model classnames (#7054)
* Adds lazy_import, removes python-exp java class renaming code, partial removal of getPythonClassName call sites

Fixes PythonClientExperimentalTest.java

Python-exp smaples regeneration

Revers makefile

Reverst pom.xml

Fixes model imports in models.__init__

Updates docstring, omits lazy import in additional properties if we dont need it

Improves additional_properties_type assignment if None

Removes getPythonClassName

Fixes python-exp tests

* Removes unused makefiles
2020-07-27 18:35:41 -07:00
Justin Black
0e0f8eb74c
[python-experimental] Removes python2 (#6991)
* Removes future from python-exp v3 sample

* Removes future from python-exp v2 sample

* Deletes future from remaining python-exp files

* Removes six from python-exp templates

* Removes six from python-exp samples

* Removes mock from python-exp

* Python-exp switched to py3

* Removes python 2.7 for python-exp ci testing

* Requires python>=3.3 for python-exp

* Reverts unnecessary changes to two templates
2020-07-19 09:45:56 -07:00
Justin Black
ed84280108
Python-exp remove codegemodel mutation, allow mixed OneOf types (#6797)
* Stops converting primitive models into object models, adds ComposedSchemas with mixed type

* Samples update for python-exp
2020-07-18 10:13:22 -07:00
Justin Black
dad931a25a
Python exp sample component renaming + additions (#6917)
* Stops converting primitive models into object models, adds ComposedSchemas with mixed type

* Reverts java and mustache changes

* Reverts mroe files

* Samples regen

* Fixes remaining tests
2020-07-13 10:22:03 -07:00
William Cheng
61789475ea update python samples 2020-07-03 18:51:31 +08:00
Jiri Kuncar
8b9c070e5d
[Python] Support for per-operation servers (#6557)
* Dynamic server support

* regenerated

* Apply suggestions from code review

Co-authored-by: Thomas Hervé <thomas.herve@datadoghq.com>

* regenerated

* Add ParameterizedServer feature to Python experimental

* Fix lookup of server variables

* Add tests and change default value for servers

* Fix server variables

* Return base path when index is None

* Use HOST

* Apply suggestions from code review

* Apply suggestions from code review

* regenerated

* Add specific tests for dynamic servers

* regenerated

* add docstring

* regenerated

* Fix wrong merge resolution

Co-authored-by: Thomas Hervé <thomas.herve@datadoghq.com>
2020-06-25 21:28:54 -07:00
Jiri Kuncar
33328977d1
[Python] enum serialization (#6746)
* [Python] enum serialization

* Fix serialization of nested enum
2020-06-22 11:07:18 -07:00
Thomas Hervé
380b173e50
[Python] Remove duplicate definition of Endpoint class (#6667)
* Remove duplicate definition of Endpoint class

The class is copied in every API modules, we can share it alongside the
API client.

* Regenerate examples
2020-06-16 07:52:45 -07:00
Jiri Kuncar
aa201b3d9f
[Python] Add attribute_map to simple model (#6669)
* [python] Add missing attribute_map definition

* regenerated
2020-06-15 12:53:43 -07:00
Jiri Kuncar
046ba7de8e
[feature][python] Support aliasing of API keys (#6469)
* [python] Support aliasing of API keys

* Support for aliasing and prefix

* Make more realistic usage

* Regenerate

* Document alias in generated code

* Support override of aliased keys

* Use diferent id and name for api keys

* ensure up-to-date

* Simple example without x-auth-id-alias

* regenerate docs

* Regenerate

* Provide separate spec for x-auth-id-alias

* Apply suggestions from code review

* regenerated
2020-06-11 09:19:57 -07:00
Jiri Kuncar
ebcce67419
[Python] Update docstring and fix a typo (#6612)
* [Python] Update docstring and fix a typo

* regenerate
2020-06-10 19:06:39 -07:00
Alexey Volkov
6f6c8ede79
[Python] Fixed docstrings in api.mustache (#6391)
* [Python] Fixed docstrings

Fixes https://github.com/swagger-api/swagger-codegen/issues/9630

* Updated generated files

* Fixed python-experimental

* Updated generated files

* Fully fixed the format of the docstrings

* Updated generated files

* Updated generated files in openapi3
2020-06-04 08:46:35 -07:00
Jiri Kuncar
e708cdc83e
[BUG][python] Support named arrays (#6493)
* [python] Support named arrays

* Fix named array type

* Use ModelSimple

* Reset samples

* Regenerated

* Animal farm test

* Array of enums

* Clean-up

* Clean-up

* Clean-up

* Fix array type generation

* simplify

* array model is not alias

* Array model has one value field

* ensure up-to-date

* ./bin/utils/ensure-up-to-date --batch

* Solve issue with missing import for array model

* regenerate
2020-06-04 07:50:53 -07:00
Justin Black
d8c422398e
[python-experimental] Quicken package loading (#6437)
* apis and models contains all apis and models, omits loading them in the package namespace

* Runs git add -a and commits it

* Fixes test_outer_enum.py

* Fixes test_fruit.py

* Updates test_fruit and test_mammal

* Fixes test_parent_pet

* Updates test_discard_unknown_properties.py

* Updates test_deserialization.py

* Updates v2 docs md files for apis + the readme

* Fixes v2 tests

* v2 doc updates

* Updates v3 docs

* Reverts python_doc_auth_partial.mustache

* Adds sys to v3 tests

* Adds FILES update

Co-authored-by: Justin Black <justinblack@justins-air.lan>
2020-06-01 00:25:37 -07:00
Sebastien Rosset
f7f41410e7
[codegen][python-experimental] Composed schema with additionalProperties (#6290)
* Mustache template should use invokerPackage tag to generate import

* Add a unit test for allOf and additionalProperties

* Fix getAdditionalProperties

* Add code comments

* Add code comments

* set nullable for additionalproperties

* add variants of additionalProperties

* Add more unit tests

* Handle additionalProperties for composed schemas

* improve code comments

* Add code comments

* Add code comments

* Add code comments

* Add code comments

* Add code comments

* Add assertions in unit tests

* Add new property to support the 'additionalProperties' keyword with composed schemas

* run sample scripts

* fix unit tests to handle additionalProperties

* Handle additional properties and composed schema

* Handle additional properties and composed schema

* Add support for additionalProperties and composed schema

* Format java code

* Add more unit tests for Python

* Handle reference in additionalProperty keyword

* Handle reference in additionalProperty keyword

* Add use case for additionalProperties and reference

* run sample scripts

* resolve schema reference

* Add OpenAPI argument

* Add OpenAPI argument

* Add OpenAPI argument

* Add OpenAPI argument

* Add OpenAPI argument

* Handle additional property keyword with reference

* Handle additional property keyword with reference

* Handle additional property keyword with reference

* Handle additional property keyword with reference

* add additionalproperties attribute with boolean values

* Run sample scripts

* handle additional properties

* Handle additionalProperties boolean values

* Run sample scripts

* fix javadoc issues

* fix javadoc issues

* Add Locale to String.toLowerCase

* execute sample scripts

* handle additional properties

* Add code comments

* Handle imports of referenced models in additional properties

* Handle isNullable class

* handle nullable type

* improve documentation, run sample scripts

* improve documentation, run sample scripts

* execute sample scripts

* execute sample scripts

* Execute sample scripts

* Run samples scripts

* set legacyAdditionalPropertiesBehavior to true by default, except python

* create separate yaml file to avoid having lots of changes in the pr

* create separate yaml file to avoid having lots of changes in the pr

* create separate yaml file to avoid having lots of changes in the pr

* create separate yaml file to avoid having lots of changes in the pr

* create separate yaml file to avoid having lots of changes in the pr

* create separate yaml file to avoid having lots of changes in the pr

* Change name of CLI option

* Generate doc

* Add TODO statement

* add code comments

* run samples scripts

* run sample scripts

* run sample scripts

* run sample scripts

* run sample scripts

* run sample scripts

* run sample scripts

* run sample scripts

* run sample scripts

* run sample scripts

* run sample scripts

* run sample scripts

* refactor cli option for additional properties

* refactor cli option for additional properties

* run samples scripts

* run sample scripts

* run sample scripts

* run sample scripts

* run sample scripts

* Add yaml comments

* small refactor

* small refactor

* run sample scripts

* run sample scripts

* fix unit tests

* Set disallowAdditionalPropertiesIfNotPresent flag

* reduced size of test yaml file

* simplify code and add imports directly

* rename some of the properties used in tests

* Handle more scenarios for nullable types

* add code comments

* Adds *args input to __init__ method to fix test testFruitNullValue

* Resolve merge issues

* run samples scripts

* run doc generator

* fix merge conflicts

Co-authored-by: Justin Black <justin.a.black@gmail.com>
2020-05-29 00:40:48 +08:00
Justin Black
a017f3a892
python-experimental updates ancestor + adds descendant discriminator tests (#6417)
* Updates comments in new method

* Adds missing line in model_utils.py

* Removes biology examples, adds ParentPet ancestor example + test, adds Pig schemas

* Updates comment and var names in get_discriminator_class, adds testMammal test

* Updates comment
2020-05-27 20:33:43 -07:00
Sebastien Rosset
583aa24152
[Python-experimental] Fix type error if oneof/anyof child schema is null type (#6387)
* Mustache template should use invokerPackage tag to generate import

* Fix runtime exception when composed schema has 'null' type

* Fix runtime exception when composed schema has 'null' type
2020-05-24 17:21:00 -07:00
Sebastien Rosset
1da9092dad
[Python-experimental] Rename from_server variable to json_variable_naming (#6390)
* Mustache template should use invokerPackage tag to generate import

* Add unit test showing how to construct objects from a JSON dict

* rename from_server to json_variable_naming

* rename from_server to json_variable_naming

* fix code so it can execute in python 2.x

* rename variable

* fix typo

* fix typo

* fix deprecation warning

* fix deprecation warning

* fix deprecation warning
2020-05-22 19:09:12 -07:00
Sebastien Rosset
19e14237aa
[python-experimental] Add support for pep 3134, attach cause of exception (#6388)
* Mustache template should use invokerPackage tag to generate import

* Add exception cause

* using six module for exception chaining in Python 3.x
2020-05-22 09:44:15 -07:00
Sebastien Rosset
69177517ef
[Python-experimental] Should accept float value serialized without decimal point (#6386)
* Mustache template should use invokerPackage tag to generate import

* A float may be serialized as an integer, e.g. '3' is a valid serialized float

* A float may be serialized as an integer, e.g. '3' is a valid serialized float

* add unit tests
2020-05-21 18:59:31 -07:00
Sebastien Rosset
b4954b0d80
[codegen][python-experimental] Add configuration knob to disable JSON schema validation (#6227)
* Add knob to disable JSON schema structural validation

* Add knob to disable JSON schema structural validation

* Fix formatting issues

* execute sample scripts

* execute sample scripts

* fix multipleOf validation issue

* Add validation log for multipleOf. Add customizable validation checks. add unit tests for JSON schema validation

* Add validation log for multipleOf. Add customizable validation checks. add unit tests for JSON schema validation

* Add validation log for multipleOf. Add customizable validation checks. add unit tests for JSON schema validation

* Add validation log for multipleOf. Add customizable validation checks. add unit tests for JSON schema validation. Fix for python 2

* address review comments
2020-05-17 09:11:01 -07:00
Sebastien Rosset
04ff319502
[python-experimental] Support schema property which has $ref to 'oneOf' schema and child schema is null type (#6275)
* Handle null type

* Handle null type

* Handle null type. Add 'null' type in the OAS document for testing purpose

* Handle null type. Add 'null' type in the OAS document for testing purpose

* Handle null type. Add 'null' type in the OAS document for testing purpose

* Handle null type. Add 'null' type in the OAS document for testing purpose

* Handle null type. Add 'null' type in the OAS document for testing purpose

* Handle null type. Add 'null' type in the OAS document for testing purpose

* improve documentation

* Handle 'null' type

* Handle 'null' type. Add unit tests

* Add NullType for go

* Add NullType for go

* fix modeling of AnyType for go-experimental

* execute scripts in bin directory

* Add review comments

* Add 'null' type in oneOf

* Improve OAS YAML file for golang openapi3 samples

* 'Any type' includes the null value, so 'isNullable' should be set to TRUE

* 'Any type' includes the null value, so 'isNullable' should be set to TRUE

* Handle AnyType and NullType

* handle anytype for go-experimental

* Log warning instead of error

* anyOf/oneOf

* Change x-golang-is-container extension to x-golang-has-wrapper

* Add code comments

* Handle Object and any type

* Handle Object and any type

* Handle object and any type

* add code comments

* handle additional properties

* handle additional properties

* handle additional properties

* handle anytype and objecttype for go-exerimental

* Move golang changes to a separate branch

* Move golang changes to a separate branch

* Better names for the OAS document test properties

* Move golang changes to a separate branch

* Run samples scripts

* Run samples scripts

* fix unit test issues

* Handle none type

* Fix index out of range exception

* fix formatting issues

* fix formatting issues

* fix formatting issues. Finally figured out how to check formatting in local workspace

* fix formatting issues

* Add reference to oneOf schema

* Add model showing unit test failure with ref to oneOf schema

* Updates get_discriminator_class to return visited_composed_classes

* Fixes broken test, adds is_valid_type

* run samples scripts

* move unit test to  test_drawing.py file

* Add more unit tests

* invoke git pull from spacether fork

* invoke git pull from spacether fork

* Improve unit tests

* Add is_nullable_type util function

* Add unit test for null value

* Add 'ShapeOrNull' type to handle the oneOf/anyOf scenario when the child schema is the null type

* Support schema property which has  to 'oneOf' schema and child schema is null type

* Support schema property which has  to 'oneOf' schema and child schema is null type

* Support schema property which has  to 'oneOf' schema and child schema is null type

* Mustache template should use invokerPackage tag to generate import

* handle null type in oneOf/anyOf

* handle null type in oneOf/anyOf

* Add more unit test for nullable shape

* resolve merge conflicts

* resolve merge conflicts

* handle null type in oneOf/anyOf

Co-authored-by: Justin Black <justin.a.black@gmail.com>
2020-05-17 09:06:12 -07:00
Sebastien Rosset
1a6cc67fcc
[python-experimental] Support schema property which has $ref to 'oneOf' schema (#6262)
* Add reference to oneOf schema

* Add model showing unit test failure with ref to oneOf schema

* Updates get_discriminator_class to return visited_composed_classes

* Fixes broken test, adds is_valid_type

* move unit test to  test_drawing.py file

* Add more unit tests

* invoke git pull from spacether fork

* invoke git pull from spacether fork

* Improve unit tests

Co-authored-by: Justin Black <justin.a.black@gmail.com>
2020-05-13 09:11:43 -07:00
Sebastien Rosset
dc1bdac820
[Python-experimental] JSON schema 'null' type should be modeled as 'none_type' (#6121)
* Handle null type

* Handle null type

* Handle null type. Add 'null' type in the OAS document for testing purpose

* Handle null type. Add 'null' type in the OAS document for testing purpose

* Handle null type. Add 'null' type in the OAS document for testing purpose

* Handle null type. Add 'null' type in the OAS document for testing purpose

* Handle null type. Add 'null' type in the OAS document for testing purpose

* Handle null type. Add 'null' type in the OAS document for testing purpose

* improve documentation

* Handle 'null' type

* Handle 'null' type. Add unit tests

* Add NullType for go

* Add NullType for go

* fix modeling of AnyType for go-experimental

* execute scripts in bin directory

* Add review comments

* Add 'null' type in oneOf

* Improve OAS YAML file for golang openapi3 samples

* 'Any type' includes the null value, so 'isNullable' should be set to TRUE

* 'Any type' includes the null value, so 'isNullable' should be set to TRUE

* Handle AnyType and NullType

* handle anytype for go-experimental

* Log warning instead of error

* anyOf/oneOf

* Change x-golang-is-container extension to x-golang-has-wrapper

* Add code comments

* Handle Object and any type

* Handle Object and any type

* Handle object and any type

* add code comments

* handle additional properties

* handle additional properties

* handle additional properties

* handle anytype and objecttype for go-exerimental

* Move golang changes to a separate branch

* Move golang changes to a separate branch

* Better names for the OAS document test properties

* Move golang changes to a separate branch

* Run samples scripts

* Run samples scripts

* fix unit test issues

* Handle none type

* Fix index out of range exception

* fix formatting issues

* fix formatting issues

* fix formatting issues. Finally figured out how to check formatting in local workspace

* fix formatting issues

* run samples scripts
2020-05-12 23:09:25 -07:00
Sebastien Rosset
c1d47a580b
[codegen][Python-experimental] Discriminator NPE fix, handle 'null' type, #4906 enhancements (#5809)
* Adds addComposedMappedModels and testComposedSchemaOneOfDiscriminatorMap

* Requires that discriminators be required properties

* Strengthens discriminaotr validation, adds better error messages, adds schema oneof samples

* Adds oneOf and anyOf invalidDiscriminator tests

* Runs ensure up to date

* Updates incorrect addOneOfInterfaceModel invocation

* Runs ensure-up-to-date

* Fix NPE when at least one extension is defined but not x-discriminator-value

* Adds addComposedMappedModels and testComposedSchemaOneOfDiscriminatorMap

* Requires that discriminators be required properties

* Strengthens discriminaotr validation, adds better error messages, adds schema oneof samples

* Adds oneOf and anyOf invalidDiscriminator tests

* Updates incorrect addOneOfInterfaceModel invocation

* Runs ensure-up-to-date

* Adds updates from Sebastien Rosset

* Removes newlines

* Add documentation and new getValidDiscriminatorMappings function

* Add documentation and new getValidDiscriminatorMappings function

* Add documentation and new getValidDiscriminatorMappings function

* Add documentation and new getValidDiscriminatorMappings function

* Add documentation and new getValidDiscriminatorMappings function

* Add documentation and new getValidDiscriminatorMappings function

* throw exception if discriminator mappingName argument is null

* handle scenario when composed schema has 'null' type

* remove extraneous characters in comments

* Uses df.isString

* Traverse discriminators to resolve discriminator mapping

* Fixes tests be correctly setting df.isString

* Remove unused method

* Updates discriminatorExplicitMappingVerbose description per PR feedback

* Adds description of how mappedModels is populated

* Adds the suggestion exception raising when a MappedModel mappingName is null

* Actually resolves merge conflicts

* Adds addComposedMappedModels and testComposedSchemaOneOfDiscriminatorMap

* Requires that discriminators be required properties

* Strengthens discriminaotr validation, adds better error messages, adds schema oneof samples

* Adds oneOf and anyOf invalidDiscriminator tests

* Updates incorrect addOneOfInterfaceModel invocation

* Runs ensure-up-to-date

* Adds updates from Sebastien Rosset

* Removes newlines

* Uses df.isString

* Fixes tests be correctly setting df.isString

* Updates discriminatorExplicitMappingVerbose description per PR feedback

* Adds description of how mappedModels is populated

* Adds the suggestion exception raising when a MappedModel mappingName is null

* Actually resolves merge conflicts

* Switches two methods to package private because they are needed for testing

* Allow nulls in MappedModel.getMappingName

* Remove exception when mappingName is null value

* Remove exception when mappingName is null value

* resolve merge conflicts

* resolve merge conflicts

* Execute scripts in the bin directory

* Fix CI issues and address PR review comments: better documentation and fix white space issues.

* Fix CI issues and address PR review comments: better documentation and fix white space issues.

* run sample scripts

* resolve merge conflicts

* fix end-of-line issue

* resolve merge conflicts

* resolve merge issues

* Handle case when discriminator is not specified in input data

* minor changes and add code comments

* Refactor get_discriminator code

* Add unit test with missing discriminator property

* improve get_discriminator function

* Run sample scripts

* add unit tests for recursive get_discriminator_class

* fix unit test issues

* fix formatting issues

* fix formatting issues

* fix formatting issues

* fix index out of range exception

* fix formatting issues

* fix formatting issues

* fix formatting issues. Finally figured out how to check formatting in local workspace

Co-authored-by: Justin Black <justin.a.black@gmail.com>
Co-authored-by: William Cheng <wing328hk@gmail.com>
2020-05-11 16:57:49 -07:00
Sebastien Rosset
4488db60b3
[python-experimental] Improve error message for regex matching, add unit tests. (#6226)
* Improve error message

* Add unit tests for regular expressions
2020-05-11 18:18:34 +08:00
Sebastien Rosset
fa37a696a8
[python-experimental] Raise builtin AttributeError instead of custom ApiKeyError (#6229)
* Use AttributeError instead of ApiKeyError because that's what the hasattr builtin function uses

* Use AttributeError instead of ApiKeyError because that's what the hasattr builtin function uses

* fix unit tests

* create ApiAttributeError exception

* fix formatting

* run samples scripts
2020-05-10 19:02:41 -07:00
Justin Black
cbc006a938
Adds memoization and deserialization through 2 or more discriminators (#6124)
* Adds cached_property decorator, adds feature to move through n discriminators

* Adds v3 sample with 2 discriminators

* Adds tests of Shape, Tringle, and Quadrilateral traveling through 2 discriminators

* Adds test_deserialization.py:test_deserialize_shape

* Simplifes XTriangle sample spec schemas

* Simplifies Shape schema definition, updates go+python-experimental samples

* Fixes python-experimental test_dog tests

* Separates off python-experimental spec
2020-05-03 11:44:04 -07:00
Justin Niessner
db5941379f
[Python] Fix Python UTF-8 Encoding Issue (#5679)
* Try decoding but don't bail on error

* Switch binary and ByteArray to bytes

* Read content type and parse appropriately

* Remove response parsing

* Remove response parsing and just return the data

* Update petshop examples w/ new generator code

* Fix copy/paste error with naming

* Update petstore examples

* Move response decoding to inside _preload_content block

* Update the clients again

* Use a raw string for the regex pattern

* Regenerate petstore clients

* Add bytes to python primitives as it's supported in 2.7 and 3

* Add bytes to the exports from model_utils

* Import bytes from model_utils

* Add conditional typing for regex pattern to match variable type

* Regenerate petstore clients

* Use read() instead of text() for asyncio

* Regenerate petstore clients

* Remove unused six import

* Regenerate petstore clients

* Add newline to kick Circle to re-run

* Remove whitespace from tox.ini

* Update more examples after ensure_updated

* Add sample updates that didn't run with the --batch flag

* Remove extra bracket in regex to remove warning

* Stop printing debug messages

* Add bytes examples to python doc generators

* Update generated FakeApi docs

* Regenerate api_client.py

* Remove print statements from generated clients

* Update bytes example in FakeApi.md. Again. I swear.

* Add yet another seemingly missing doc update

* Catch the error, decode the body, and re-throw

* Remove the updates now that the change is non-breaking

* Regenerate client

* Add bytes deserialization test

* Update exception parsing

* Add exception parsing for python-experimental

* Regenerate client with minor changes

* Revert test changes

* Regenerate model_utils.py

* Update confusing test name

* Remove bytes from mapping and examples

* Add back in the old binary/ByteArray to str mapping

* Update docs and api_client template

* Add experimental api_client changes

* Regenerate samples again

* Add Tornado handling to early return

* Try fixing Tornado python returns

* More documentation changes

* Re-generate the client code

* Remove bytes from test_format_test

* Remove more leftover bytes usages

* Switch bytes validation back to string

* Fix format_test template and regenerate

* Remove unused bytes var

* Remove bytes import from models and regenerate

* Remove bytes import from test_deserialization

* Reduce nested ifs

* Remove byte logic for now

* Regenerate client after latest changes

* Remove another bytes usage

* Regenerate after removing dangling byte string usage

* Reduce the scope of the try/catch in api_client

* Regenerate after try/catch cleanup

* Swap catch for except

* Regenerate Python client after api_client change

* Fix lint error on the generated api_client

* Add binary format test back in w/ string

* Add decoding to python-experimental and regenerate

* Import re into python-experimental api_client

* Ensure file upload json response is utf-8 encoded bytes
2020-04-26 13:33:42 -07:00
Sebastien Rosset
e8f486ba7f
[Python experimental] Readme improvements (#6031)
* Python experimental readme improvements

* Python experimental readme improvements

* execute scripts in bin directory
2020-04-25 00:10:32 +08:00
Justin Black
8e8471c1fd
[CORE] Fixes composed schema discriminator map (#4906)
* Adds addComposedMappedModels and testComposedSchemaOneOfDiscriminatorMap

* Requires that discriminators be required properties

* Strengthens discriminaotr validation, adds better error messages, adds schema oneof samples

* Adds oneOf and anyOf invalidDiscriminator tests

* Updates incorrect addOneOfInterfaceModel invocation

* Runs ensure-up-to-date

* Adds updates from Sebastien Rosset

* Removes newlines

* Uses df.isString

* Fixes tests be correctly setting df.isString

* Updates discriminatorExplicitMappingVerbose description per PR feedback

* Adds description of how mappedModels is populated

* Adds the suggestion exception raising when a MappedModel mappingName is null

* Actually resolves merge conflicts

* Switches two methods to package private because they are needed for testing

* Allow nulls in MappedModel.getMappingName

* Updates CLI flag name to legacyDiscriminatorBehavior, default=true

Co-authored-by: William Cheng <wing328hk@gmail.com>
2020-04-25 00:01:02 +08:00
Sebastien Rosset
6ad5e5fb45
[Python experimental] Add __setattr__ function to ensure signing_info.host is the same as configuration.host when the user assigns signing info (#6033)
* Add __setattr__ function to ensure signing_info.host is the same as configuration.host when the user assigns signing info

* Add __setattr__ function to ensure signing_info.host is the same as configuration.host when the user assigns signing info
2020-04-23 23:16:31 -07:00
Sebastien Rosset
1e01c380e8
[python-experimental] Minor doc update, code comments and exception handling (#5945)
* add support for any type, i.e. when 'type' attribute is not specified in OAS schema

* fix typos, add code comments

* Handle case when 'type' attribute is not present in the OAS schema

* fix python formatting rule

* fix python formatting rule

* remove 'object' as a type
2020-04-23 22:59:31 -07:00
Justin Black
1766279916
Fixes issue 5876 (#5977)
* Fixes getParentName function

* Updates getChildrenMap to not throw a NPE

* Updates test

* Runs ensure up to date
2020-04-20 16:00:24 +08:00
Sebastien Rosset
91cfabdad2
[Python-experimental] Fix TypeError: unhashable type: 'list' (#5810)
* handle scenario when value is a list, fix TypeError: unhashable type: 'list'

* Add __hash__ function

* use list instead of set

* use list instead of set

* use list instead of set

* use list instead of set

* use list instead of set

* use list instead of set
2020-04-15 17:02:56 -07:00
Sebastien Rosset
242c2e8544
[Python-experimental] Documentation enhancement for oneOf schema and minor err msg improvement (#5791)
* Add documentation to generated code

* Improve error message

* Improve documentation

* Improve documentation

* Improve documentation

* Improve documentation

* Improve documentation

* Improve documentation

* Run sample scripts

* Address review comments

* Address review comments

* Fix problem in python error message
2020-04-03 20:49:23 -07:00
Justin Black
0a3272697d
Adds parseFlattenSpec (#5526)
* Adds parseFlattenSpec, updates tests and helper functions

* Adds parseSPec invocation inside parseFlattenSpec
2020-03-16 21:12:36 -04:00
Sebastien Rosset
20011194c0
Add serialization of ModelComposed (#5551) 2020-03-06 17:25:45 -08:00
Justin Black
9e596697a9
[python] Adds python oneOf/anyOf models + tests (#5341)
* Adds oneOf + anyOf schemas, models and tests to python-experimental

* Adds setUpClass and tearDownClass

* Removes newline in method_init_shared.mustache

* Regenerated v3 spec sample for python-experimental

* Fxes test for discard_unknown_keys

* Moves new models into existing spec, regen python-exp and go-exp

* Also fix python-exp windows file
2020-02-28 14:21:08 -08:00
Tomasz Prus
3f0c163f0c
[python] add method to set/get default configuration (#5315)
* [python] add method to set/get default configuration

* [python] change method name and fix handling api_key

* python: using modified deepcopy to set/get default configuration

* python: update samples

* python: update samples
2020-02-23 14:10:44 -06:00
Sebastien Rosset
e08e05a2c7
[Python] add discard_unknown_keys parameter (#5362)
* add discard_unknown_key parameter

* add discard_unknown_key parameter

* add discard_unknown_key parameter

* discard unknown keys in composed schema if configuration.discard_unknown_keys is set

* discard unknown keys in composed schema if configuration.discard_unknown_keys is set

* discard unknown keys in composed schema if configuration.discard_unknown_keys is set

* discard unknown keys in composed schema if configuration.discard_unknown_keys is set

* discard unknown keys in composed schema if configuration.discard_unknown_keys is set

* discard unknown keys in composed schema if configuration.discard_unknown_keys is set

* discard unknown keys in composed schema if configuration.discard_unknown_keys is set

* discard unknown keys in composed schema if configuration.discard_unknown_keys is set

* discard unknown keys in composed schema if configuration.discard_unknown_keys is set

* discard unknown keys in composed schema if configuration.discard_unknown_keys is set

* discard unknown keys in composed schema if configuration.discard_unknown_keys is set

* discard unknown keys in composed schema if configuration.discard_unknown_keys is set

* discard unknown keys in composed schema if configuration.discard_unknown_keys is set

* discard unknown keys in composed schema if configuration.discard_unknown_keys is set

* discard unknown keys in composed schema if configuration.discard_unknown_keys is set

* discard unknown keys in composed schema if configuration.discard_unknown_keys is set

* discard unknown keys in composed schema if configuration.discard_unknown_keys is set

* discard unknown keys in composed schema if configuration.discard_unknown_keys is set

* discard unknown keys in composed schema if configuration.discard_unknown_keys is set

* discard unknown keys in composed schema if configuration.discard_unknown_keys is set

* discard unknown keys in composed schema if configuration.discard_unknown_keys is set

* discard unknown keys in composed schema if configuration.discard_unknown_keys is set

* discard unknown keys in composed schema if configuration.discard_unknown_keys is set

* discard unknown keys in composed schema if configuration.discard_unknown_keys is set

* run sample scripts for python

* code reformatting

* execute script in bin directory

* improve unit tests for discarding properties
2020-02-21 16:51:24 -06:00
Sebastien Rosset
67e4cc8be1
[Python] Python HTTP signature update (#5154)
* improve python documentation and add import to __init__package.mustache

* improve python documentation and add import to __init__package.mustache

* add signing_info parameter conditionally

* add code comments and remove 'Content-Length' header from example

* Remove debug log statement

* set access_token to None by default

* set access_token to None by default

* fix unit tests for Python experimental

* fix trailing space
2020-02-03 09:39:17 -08:00
Justin Black
a51d02ac61
[Python] Fix #5126 operations with req enums of length one (#5129)
* Updates ap.mustache for python-experimental, adds test test_test_endpoint_enums_length_one

* Removes sortParamsByRequiredFlag from python-experimental

* Removes duplicate params from docstring
2020-01-29 10:10:41 -08:00
Fabian von Feilitzsch
15345e1620
[python] Cleanup ThreadPool with atexit rather than __del__ (#5094)
* [python] Cleanup ThreadPool with atexit rather than __del__

This removes the `__del__` function from the generated Python client,
and replaces it with a `cleanup` function. When a ThreadPool is created,
the cleanup function is registered with the `atexit` module.

This fixes #5093, where the API client could hang indefinitely at
garbage collection.

* Update petstore examples

* Test to ensure threadpool is cleaned up

* Docs now encourage using the context manager

* Regenerate docs

* Update samples
2020-01-28 21:58:11 -08:00
Sebastien Rosset
4f350bc01c [Python] Support for HTTP signature (#4958)
* start implementation of HTTP signature

* add api key parameters for http message signature

* HTTP signature authentication

* start implementation of HTTP signature

* add api key parameters for http message signature

* HTTP signature authentication

* HTTP signature authentication

* start implementation of HTTP signature

* fix merge issues

* Address formatting issues

* Address formatting issues

* move python-experimental-openapiv3-sample to a separate PR

* Add support for HTTP signature

* Add code comments

* Add code comments

* Fix formatting issues

* Fix formatting issues

* Fix formatting issues

* add code comments

* add code comments

* fix python formatting issues

* Make PKCS1v15 string constant consistent between Python and Golang

* fix python formatting issues

* Add code comments in generated Python. Start adding unit tests for HTTP signature

* compliance with HTTP signature draft 12

* compliance with HTTP signature draft 12

* working on review comments

* working on review comments

* working on review comments

* working on review comments

* working on review comments

* working on review comments

* working on review comments

* working on review comments

* working on review comments

* fix python formatting issues

* fix trailing white space

* address PR comments

* address PR comments

* address PR comments

* Add suppport for '(expires)' signature parameter

* address PR comments

* address PR comments

* Fix python formatting issues

* Fix python formatting issues

* Starting to move code to dedicated file for HTTP signatures

* Continue to refactor code to dedicated file for HTTP signatures

* Continue to refactor code to dedicated file for HTTP signatures

* Continue to refactor code to dedicated file for HTTP signatures

* Continue to refactor code to dedicated file for HTTP signatures

* move method to ProcessUtils

* conditionally build signing.py

* move method to ProcessUtils

* Code reformatting

* externalize http signature configuration

* address PR review comments

* address PR review comments

* run samples scripts

* Address PR review comments

* Move 'private_key' field to signing module

* Move 'private_key' field to signing module

* code cleanup

* remove use of strftime('%s'), which is non portable

* code cleanup

* code cleanup

* code cleanup

* run sample scripts

* Address PR review comments.

* Add http-signature security scheme

* Run sample scripts for go

* Fix issue uncovered in integration branch

* Fix issue uncovered in integration branch

* Fix issue uncovered in integration branch

* Fix issue uncovered in integration branch

* Run samples scripts

* move http signature tests to separate file

* move http signature tests to separate file

* unit tests for HTTP signature

* continue implementation of unit tests

* add http_signature_test to security scheme

* add unit tests for http signature

* address review comments

* remove http signature from petapi

* Add separate OAS file with support for HTTP signature

* Add support for private key passphrase. Add more unit tests

* Add unit test to validate the signature against the public key

* remove http signature from petstore-with-fake-endpoints-models-for-testing.yaml

* fix unit test issues

* run scripts in bin directory

* Refact unit test with better variable names

* do not throw exception if security scheme is unrecognized

* change URL of apache license to use https

* sync from master

* fix usage of escape character in python regex. Fix generated python documentation

* write HTTP signed headers in user-specified order. Fix PEP8 formatting issues

* write HTTP signed headers in user-specified order. Fix PEP8 formatting issues

* http signature unit tests

* Fix PEP8 format issue

* spread out each requirement to a separate line

* run samples scripts

* run sample scripts

* remove encoding of '+' character
2020-01-26 18:17:26 -08:00
Sebastien Rosset
63859d6d51 Add python-experimental-openapiv3-sample (#4992)
Add python-experimental-openapiv3-sample

Add missing files for the Python samples

Add python-experimental-petstore.bat for openapi v3

Add python-experimental samples openapi v3

Add python-experimental samples openapi v3

Add python-experimental samples openapi v3. Address review comments

add missing files for test purpose

fix python formatting issues

fix python formatting issues

fix python formatting issues

Fix unit tests

fix python formatting issues

fix python formatting issues

fix python formatting issues

fix 'line too long' pep8 error

address PR comments for pep8 'line too long' problem

regenerate samples

execute samples scripts

dummy commit to retrigger circleci

Revert dummy commit, it didn't help.
2020-01-21 23:19:07 +08:00
Sebastien Rosset
fa0ef2be25 [Python] Conditionally set auth attributes (#4988)
* Enhance python API keys

* Run python scripts under ./bin/openapi3

* fix unit test issue

* Fix unit tests

* Fix unit tests

* Invoke bin scripts
2020-01-16 17:42:23 +08:00
Jim Schubert
78bf3adc4a
[core] Initial FeatureSet structures and definitions (#3614)
[core] Initial FeatureSet structures and definitions
Add default feature set to DefaultCodegen
Initial FeatureSet definitions for:

*  ada 
*  android 
*  apache2 
*  asciidoc 
*  aspnetcore 
*  avro 
*  bash 
*  c 
*  clojure 
*  cpp-pistache-server 
*  cpp-qt5-client 
*  cpp-qt5-qhttpengine-server 
*  cpp-restbed-server 
*  cpp-restsdk 
*  cpp-tizen 
*  csharp 
*  csharp-nancyfx 
*  csharp-netcore 
*  cwiki 
*  dart 
*  eiffel 
*  elixir 
*  elm 
*  erlang 
*  flash 
*  fsharp-functions 
*  go  Client/Server
*  graphql-nodejs-express-server 
*  graphql-schema 
*  groovy 
*  haskell 
*  haskell-http-client 
*  java 
*  jmeter 
*  kotlin 
*  kotlin vertx 
*  kotlin-server 
*  kotlin-spring 
*  lua 
*  mysql 
*  nim 
*  nodejs 
*  nodejs-express 
*  objc 
*  ocaml 
*  openapi 
*  openapi-yaml 
*  perl 
*  php 
*  php-laravel 
*  php-lumen 
*  php-silex 
*  php-slim 
*  php-symfony 
*  php-ze-ph 
*  powershell 
*  protobuf 
*  protobuf-schema 
*  python 
*  python-aiohttp 
*  python-blueplanet 
*  python-experimental 
*  r 
*  ror 
*  ruby 
*  ruby 
*  ruby-sinatra 
*  rust 
*  scala-akka 
*  scala-finch 
*  scala-gatling 
*  scala-http-client 
*  scala-lagom 
*  scala-play 
*  scalatra 
*  scalaz 
*  spring 
*  static docs 
*  swift 
*  typescript
2020-01-11 16:20:47 -05:00
Justin Black
cbc12543a9 [Python] Allow models to have properties of type self (#4888)
* Refactors openapi_types into a staticmethod

* Adds a Player model with a self type rpoperty, adds a test to ensure that it is working right
2020-01-10 17:43:35 +08:00