159 Commits

Author SHA1 Message Date
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
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 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
Justin Black
67e3bf5271
Fixes kwargs typos, removes E501s (#5552) 2020-03-06 20:22:19 -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
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
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
Jim Schubert
376e419d0b Support models with multi-level hierarchy (via roxspring) (#4503)
* Example of broken multi-level hierarchy

* Support for multiple levels of hierarchy in model objects

* Support for multiple levels of hierarchy in generators

* Regenerated samples

* Temporarily skip scalaz sample verification, which is having issue with Java version in CI container

* Re-enable scalaz in verify samples

Co-authored-by: Rob Oxspring <roxspring@imapmail.org>
2019-12-27 15:42:32 +08:00
Jiri Kuncar
45eb87c16a [Python] Remove mutable default argument (#4665) 2019-12-17 10:39:54 +08:00
Justin Black
a1a9e70fe4 Fixes Python client Configuration class so each instance uses its own dicts (#4485) 2019-11-17 08:49:19 +08:00
Arun
649eab2868 [Python] [Performance] Avoid unnessacary checks inside the loop (#4305) 2019-11-07 10:49:54 +08:00
Arun
fe3b59d3c5 [Python] Avoid pep8 violation (#4316) 2019-11-03 14:48:42 +08:00
Arun
eaca7b8d48 [Python] Remove redundant else statement (#4311)
* [Python] Remove redundant else condition

* Add indentation

* Reduce extra indent

* Avoid longer than 79 chars

* Remove trailing space after response_body

* [Python] Fix pep8 violation in imports

* Revert "[Python] Fix pep8 violation in imports"

This reverts commit bc69aaae7fa7739d0d48421e47a1a446f130c225.
2019-10-30 17:02:08 +08:00
Arun
c8465c40ff [Python] [Bug] Correct typo in the word datetime (#4304) 2019-10-29 22:54:05 +08:00
Arun
652b0f5bf6 [python] Add ability to get allowed values (#4138)
* Add function to get list of allowed values

* [python] Add function to get list of allowed values

* Remove temporary variable

* Remove static method and use a variable

* Remove classname
2019-10-24 17:28:29 +08:00
William Cheng
60d601ee26
[Python] Minor fix to code format (#4172)
* test python e501 fix

* 2 spaces

* fix format with noqa: E501

* fix format, update samples
2019-10-17 02:34:04 +08:00
Arun
d71b1cf49e [python] Add option to skip client validations (#4137)
* Adds options to skip client side validations

* Runs petstore.sh

* Correct typo in variable name

* Consistent code styling

* Rerun petstore.sh

* Change position of local_vars_configuration

* Make code pep8 compliant
2019-10-16 15:44:04 +08:00
Arun
095fa719b3 [python] Remove post_params and body from OPTIONS request (#4163)
* Remove post_params and body from OPTIONS

* Empty commit to retrigger build
2019-10-16 15:34:22 +08:00
Arun
1786e75490 Skip adding None value in query parameters (#4161) 2019-10-16 15:15:14 +08:00
William Cheng
7dbda049f0
Better tests for string (number) (#3953)
* beter test for string (number)

* fix mapping

* fix mapping in csharp generators
2019-09-30 15:22:44 +08:00
Benjamin Simpson
239d68df36 [Java][okhttp-gson] fix failure to deserialize floats (#3846)
* fixed bug where nullApi.java would be generated.  Instead, generated DefaultApi.java to match the default path /{pathParam}

* fix to bug #3157

* update samples
2019-09-07 12:36:19 +08:00
Qingping Hou
99fcfbc802 [Python] support api key refresh in configuration module (#3594) 2019-08-15 22:06:36 +08:00
William Cheng
c3535cf9ca
Add test cases to cover different collection formats (#3640)
* add test cases to cover different collection format

* add space params to retrofit 1.x

* add space params to retrofit 2.x

* rename url to localVarUrl

* fix exception in haskell servant
2019-08-15 11:09:12 +08:00
Qingping Hou
850c493c63 [Python] avoid unnecessary dictionary lookup in get_api_key method (#3592) 2019-08-13 13:55:45 +08:00
Sai Giridhar P
e3bc228dd5 [python] Adding constructor parameters to Configuration and improving documentation (#3002)
* feat(python): Updated configuration's constructor and documentation

* feat(python): Updated documentation

* feat(python): Updated pet project

* feat(python): Updated pet project

* feat(python): Fixing host

* feat(python): Updating pet project

* feat(python): Fixing indentation
2019-05-30 00:50:26 +08:00
Shenghan Gao
268196e7f6 [Python] Remove unnecessary if else. (#2985)
* Remove Unnecessary `if else`

* update samples
2019-05-25 00:10:11 +08:00
William Cheng
dc0c24b955
Minor wording change (#2875)
* better wording for version of openapi doc

* update petstore samples
2019-05-13 15:59:59 +08:00
Matthieu Berthomé
ee43cc1520 handle composed schemas in InlineModelResolver (#2112)
* handle composed schemas in InlineModelResolver

* fix unit test -> TestUtils.parseSpec

* update samples

* fix samples

* update samples

* update samples

* add new files
2019-05-08 10:19:15 +08:00
Matthieu Berthomé
f0346aeeb2 python: api_client: add the multipart files after sanitization (#2122)
* python: api_client: add the multipart files after sanitization

* simplify prepare_post_parameters

* fix case of both post params and files set

* update samples

* update samples
2019-05-07 21:27:01 +08:00
Sebastien Arod
567eb6cdd3 [Bug][Python]Support body as bytes when Content-Type is unknown (#2626)
* Support body as bytes when Content-Type is unknownfix #2623

* Revert unwanted import changes

* update samples/openapi3
2019-04-27 01:45:34 +08:00
Gaurav Yadav
ee75366051 Added proxy headers option for urllib3 (#2467)
* adding headers option to pass in rest client

* running ensure uptodate
2019-03-22 11:22:10 +08:00
Justin Black
b1955f3517 Adds exceptions module to python clients (#2393)
* Adds python client exceptions module and updates samples

* Adds python style updates, detects integers in exception paths with six

* Updates to ruby samples which circleci needs

* Removes petstore-security-tests samples

* readme char removal (triggers ci tests)

* Readme fix, triggers CI tests

* Updates python client sample
2019-03-22 10:40:32 +08:00
Gaurav Yadav
45ad72b032 Adding retries option to override default value 3 of urllib3 (#2460)
* adding retries option to override default value 3 of urllib3

* running petstore for python

* adding files for samples in petstore run

* running ensure-up-to-date
2019-03-22 08:24:23 +08:00
Justin Black
b67318ef21 Adds spec additionalProperties + nullable examples (#2405)
* Adds v2 spec additionalproperties examples, adds v3 spec nulllable model example, updates samples

* Remaining samples updates

* Adds csharp generator update to handle models with multilevel parent types, which works for the AdditionalPropertiesObject model, samples updated
2019-03-20 15:31:28 +08:00
Tom Ghyselinck
83bc863b2b Python apikey cookie (#2367)
* The `ApiClient` will now have support to store and use HTTP Cookies (as APIKey auth).

* Use Cookie authentication for user management.

* - Updated Python related samples.
2019-03-14 16:33:35 +08:00
William Cheng
8e7ad9c9b6
Removal of number being default to example in python client (#2228)
* remove number default to example in python client

* update python samples
2019-02-25 16:44:38 +08:00
Vincent Devos
7486438491 pyhton sample cleanup models unused (#2219)
* pyhton sample cleanup models unused

* pyhton sample cleanup models unused tests
2019-02-23 23:40:06 +08:00
William Cheng
f2002b25da
[Python] remove default value from being fallback to example (#2213)
* remove example fallback

* reset test case
2019-02-22 20:44:27 +08:00
William Cheng
36fa7102dd
[Python] Add "servers" support in path, operation (#2052)
* add servers to path, operation

* add path/operation server support to python client

* update python samples

* fix index

* fix python code style
2019-02-08 11:48:37 +08:00
William Cheng
2eb99f602a
Add Bearer authentication support to Python client (#1999)
* add bearer auth support to python

* add bearer auth support to python

* update python oas2 petstore samples

* update samples

* add bearer format

* update php symfony samle
2019-01-30 22:16:53 +08:00
William Cheng
7811390b7b
Add multiple servers support to Python client (#1969)
* add multiple server support to python client

* various fixes

* minor fixes, add tests

* test oas2 python first

* fix tests

* fix issues reported by flake8

* update code format

* add python petstore to ensure up-to-date

* rearrange test

* fix E501

* fix tests

* add new files

* fix script permission

* fix index check

* update samples
2019-01-28 11:24:48 +08:00
Justin Black
9ec594eec5 [Spec] adds XmlItem model and route for xml testing (#1883)
* Adds xmlitem model and route, rest-assured Api suffix fix, updates pytest and pytest-cov versions

* Adds python client sample files

* Adds samples update

* Adds rest-assured sample client update

* Adds sample updates in ensure-up-to-date

* Changes rest-assured files back to master version, removes fix for issue #13

* Updates samples
2019-01-26 17:26:38 +08:00
Justin Black
539ec23298 [python-client] Add model default values (#1776)
* Adds two models to the v2.0 spec, uses examples as defaults in python client

* Adds array default and type_holder_default and type_holder_example tests

* Re-generated python security client with ./bin/security/python-petstore.sh

* Changes comment text, rebased master

* Updates client + server samples

* Adds missing samples updates

* Changes python client to look for true or false with booleans in toDefaultValue

* Changes boolean casting to use Boolean.valueOf

* Adds deserialization fix for python tests

* Changes Mock to namedtuple in python deserialization tests

* Actually remove unittest.mock
2019-01-09 11:18:35 +08:00