[python-exp] simplify examples (#7157)

* Adds example setting code in python-experimental with one fn setting example values

Fixes sample indentations

Handles composed schema models, object model and arraymodels

Adds brackets in arraymodel input

Sets modelName with map schemas

Removes included_schemas arguments, dicriminator examples do not include property examples

Refactors modelName into toExampleValueRecursive argument

Fixes bug where example models contained themselves

Stops using model ExampleGenerator examples because they are inconsistent with the ones in python-experimental

Uses example values if they exist

Removes single quotes from enum examples

Fixes password example

Adds commented our regex handling, commented out because it breaks

Handles AnyType schema examples

Adds x_example values for simple string properties, uses toExampleValue for all example generation

Adds examples for simple string parameters

Updates comments in toExampleValueBase

Fixes the double nested bug for AdditionalPropertiesWithArrayOfEnums

Fixes bug where NumberWithValidations had double nesting

Updates simple string examples in arrays

Fixes array string examples

Fixes example for string endpoint body example

Adds exampleFromStringOrArraySchema

Adds regex examples, pegs slf4j-version to v1.7.29 for rgxgen

Adds comment about regex seed

Updates pattern matcher to not handle ^ and $

Updates used sample values

Adds ensureQuotes

Adds ensureQuotes

Fixes double quote bug

Updates mustache file

Adds ensureQuotes to key handling

Adds modelNameToSchema map, reduces run time by using it

Fixes java tests

Regenerates python-experimental samples

Fixes python test

* Rebased on master

* Adds getModelNameToSchemaCache

* Updates toDefaultValue to not mutate schemas

* Has all dates and datetimes default and example setting use the same helper function

* Samples regenerated

* indentation tweak, removes txt from sample file
This commit is contained in:
spacether
2020-08-19 21:27:31 -07:00
committed by GitHub
parent c19350b179
commit 866df36c94
65 changed files with 1503 additions and 444 deletions

View File

@@ -40,8 +40,21 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = user_api.UserApi(api_client)
user = User() # User | Created user object
user = User(
id=1,
username="username_example",
first_name="first_name_example",
last_name="last_name_example",
email="email_example",
password="password_example",
phone="phone_example",
user_status=1,
object_with_no_declared_props={},
object_with_no_declared_props_nullable={},
any_type_prop=None,
any_type_prop_nullable=None,
) # User | Created user object
# example passing only required values which don't have defaults set
try:
# Create user
@@ -100,8 +113,23 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = user_api.UserApi(api_client)
user = [User()] # [User] | List of user object
user = [
User(
id=1,
username="username_example",
first_name="first_name_example",
last_name="last_name_example",
email="email_example",
password="password_example",
phone="phone_example",
user_status=1,
object_with_no_declared_props={},
object_with_no_declared_props_nullable={},
any_type_prop=None,
any_type_prop_nullable=None,
),
] # [User] | List of user object
# example passing only required values which don't have defaults set
try:
# Creates list of users with given input array
@@ -160,8 +188,23 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = user_api.UserApi(api_client)
user = [User()] # [User] | List of user object
user = [
User(
id=1,
username="username_example",
first_name="first_name_example",
last_name="last_name_example",
email="email_example",
password="password_example",
phone="phone_example",
user_status=1,
object_with_no_declared_props={},
object_with_no_declared_props_nullable={},
any_type_prop=None,
any_type_prop_nullable=None,
),
] # [User] | List of user object
# example passing only required values which don't have defaults set
try:
# Creates list of users with given input array
@@ -221,8 +264,8 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = user_api.UserApi(api_client)
username = 'username_example' # str | The name that needs to be deleted
username = "username_example" # str | The name that needs to be deleted
# example passing only required values which don't have defaults set
try:
# Delete user
@@ -282,8 +325,8 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = user_api.UserApi(api_client)
username = 'username_example' # str | The name that needs to be fetched. Use user1 for testing.
username = "username_example" # str | The name that needs to be fetched. Use user1 for testing.
# example passing only required values which don't have defaults set
try:
# Get user by user name
@@ -344,9 +387,9 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = user_api.UserApi(api_client)
username = 'username_example' # str | The user name for login
password = 'password_example' # str | The password for login in clear text
username = "username_example" # str | The user name for login
password = "password_example" # str | The password for login in clear text
# example passing only required values which don't have defaults set
try:
# Logs user into the system
@@ -407,7 +450,7 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = user_api.UserApi(api_client)
# example, this endpoint has no required or optional parameters
try:
# Logs out current logged in user session
@@ -465,9 +508,22 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = user_api.UserApi(api_client)
username = 'username_example' # str | name that need to be deleted
user = User() # User | Updated user object
username = "username_example" # str | name that need to be deleted
user = User(
id=1,
username="username_example",
first_name="first_name_example",
last_name="last_name_example",
email="email_example",
password="password_example",
phone="phone_example",
user_status=1,
object_with_no_declared_props={},
object_with_no_declared_props_nullable={},
any_type_prop=None,
any_type_prop_nullable=None,
) # User | Updated user object
# example passing only required values which don't have defaults set
try:
# Updated user