[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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
65 changed files with 1503 additions and 444 deletions

View File

@ -72,7 +72,7 @@
</profiles>
<properties>
<slf4j-version>1.7.12</slf4j-version>
<slf4j-version>1.7.29</slf4j-version>
<guava-version>26.0-jre</guava-version>
</properties>
</project>

View File

@ -258,6 +258,7 @@
<diffutils-version>1.3.0</diffutils-version>
<guava-version>26.0-jre</guava-version>
<generex-version>1.0.2</generex-version>
<rxgen-version>1.1</rxgen-version>
<jackson-version>2.10.1</jackson-version>
<jackson-threetenbp-version>2.10.0</jackson-threetenbp-version>
<kotlin-version>1.3.60</kotlin-version>
@ -373,6 +374,11 @@
<artifactId>generex</artifactId>
<version>${generex-version}</version>
</dependency>
<dependency>
<groupId>com.github.curious-odd-man</groupId>
<artifactId>rgxgen</artifactId>
<version>${rxgen-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>

View File

@ -6191,7 +6191,7 @@ public class DefaultCodegen implements CodegenConfig {
return codegenServerVariables;
}
private void setParameterNullable(CodegenParameter parameter, CodegenProperty property) {
protected void setParameterNullable(CodegenParameter parameter, CodegenProperty property) {
if (parameter == null || property == null) {
return;
}

View File

@ -16,8 +16,8 @@
package org.openapitools.codegen.languages;
import io.swagger.v3.core.util.Json;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.examples.Example;
import io.swagger.v3.oas.models.media.*;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.MediaType;
@ -26,9 +26,9 @@ import io.swagger.v3.oas.models.parameters.Parameter;
import io.swagger.v3.oas.models.parameters.RequestBody;
import io.swagger.v3.oas.models.responses.ApiResponse;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenDiscriminator.MappedModel;
import org.openapitools.codegen.examples.ExampleGenerator;
import org.openapitools.codegen.meta.features.*;
import org.openapitools.codegen.utils.ModelUtils;
@ -37,6 +37,7 @@ import org.openapitools.codegen.meta.GeneratorMetadata;
import org.openapitools.codegen.meta.Stability;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.curiousoddman.rgxgen.RgxGen;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
@ -44,12 +45,16 @@ import java.time.format.DateTimeFormatter;
import java.io.File;
import java.util.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
import static org.openapitools.codegen.utils.OnceLogger.once;
public class PythonClientExperimentalCodegen extends PythonClientCodegen {
private static final Logger LOGGER = LoggerFactory.getLogger(PythonClientExperimentalCodegen.class);
// A cache to efficiently lookup a Schema instance based on the return value of `toModelName()`.
private Map<String, Schema> modelNameToSchemaCache;
private DateTimeFormatter iso8601Date = DateTimeFormatter.ISO_DATE;
private DateTimeFormatter iso8601DateTime = DateTimeFormatter.ISO_DATE_TIME;
public PythonClientExperimentalCodegen() {
super();
@ -220,15 +225,38 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
return "python-experimental";
}
public String dateToString(Schema p, OffsetDateTime date, DateTimeFormatter dateFormatter, DateTimeFormatter dateTimeFormatter) {
// converts a date into a date or date-time python string
if (!(ModelUtils.isDateSchema(p) || ModelUtils.isDateTimeSchema(p))) {
throw new RuntimeException("passed schema must be of type Date or DateTime");
public String pythonDate(Object dateValue) {
String strValue = null;
if (dateValue instanceof OffsetDateTime) {
OffsetDateTime date = null;
try {
date = (OffsetDateTime) dateValue;
} catch (ClassCastException e) {
LOGGER.warn("Invalid `date` format for value {}", dateValue.toString());
date = ((Date) dateValue).toInstant().atOffset(ZoneOffset.UTC);
}
strValue = date.format(iso8601Date);
} else {
strValue = dateValue.toString();
}
if (ModelUtils.isDateSchema(p)) {
return "dateutil_parser('" + date.format(dateFormatter) + "').date()";
return "dateutil_parser('" + strValue + "').date()";
}
public String pythonDateTime(Object dateTimeValue) {
String strValue = null;
if (dateTimeValue instanceof OffsetDateTime) {
OffsetDateTime dateTime = null;
try {
dateTime = (OffsetDateTime) dateTimeValue;
} catch (ClassCastException e) {
LOGGER.warn("Invalid `date-time` format for value {}", dateTimeValue.toString());
dateTime = ((Date) dateTimeValue).toInstant().atOffset(ZoneOffset.UTC);
}
strValue = dateTime.format(iso8601DateTime);
} else {
strValue = dateTimeValue.toString();
}
return "dateutil_parser('" + date.format(dateTimeFormatter) + "')";
return "dateutil_parser('" + strValue + "')";
}
/**
@ -251,80 +279,25 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
defaultObject = p.getEnum().get(0);
}
// convert datetime and date enums if they exist
DateTimeFormatter iso8601Date = DateTimeFormatter.ISO_DATE;
DateTimeFormatter iso8601DateTime = DateTimeFormatter.ISO_DATE_TIME;
if (ModelUtils.isDateSchema(p) || ModelUtils.isDateTimeSchema(p)) {
List<Object> currentEnum = p.getEnum();
List<String> fixedEnum = new ArrayList<String>();
String fixedValue = null;
OffsetDateTime date = null;
if (currentEnum != null && !currentEnum.isEmpty()) {
for (Object enumItem : currentEnum) {
date = (OffsetDateTime) enumItem;
fixedValue = dateToString(p, date, iso8601Date, iso8601DateTime);
fixedEnum.add(fixedValue);
}
p.setEnum(fixedEnum);
}
// convert the example if it exists
Object currentExample = p.getExample();
if (currentExample != null) {
try {
date = (OffsetDateTime) currentExample;
} catch (ClassCastException e) {
date = ((Date) currentExample).toInstant().atOffset(ZoneOffset.UTC);
LOGGER.warn("Invalid `date-time` format for value {}", currentExample);
}
fixedValue = dateToString(p, date, iso8601Date, iso8601DateTime);
fixedEnum.add(fixedValue);
p.setExample(fixedValue);
LOGGER.warn(fixedValue);
}
// fix defaultObject
if (defaultObject != null) {
date = (OffsetDateTime) defaultObject;
fixedValue = dateToString(p, date, iso8601Date, iso8601DateTime);
p.setDefault(fixedValue);
defaultObject = fixedValue;
}
}
if (defaultObject == null) {
return null;
}
String defaultValue = null;
if (ModelUtils.isStringSchema(p)) {
defaultValue = defaultObject.toString();
if (ModelUtils.isDateSchema(p) || ModelUtils.isDateTimeSchema(p)) {
return defaultValue;
String defaultValue = defaultObject.toString();
if (ModelUtils.isDateSchema(p)) {
defaultValue = pythonDate(defaultObject);
} else if (ModelUtils.isDateTimeSchema(p)) {
defaultValue = pythonDateTime(defaultObject);
} else if (ModelUtils.isStringSchema(p) && !ModelUtils.isByteArraySchema(p) && !ModelUtils.isBinarySchema(p) && !ModelUtils.isFileSchema(p) && !ModelUtils.isUUIDSchema(p) && !ModelUtils.isEmailSchema(p)) {
defaultValue = ensureQuotes(defaultValue);
} else if (ModelUtils.isBooleanSchema(p)) {
if (Boolean.valueOf(defaultValue) == false) {
defaultValue = "False";
} else {
defaultValue = "True";
}
if (!ModelUtils.isByteArraySchema(p) && !ModelUtils.isBinarySchema(p) && !ModelUtils.isFileSchema(p) && !ModelUtils.isUUIDSchema(p) && !ModelUtils.isEmailSchema(p) && !ModelUtils.isDateTimeSchema(p) && !ModelUtils.isDateSchema(p)) {
if (Pattern.compile("\r\n|\r|\n").matcher((String) defaultValue).find()) {
defaultValue = "'''" + defaultValue + "'''";
} else {
defaultValue = "'" + defaultValue + "'";
}
}
return defaultValue;
} else if (ModelUtils.isIntegerSchema(p) || ModelUtils.isNumberSchema(p) || ModelUtils.isBooleanSchema(p)) {
defaultValue = String.valueOf(defaultObject);
if (ModelUtils.isBooleanSchema(p)) {
if (Boolean.valueOf(defaultValue) == false) {
return "False";
} else {
return "True";
}
}
return defaultValue;
} else {
return defaultObject.toString();
}
return defaultValue;
}
@Override
@ -489,13 +462,6 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
String simpleDataType = result.dataType;
result.dataType = toModelName(modelName);
result.baseType = result.dataType;
// set the example value
if (modelProp.isEnum) {
String value = modelProp._enum.get(0).toString();
result.example = result.dataType + "(" + toEnumValue(value, simpleDataType) + ")";
} else {
result.example = result.dataType + "(" + result.example + ")";
}
}
return result;
}
@ -656,7 +622,7 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
if (datatype.equals("int") || datatype.equals("float")) {
return value;
} else {
return "\"" + escapeText(value) + "\"";
return ensureQuotes(value);
}
}
@ -962,6 +928,18 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
return openAPIType;
}
public String getModelName(Schema sc) {
Boolean thisModelWillBeMade = modelWillBeMade(sc);
Map<String, Schema> schemas = ModelUtils.getSchemas(openAPI);
for (String thisSchemaName : schemas.keySet()) {
Schema thisSchema = schemas.get(thisSchemaName);
if (thisSchema == sc && thisModelWillBeMade) {
return toModelName(thisSchemaName);
}
}
return null;
}
/**
* Output the type declaration of the property
*
@ -978,11 +956,27 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
public Boolean modelWillBeMade(Schema s) {
// only invoke this on $refed schemas
if (ModelUtils.isComposedSchema(s) || ModelUtils.isArraySchema(s) || ModelUtils.isObjectSchema(s)) {
if (ModelUtils.isComposedSchema(s) || ModelUtils.isObjectSchema(s) || ModelUtils.isArraySchema(s) || ModelUtils.isMapSchema(s)) {
return true;
}
CodegenProperty cp = fromProperty("_model", s);
if (cp.isEnum || cp.hasValidation) {
List<Object> enums = s.getEnum();
if (enums != null && !enums.isEmpty()) {
return true;
}
Boolean hasValidation = (
s.getMaxItems() != null ||
s.getMinLength() != null ||
s.getMinItems() != null ||
s.getMultipleOf() != null ||
s.getPattern() != null ||
s.getMaxLength() != null ||
s.getMinimum() != null ||
s.getMaximum() != null ||
s.getExclusiveMaximum() != null ||
s.getExclusiveMinimum() != null ||
s.getUniqueItems() != null
);
if (hasValidation) {
return true;
}
return false;
@ -1106,71 +1100,545 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
// to false, i.e. no additional properties are allowed.
}
@Override
public void setParameterExampleValue(CodegenParameter p) {
// we have a custom version of this function so we can set the file
// type example value
String example;
/**
* Gets an example if it exists
*
* @param sc input schema
* @return the example value
*/
protected Object getObjectExample(Schema sc) {
Schema schema = sc;
String ref = sc.get$ref();
if (ref != null) {
schema = ModelUtils.getSchema(this.openAPI, ModelUtils.getSimpleRef(ref));
}
// TODO handle examples in object models in the future
Boolean objectModel = (ModelUtils.isObjectSchema(schema) || ModelUtils.isMapSchema(schema) || ModelUtils.isComposedSchema(schema));
if (objectModel) {
return null;
}
if (schema.getExample() != null) {
return schema.getExample();
} if (schema.getDefault() != null) {
return schema.getDefault();
} else if (schema.getEnum() != null && !schema.getEnum().isEmpty()) {
return schema.getEnum().get(0);
}
return null;
}
if (p.defaultValue == null) {
example = p.example;
/***
* Ensures that the string has a leading and trailing quote
*
* @param in input string
* @return quoted string
*/
public String ensureQuotes(String in) {
Pattern pattern = Pattern.compile("\r\n|\r|\n");
Matcher matcher = pattern.matcher(in);
if (matcher.find()) {
// if a string has a new line in it add triple quotes to make it a python multiline string
return "'''" + in + "'''";
}
String strPattern = "^['\"].*?['\"]$";
if (in.matches(strPattern)) {
return in;
}
return "\"" + in + "\"";
}
public String toExampleValue(Schema schema, Object objExample) {
String modelName = getModelName(schema);
return toExampleValueRecursive(modelName, schema, objExample, 1, "", 0);
}
private Boolean simpleStringSchema(Schema schema) {
Schema sc = schema;
String ref = schema.get$ref();
if (ref != null) {
sc = ModelUtils.getSchema(this.openAPI, ModelUtils.getSimpleRef(ref));
}
if (ModelUtils.isStringSchema(sc) && !ModelUtils.isDateSchema(sc) && !ModelUtils.isDateTimeSchema(sc) && !"Number".equalsIgnoreCase(sc.getFormat()) && !ModelUtils.isByteArraySchema(sc) && !ModelUtils.isBinarySchema(sc) && schema.getPattern() == null) {
return true;
}
return false;
}
private MappedModel getDiscriminatorMappedModel(CodegenDiscriminator disc) {
for ( MappedModel mm : disc.getMappedModels() ) {
String modelName = mm.getModelName();
Schema modelSchema = getModelNameToSchemaCache().get(modelName);
if (ModelUtils.isObjectSchema(modelSchema)) {
return mm;
}
}
return null;
}
/***
* Recursively generates string examples for schemas
*
* @param modelName the string name of the refed model that will be generated for the schema or null
* @param schema the schema that we need an example for
* @param objExample the example that applies to this schema, for now only string example are used
* @param indentationLevel integer indentation level that we are currently at
* we assume the indentaion amount is 4 spaces times this integer
* @param prefix the string prefix that we will use when assigning an example for this line
* this is used when setting key: value, pairs "key: " is the prefix
* and this is used when setting properties like some_property='some_property_example'
* @param exampleLine this is the current line that we are generatign an example for, starts at 0
* we don't indentin the 0th line because using the example value looks like:
* prop = ModelName( line 0
* some_property='some_property_example' line 1
* ) line 2
* and our example value is:
* ModelName( line 0
* some_property='some_property_example' line 1
* ) line 2
* @return the string example
*/
private String toExampleValueRecursive(String modelName, Schema schema, Object objExample, int indentationLevel, String prefix, Integer exampleLine) {
final String indentionConst = " ";
String currentIndentation = "";
String closingIndentation = "";
for (int i=0 ; i < indentationLevel ; i++) currentIndentation += indentionConst;
if (exampleLine.equals(0)) {
closingIndentation = currentIndentation;
currentIndentation = "";
} else {
p.example = p.defaultValue;
closingIndentation = currentIndentation;
}
String openChars = "";
String closeChars = "";
if (modelName != null) {
openChars = modelName+"(";
closeChars = ")";
}
String fullPrefix = currentIndentation + prefix + openChars;
String example = null;
if (objExample != null) {
example = objExample.toString();
}
if (null != schema.get$ref()) {
// $ref case:
Map<String, Schema> allDefinitions = ModelUtils.getSchemas(this.openAPI);
String ref = ModelUtils.getSimpleRef(schema.get$ref());
if (allDefinitions != null) {
Schema refSchema = allDefinitions.get(ref);
if (null == refSchema) {
return fullPrefix + "None" + closeChars;
} else {
String refModelName = getModelName(refSchema);
return toExampleValueRecursive(refModelName, refSchema, objExample, indentationLevel, prefix, exampleLine);
}
} else {
LOGGER.warn("allDefinitions not defined in toExampleValue!\n");
}
} else if (ModelUtils.isNullType(schema) || isAnyTypeSchema(schema)) {
// The 'null' type is allowed in OAS 3.1 and above. It is not supported by OAS 3.0.x,
// though this tooling supports it.
return fullPrefix + "None" + closeChars;
} else if (ModelUtils.isBooleanSchema(schema)) {
if (objExample == null) {
example = "True";
} else {
if ("false".equalsIgnoreCase(objExample.toString())) {
example = "False";
} else {
example = "True";
}
}
return fullPrefix + example + closeChars;
} else if (ModelUtils.isDateSchema(schema)) {
if (objExample == null) {
example = pythonDate("1970-01-01");
} else {
example = pythonDate(objExample);
}
return fullPrefix + example + closeChars;
} else if (ModelUtils.isDateTimeSchema(schema)) {
if (objExample == null) {
example = pythonDateTime("1970-01-01T00:00:00.00Z");
} else {
example = pythonDateTime(objExample);
}
return fullPrefix + example + closeChars;
} else if (ModelUtils.isBinarySchema(schema)) {
if (objExample == null) {
example = "/path/to/file";
}
example = "open('" + example + "', 'rb')";
return fullPrefix + example + closeChars;
} else if (ModelUtils.isByteArraySchema(schema)) {
if (objExample == null) {
example = "'YQ=='";
}
return fullPrefix + example + closeChars;
} else if (ModelUtils.isStringSchema(schema)) {
if (objExample == null) {
// a BigDecimal:
if ("Number".equalsIgnoreCase(schema.getFormat())) {
example = "2";
return fullPrefix + example + closeChars;
} else if (StringUtils.isNotBlank(schema.getPattern())) {
String pattern = schema.getPattern();
RgxGen rgxGen = new RgxGen(pattern);
// this seed makes it so if we have [a-z] we pick a
Random random = new Random(18);
String sample = rgxGen.generate(random);
// omit leading / and trailing /, omit trailing /i
Pattern valueExtractor = Pattern.compile("^/?(.+?)/?.?$");
Matcher m = valueExtractor.matcher(sample);
if (m.find()) {
example = m.group(m.groupCount());
} else {
example = "";
}
} else if (schema.getMinLength() != null) {
example = "";
int len = schema.getMinLength().intValue();
for (int i=0;i<len;i++) example += "a";
} else if (ModelUtils.isUUIDSchema(schema)) {
example = "046b6c7f-0b8a-43b9-b35d-6489e6daee91";
} else {
example = "string_example";
}
}
return fullPrefix + ensureQuotes(example) + closeChars;
} else if (ModelUtils.isIntegerSchema(schema)) {
if (objExample == null) {
if (schema.getMinimum() != null) {
example = schema.getMinimum().toString();
} else {
example = "1";
}
}
return fullPrefix + example + closeChars;
} else if (ModelUtils.isNumberSchema(schema)) {
if (objExample == null) {
if (schema.getMinimum() != null) {
example = schema.getMinimum().toString();
} else {
example = "3.14";
}
}
return fullPrefix + example + closeChars;
} else if (ModelUtils.isArraySchema(schema)) {
ArraySchema arrayschema = (ArraySchema) schema;
Schema itemSchema = arrayschema.getItems();
String itemModelName = getModelName(itemSchema);
example = fullPrefix + "[" + "\n" + toExampleValueRecursive(itemModelName, itemSchema, objExample, indentationLevel+1, "", exampleLine+1) + ",\n" + closingIndentation + "]" + closeChars;
return example;
} else if (ModelUtils.isMapSchema(schema)) {
if (modelName == null) {
fullPrefix += "{";
closeChars = "}";
}
Object addPropsObj = schema.getAdditionalProperties();
// TODO handle true case for additionalProperties
if (addPropsObj instanceof Schema) {
Schema addPropsSchema = (Schema) addPropsObj;
String key = "key";
Object addPropsExample = getObjectExample(addPropsSchema);
if (addPropsSchema.getEnum() != null && !addPropsSchema.getEnum().isEmpty()) {
key = addPropsSchema.getEnum().get(0).toString();
}
addPropsExample = exampleFromStringOrArraySchema(addPropsSchema, addPropsExample, key);
String addPropPrefix = ensureQuotes(key) + ": ";
String addPropsModelName = getModelName(addPropsSchema);
example = fullPrefix + "\n" + toExampleValueRecursive(addPropsModelName, addPropsSchema, addPropsExample, indentationLevel + 1, addPropPrefix, exampleLine + 1) + ",\n" + closingIndentation + closeChars;
} else {
example = fullPrefix + closeChars;
}
return example;
} else if (ModelUtils.isObjectSchema(schema)) {
if (modelName == null) {
fullPrefix += "{";
closeChars = "}";
}
CodegenDiscriminator disc = createDiscriminator(modelName, schema, openAPI);
if (disc != null) {
MappedModel mm = getDiscriminatorMappedModel(disc);
if (mm != null) {
String discPropNameValue = mm.getMappingName();
String chosenModelName = mm.getModelName();
// TODO handle this case in the future, this is when the discriminated
// schema allOf includes this schema, like Cat allOf includes Pet
// so this is the composed schema use case
} else {
return fullPrefix + closeChars;
}
}
return exampleForObjectModel(schema, fullPrefix, closeChars, null, indentationLevel, exampleLine, closingIndentation);
} else if (ModelUtils.isComposedSchema(schema)) {
// TODO add examples for composed schema models without discriminators
CodegenDiscriminator disc = createDiscriminator(modelName, schema, openAPI);
if (disc != null) {
MappedModel mm = getDiscriminatorMappedModel(disc);
if (mm != null) {
String discPropNameValue = mm.getMappingName();
String chosenModelName = mm.getModelName();
Schema modelSchema = getModelNameToSchemaCache().get(chosenModelName);
CodegenProperty cp = new CodegenProperty();
cp.setName(disc.getPropertyName());
cp.setExample(discPropNameValue);
return exampleForObjectModel(modelSchema, fullPrefix, closeChars, cp, indentationLevel, exampleLine, closingIndentation);
} else {
return fullPrefix + closeChars;
}
}
return fullPrefix + closeChars;
} else {
LOGGER.warn("Type " + schema.getType() + " not handled properly in toExampleValue");
}
return example;
}
private String exampleForObjectModel(Schema schema, String fullPrefix, String closeChars, CodegenProperty discProp, int indentationLevel, int exampleLine, String closingIndentation) {
Map<String, Schema> requiredAndOptionalProps = schema.getProperties();
if (requiredAndOptionalProps == null || requiredAndOptionalProps.isEmpty()) {
return fullPrefix + closeChars;
}
String example = fullPrefix + "\n";
for (Map.Entry<String, Schema> entry : requiredAndOptionalProps.entrySet()) {
String propName = entry.getKey();
Schema propSchema = entry.getValue();
propName = toVarName(propName);
String propModelName = null;
Object propExample = null;
if (discProp != null && propName.equals(discProp.name)) {
propModelName = null;
propExample = discProp.example;
} else {
propModelName = getModelName(propSchema);
propExample = exampleFromStringOrArraySchema(propSchema, null, propName);
}
example += toExampleValueRecursive(propModelName, propSchema, propExample, indentationLevel + 1, propName + "=", exampleLine + 1) + ",\n";
}
// TODO handle additionalProperties also
example += closingIndentation + closeChars;
return example;
}
private Object exampleFromStringOrArraySchema(Schema sc, Object currentExample, String propName) {
if (currentExample != null) {
return currentExample;
}
Schema schema = sc;
String ref = sc.get$ref();
if (ref != null) {
schema = ModelUtils.getSchema(this.openAPI, ModelUtils.getSimpleRef(ref));
}
Object example = getObjectExample(schema);
if (example != null) {
return example;
} else if (simpleStringSchema(schema)) {
return propName + "_example";
} else if (ModelUtils.isArraySchema(schema)) {
ArraySchema arraySchema = (ArraySchema) schema;
Schema itemSchema = arraySchema.getItems();
example = getObjectExample(itemSchema);
if (example != null ) {
return example;
} else if (simpleStringSchema(itemSchema)) {
return propName + "_example";
}
}
return null;
}
/***
*
* Set the codegenParameter example value
* We have a custom version of this function so we can invoke toExampleValue
*
* @param codegenParameter the item we are setting the example on
* @param parameter the base parameter that came from the spec
*/
@Override
public void setParameterExampleValue(CodegenParameter codegenParameter, Parameter parameter) {
Schema schema = parameter.getSchema();
if (schema == null) {
LOGGER.warn("CodegenParameter.example defaulting to null because parameter lacks a schema");
return;
}
String type = p.baseType;
if (type == null) {
type = p.dataType;
}
if ("String".equalsIgnoreCase(type) || "str".equalsIgnoreCase(type)) {
if (example == null) {
example = p.paramName + "_example";
}
example = "'" + escapeText(example) + "'";
} else if ("Integer".equals(type) || "int".equals(type)) {
if (example == null) {
example = "56";
}
} else if ("Float".equalsIgnoreCase(type) || "Double".equalsIgnoreCase(type)) {
if (example == null) {
example = "3.4";
}
} else if ("BOOLEAN".equalsIgnoreCase(type) || "bool".equalsIgnoreCase(type)) {
if (example == null) {
example = "True";
}
} else if ("file".equalsIgnoreCase(type)) {
if (example == null) {
example = "/path/to/file";
}
example = "open('"+example+"', 'rb')";
} else if ("Date".equalsIgnoreCase(type)) {
if (example == null) {
example = "2013-10-20";
}
example = "'" + escapeText(example) + "'";
} else if ("DateTime".equalsIgnoreCase(type)) {
if (example == null) {
example = "2013-10-20T19:20:30+01:00";
}
example = "'" + escapeText(example) + "'";
} else if (!languageSpecificPrimitives.contains(type)) {
// type is a model class, e.g. user.User
example = type + "()";
Object example = null;
if (codegenParameter.vendorExtensions != null && codegenParameter.vendorExtensions.containsKey("x-example")) {
example = codegenParameter.vendorExtensions.get("x-example");
} else if (parameter.getExample() != null) {
example = parameter.getExample();
} else if (parameter.getExamples() != null && !parameter.getExamples().isEmpty() && parameter.getExamples().values().iterator().next().getValue() != null) {
example = parameter.getExamples().values().iterator().next().getValue();
} else {
LOGGER.warn("Type " + type + " not handled properly in setParameterExampleValue");
example = getObjectExample(schema);
}
example = exampleFromStringOrArraySchema(schema, example, parameter.getName());
String finalExample = toExampleValue(schema, example);
codegenParameter.example = finalExample;
}
/**
* Return the example value of the parameter.
*
* @param codegenParameter Codegen parameter
* @param requestBody Request body
*/
@Override
public void setParameterExampleValue(CodegenParameter codegenParameter, RequestBody requestBody) {
if (codegenParameter.vendorExtensions != null && codegenParameter.vendorExtensions.containsKey("x-example")) {
codegenParameter.example = Json.pretty(codegenParameter.vendorExtensions.get("x-example"));
}
if (example == null) {
example = "None";
} else if (Boolean.TRUE.equals(p.isListContainer)) {
example = "[" + example + "]";
} else if (Boolean.TRUE.equals(p.isMapContainer)) {
example = "{'key': " + example + "}";
Content content = requestBody.getContent();
if (content.size() > 1) {
// @see ModelUtils.getSchemaFromContent()
once(LOGGER).warn("Multiple MediaTypes found, using only the first one");
}
p.example = example;
MediaType mediaType = content.values().iterator().next();
Schema schema = mediaType.getSchema();
if (schema == null) {
LOGGER.warn("CodegenParameter.example defaulting to null because requestBody content lacks a schema");
return;
}
Object example = null;
if (mediaType.getExample() != null) {
example = mediaType.getExample();
} else if (mediaType.getExamples() != null && !mediaType.getExamples().isEmpty() && mediaType.getExamples().values().iterator().next().getValue() != null) {
example = mediaType.getExamples().values().iterator().next().getValue();
} else {
example = getObjectExample(schema);
}
example = exampleFromStringOrArraySchema(schema, example, codegenParameter.paramName);
codegenParameter.example = toExampleValue(schema, example);
}
/**
* Create a CodegenParameter for a Form Property
* We have a custom version of this method so we can invoke
* setParameterExampleValue(codegenParameter, parameter)
* rather than setParameterExampleValue(codegenParameter)
* This ensures that all of our samples are generated in
* toExampleValueRecursive
*
* @param name the property name
* @param propertySchema the property schema
* @param imports our import set
* @return the resultant CodegenParameter
*/
@Override
public CodegenParameter fromFormProperty(String name, Schema propertySchema, Set<String> imports) {
CodegenParameter codegenParameter = CodegenModelFactory.newInstance(CodegenModelType.PARAMETER);
LOGGER.debug("Debugging fromFormProperty {}: {}", name, propertySchema);
CodegenProperty codegenProperty = fromProperty(name, propertySchema);
ModelUtils.syncValidationProperties(propertySchema, codegenProperty);
codegenParameter.isFormParam = Boolean.TRUE;
codegenParameter.baseName = codegenProperty.baseName;
codegenParameter.paramName = toParamName((codegenParameter.baseName));
codegenParameter.baseType = codegenProperty.baseType;
codegenParameter.dataType = codegenProperty.dataType;
codegenParameter.dataFormat = codegenProperty.dataFormat;
codegenParameter.description = escapeText(codegenProperty.description);
codegenParameter.unescapedDescription = codegenProperty.getDescription();
codegenParameter.jsonSchema = Json.pretty(propertySchema);
codegenParameter.defaultValue = codegenProperty.getDefaultValue();
if (codegenProperty.getVendorExtensions() != null && !codegenProperty.getVendorExtensions().isEmpty()) {
codegenParameter.vendorExtensions = codegenProperty.getVendorExtensions();
}
if (propertySchema.getRequired() != null && !propertySchema.getRequired().isEmpty() && propertySchema.getRequired().contains(codegenProperty.baseName)) {
codegenParameter.required = Boolean.TRUE;
}
// non-array/map
updateCodegenPropertyEnum(codegenProperty);
codegenParameter.isEnum = codegenProperty.isEnum;
codegenParameter._enum = codegenProperty._enum;
codegenParameter.allowableValues = codegenProperty.allowableValues;
if (codegenProperty.isEnum) {
codegenParameter.datatypeWithEnum = codegenProperty.datatypeWithEnum;
codegenParameter.enumName = codegenProperty.enumName;
}
if (codegenProperty.items != null && codegenProperty.items.isEnum) {
codegenParameter.items = codegenProperty.items;
codegenParameter.mostInnerItems = codegenProperty.mostInnerItems;
}
// import
if (codegenProperty.complexType != null) {
imports.add(codegenProperty.complexType);
}
// validation
// handle maximum, minimum properly for int/long by removing the trailing ".0"
if (ModelUtils.isIntegerSchema(propertySchema)) {
codegenParameter.maximum = propertySchema.getMaximum() == null ? null : String.valueOf(propertySchema.getMaximum().longValue());
codegenParameter.minimum = propertySchema.getMinimum() == null ? null : String.valueOf(propertySchema.getMinimum().longValue());
} else {
codegenParameter.maximum = propertySchema.getMaximum() == null ? null : String.valueOf(propertySchema.getMaximum());
codegenParameter.minimum = propertySchema.getMinimum() == null ? null : String.valueOf(propertySchema.getMinimum());
}
codegenParameter.exclusiveMaximum = propertySchema.getExclusiveMaximum() == null ? false : propertySchema.getExclusiveMaximum();
codegenParameter.exclusiveMinimum = propertySchema.getExclusiveMinimum() == null ? false : propertySchema.getExclusiveMinimum();
codegenParameter.maxLength = propertySchema.getMaxLength();
codegenParameter.minLength = propertySchema.getMinLength();
codegenParameter.pattern = toRegularExpression(propertySchema.getPattern());
codegenParameter.maxItems = propertySchema.getMaxItems();
codegenParameter.minItems = propertySchema.getMinItems();
codegenParameter.uniqueItems = propertySchema.getUniqueItems() == null ? false : propertySchema.getUniqueItems();
codegenParameter.multipleOf = propertySchema.getMultipleOf();
// exclusive* are noop without corresponding min/max
if (codegenParameter.maximum != null || codegenParameter.minimum != null ||
codegenParameter.maxLength != null || codegenParameter.minLength != null ||
codegenParameter.maxItems != null || codegenParameter.minItems != null ||
codegenParameter.pattern != null || codegenParameter.multipleOf != null) {
codegenParameter.hasValidation = true;
}
setParameterBooleanFlagWithCodegenProperty(codegenParameter, codegenProperty);
Parameter p = new Parameter();
p.setSchema(propertySchema);
p.setName(codegenParameter.paramName);
setParameterExampleValue(codegenParameter, p);
// setParameterExampleValue(codegenParameter);
// set nullable
setParameterNullable(codegenParameter, codegenProperty);
//TODO collectionFormat for form parameter not yet supported
//codegenParameter.collectionFormat = getCollectionFormat(propertySchema);
return codegenParameter;
}
/**
* Return a map from model name to Schema for efficient lookup.
*
* @return map from model name to Schema.
*/
protected Map<String, Schema> getModelNameToSchemaCache() {
if (modelNameToSchemaCache == null) {
// Create a cache to efficiently lookup schema based on model name.
Map<String, Schema> m = new HashMap<String, Schema>();
ModelUtils.getSchemas(openAPI).forEach((key, schema) -> {
m.put(toModelName(key), schema);
});
modelNameToSchemaCache = Collections.unmodifiableMap(m);
}
return modelNameToSchemaCache;
}
}

View File

@ -16,44 +16,61 @@ with {{{packageName}}}.ApiClient() as api_client:
{{/hasAuthMethods}}
# Create an instance of the API class
api_instance = {{classVarName}}.{{{classname}}}(api_client)
{{#requiredParams}}{{^defaultValue}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}
{{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}}
{{/optionalParams}}
{{#requiredParams}}
{{^hasMore}}
{{#requiredParams}}
{{^defaultValue}}
{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}
{{/defaultValue}}
{{/requiredParams}}
{{#optionalParams}}
{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}}
{{/optionalParams}}
{{#requiredParams}}
{{^hasMore}}
# example passing only required values which don't have defaults set
try:
{{#summary}} # {{{.}}}
{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/defaultValue}}{{/requiredParams}}){{#returnType}}
pprint(api_response){{/returnType}}
{{#summary}}
# {{{.}}}
{{/summary}}
{{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/defaultValue}}{{/requiredParams}})
{{#returnType}}
pprint(api_response)
{{/returnType}}
except {{{packageName}}}.ApiException as e:
print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e)
{{/hasMore}}
{{/requiredParams}}
{{#optionalParams}}
{{^hasMore}}
{{/hasMore}}
{{/requiredParams}}
{{#optionalParams}}
{{^hasMore}}
# example passing only required values which don't have defaults set
# and optional values
try:
{{#summary}} # {{{.}}}
{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}}={{paramName}}{{#hasMore}}, {{/hasMore}}{{/optionalParams}}){{#returnType}}
pprint(api_response){{/returnType}}
{{#summary}}
# {{{.}}}
{{/summary}}
{{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}}={{paramName}}{{#hasMore}}, {{/hasMore}}{{/optionalParams}})
{{#returnType}}
pprint(api_response)
{{/returnType}}
except {{{packageName}}}.ApiException as e:
print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e)
{{/hasMore}}
{{/optionalParams}}
{{^requiredParams}}
{{^optionalParams}}
{{/hasMore}}
{{/optionalParams}}
{{^requiredParams}}
{{^optionalParams}}
# example, this endpoint has no required or optional parameters
try:
{{#summary}} # {{{.}}}
{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}(){{#returnType}}
pprint(api_response){{/returnType}}
{{#summary}}
# {{{.}}}
{{/summary}}
{{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}()
{{#returnType}}
pprint(api_response)
{{/returnType}}
except {{{packageName}}}.ApiException as e:
print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e)
{{/optionalParams}}
{{/requiredParams}}
{{/optionalParams}}
{{/requiredParams}}
```

View File

@ -51,7 +51,7 @@ public class PythonClientExperimentalTest {
final String path = "/api/v1beta3/namespaces/{namespaces}/bindings";
final Operation operation = openAPI.getPaths().get(path).getPost();
final CodegenOperation codegenOperation = codegen.fromOperation(path, "get", operation, null);
final CodegenOperation codegenOperation = codegen.fromOperation(path, "post", operation, null);
Assert.assertEquals(codegenOperation.returnType, "V1beta3Binding");
Assert.assertEquals(codegenOperation.returnBaseType, "V1beta3Binding");
}

View File

@ -234,6 +234,11 @@
}
}
},
"any": {
"description": "map model with key property names to any type",
"properties": {},
"additionalProperties": {}
},
"v1beta3.ObjectReference": {
"id": "v1beta3.ObjectReference",
"properties": {
@ -271,7 +276,7 @@
"id": "v1beta3.ObjectMeta",
"properties": {
"annotations": {
"type": "any",
"$ref": "any",
"description": "map of string keys and values that can be used by external tooling to store and retrieve arbitrary metadata about objects"
},
"creationTimestamp": {
@ -287,7 +292,7 @@
"description": "an optional prefix to use to generate a unique name; has the same validation rules as name; optional, and is applied only name if is not specified"
},
"labels": {
"type": "any",
"$ref": "any",
"description": "map of string keys and values that can be used to organize and categorize objects; may match selectors of replication controllers and services"
},
"name": {

View File

@ -842,6 +842,26 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/NumberWithValidations'
/fake/refs/mammal:
post:
tags:
- fake
description: Test serialization of mammals
operationId: Mammal
requestBody:
description: Input mammal
content:
application/json:
schema:
$ref: '#/components/schemas/mammal'
required: true
responses:
'200':
description: Output mammal
content:
application/json:
schema:
$ref: '#/components/schemas/mammal'
/fake/refs/string:
post:
tags:
@ -1588,6 +1608,9 @@ components:
type: string
format: uuid
example: 72f98069-206d-4f12-9f12-3d1e525a8e84
uuidNoExample:
type: string
format: uuid
password:
type: string
format: password
@ -1820,6 +1843,11 @@ components:
- "placed"
- "approved"
- "delivered"
- 'single quoted'
- |-
multiple
lines
- "double quote \n with newline"
IntegerEnum:
type: integer
enum:

View File

@ -1515,7 +1515,7 @@
<jackson-version>2.10.2</jackson-version>
<maven-plugin-version>1.0.0</maven-plugin-version>
<commons-lang-version>3.4</commons-lang-version>
<slf4j-version>1.7.12</slf4j-version>
<slf4j-version>1.7.29</slf4j-version>
<scala-maven-plugin-version>4.3.1</scala-maven-plugin-version>
<jmustache-version>1.14</jmustache-version>
<handlebars.java-version>4.1.2</handlebars.java-version>

View File

@ -63,7 +63,9 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = another_fake_api.AnotherFakeApi(api_client)
body = Client() # Client | client model
body = Client(
client="client_example",
) # Client | client model
try:
# To test special tags

View File

@ -4,7 +4,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**class_name** | **str** | |
**color** | **str** | | [optional] if omitted the server will use the default value of 'red'
**color** | **str** | | [optional] if omitted the server will use the default value of "red"
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -33,8 +33,10 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = another_fake_api.AnotherFakeApi(api_client)
body = Client() # Client | client model
body = Client(
client="client_example",
) # Client | client model
# example passing only required values which don't have defaults set
try:
# To test special tags

View File

@ -5,7 +5,7 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**class_name** | **str** | |
**declawed** | **bool** | | [optional]
**color** | **str** | | [optional] if omitted the server will use the default value of 'red'
**color** | **str** | | [optional] if omitted the server will use the default value of "red"
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -3,7 +3,7 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **str** | | defaults to 'default-name'
**name** | **str** | | defaults to "default-name"
**id** | **int** | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -5,7 +5,7 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**class_name** | **str** | |
**breed** | **str** | | [optional]
**color** | **str** | | [optional] if omitted the server will use the default value of 'red'
**color** | **str** | | [optional] if omitted the server will use the default value of "red"
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -3,7 +3,7 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**value** | **str** | | if omitted the server will use the default value of '-efg', must be one of ["_abc", "-efg", "(xyz)", ]
**value** | **str** | | if omitted the server will use the default value of "-efg", must be one of ["_abc", "-efg", "(xyz)", ]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -48,7 +48,9 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
body = AnimalFarm() # AnimalFarm | Input model (optional)
body = AnimalFarm([
Animal(),
]) # AnimalFarm | Input model (optional)
# example passing only required values which don't have defaults set
# and optional values
@ -173,8 +175,56 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
xml_item = XmlItem() # XmlItem | XmlItem Body
xml_item = XmlItem(
attribute_string="string",
attribute_number=1.234,
attribute_integer=-2,
attribute_boolean=True,
wrapped_array=[
1,
],
name_string="string",
name_number=1.234,
name_integer=-2,
name_boolean=True,
name_array=[
1,
],
name_wrapped_array=[
1,
],
prefix_string="string",
prefix_number=1.234,
prefix_integer=-2,
prefix_boolean=True,
prefix_array=[
1,
],
prefix_wrapped_array=[
1,
],
namespace_string="string",
namespace_number=1.234,
namespace_integer=-2,
namespace_boolean=True,
namespace_array=[
1,
],
namespace_wrapped_array=[
1,
],
prefix_ns_string="string",
prefix_ns_number=1.234,
prefix_ns_integer=-2,
prefix_ns_boolean=True,
prefix_ns_array=[
1,
],
prefix_ns_wrapped_array=[
1,
],
) # XmlItem | XmlItem Body
# example passing only required values which don't have defaults set
try:
# creates an XmlItem
@ -235,7 +285,7 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
body = NumberWithValidations(3.4) # NumberWithValidations | Input number as post body (optional)
body = NumberWithValidations(1E+1) # NumberWithValidations | Input number as post body (optional)
# example passing only required values which don't have defaults set
# and optional values
@ -298,7 +348,11 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
body = ObjectModelWithRefProps() # ObjectModelWithRefProps | Input model (optional)
body = ObjectModelWithRefProps(
my_number=NumberWithValidations(1E+1),
my_string="my_string_example",
my_boolean=True,
) # ObjectModelWithRefProps | Input model (optional)
# example passing only required values which don't have defaults set
# and optional values
@ -360,7 +414,7 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
body = 'body_example' # str | Input string as post body (optional)
body = "body_example" # str | Input string as post body (optional)
# example passing only required values which don't have defaults set
# and optional values
@ -486,8 +540,17 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
body = FileSchemaTestClass() # FileSchemaTestClass |
body = FileSchemaTestClass(
file=File(
source_uri="source_uri_example",
),
files=[
File(
source_uri="source_uri_example",
),
],
) # FileSchemaTestClass |
# example passing only required values which don't have defaults set
try:
api_instance.test_body_with_file_schema(body)
@ -545,9 +608,18 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
query = 'query_example' # str |
body = User() # User |
query = "query_example" # str |
body = 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,
) # User |
# example passing only required values which don't have defaults set
try:
api_instance.test_body_with_query_params(query, body)
@ -608,8 +680,10 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
body = Client() # Client | client model
body = Client(
client="client_example",
) # Client | client model
# example passing only required values which don't have defaults set
try:
# To test \"client\" model
@ -670,7 +744,7 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
# example passing only required values which don't have defaults set
try:
api_instance.test_endpoint_enums_length_one()
@ -683,8 +757,8 @@ with petstore_api.ApiClient() as api_client:
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**query_integer** | **int**| | defaults to 3
**query_string** | **str**| | defaults to 'brillig'
**path_string** | **str**| | defaults to 'hello'
**query_string** | **str**| | defaults to "brillig"
**path_string** | **str**| | defaults to "hello"
**path_integer** | **int**| | defaults to 34
**header_number** | **float**| | defaults to 1.234
@ -744,20 +818,20 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
number = 3.4 # float | None
double = 3.4 # float | None
pattern_without_delimiter = 'pattern_without_delimiter_example' # str | None
byte = 'byte_example' # str | None
integer = 56 # int | None (optional)
int32 = 56 # int | None (optional)
int64 = 56 # int | None (optional)
float = 3.4 # float | None (optional)
string = 'string_example' # str | None (optional)
binary = open('/path/to/file', 'rb') # file_type | None (optional)
date = '2013-10-20' # date | None (optional)
date_time = '2013-10-20T19:20:30+01:00' # datetime | None (optional)
password = 'password_example' # str | None (optional)
param_callback = 'param_callback_example' # str | None (optional)
number = 32.1 # float | None
double = 67.8 # float | None
pattern_without_delimiter = "AUR,rZ#UM/?R,Fp^l6$ARjbhJk C" # str | None
byte = 'YQ==' # str | None
integer = 10 # int | None (optional)
int32 = 20 # int | None (optional)
int64 = 1 # int | None (optional)
float = 3.14 # float | None (optional)
string = "a" # str | None (optional)
binary = open('/path/to/file', 'rb') # file_type | None (optional)
date = dateutil_parser('1970-01-01').date() # date | None (optional)
date_time = dateutil_parser('1970-01-01T00:00:00.00Z') # datetime | None (optional)
password = "password_example" # str | None (optional)
param_callback = "param_callback_example" # str | None (optional)
# example passing only required values which don't have defaults set
try:
@ -840,14 +914,18 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
enum_header_string_array = ['enum_header_string_array_example'] # [str] | Header parameter enum test (string array) (optional)
enum_header_string = '-efg' # str | Header parameter enum test (string) (optional) if omitted the server will use the default value of '-efg'
enum_query_string_array = ['enum_query_string_array_example'] # [str] | Query parameter enum test (string array) (optional)
enum_query_string = '-efg' # str | Query parameter enum test (string) (optional) if omitted the server will use the default value of '-efg'
enum_query_integer = 56 # int | Query parameter enum test (double) (optional)
enum_query_double = 3.4 # float | Query parameter enum test (double) (optional)
enum_form_string_array = '$' # [str] | Form parameter enum test (string array) (optional) if omitted the server will use the default value of '$'
enum_form_string = '-efg' # str | Form parameter enum test (string) (optional) if omitted the server will use the default value of '-efg'
enum_header_string_array = [
"$",
] # [str] | Header parameter enum test (string array) (optional)
enum_header_string = "-efg" # str | Header parameter enum test (string) (optional) if omitted the server will use the default value of "-efg"
enum_query_string_array = [
"$",
] # [str] | Query parameter enum test (string array) (optional)
enum_query_string = "-efg" # str | Query parameter enum test (string) (optional) if omitted the server will use the default value of "-efg"
enum_query_integer = 1 # int | Query parameter enum test (double) (optional)
enum_query_double = 1.1 # float | Query parameter enum test (double) (optional)
enum_form_string_array = "$" # [str] | Form parameter enum test (string array) (optional) if omitted the server will use the default value of "$"
enum_form_string = "-efg" # str | Form parameter enum test (string) (optional) if omitted the server will use the default value of "-efg"
# example passing only required values which don't have defaults set
# and optional values
@ -863,13 +941,13 @@ enum_form_string = '-efg' # str | Form parameter enum test (string) (optional) i
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**enum_header_string_array** | **[str]**| Header parameter enum test (string array) | [optional]
**enum_header_string** | **str**| Header parameter enum test (string) | [optional] if omitted the server will use the default value of '-efg'
**enum_header_string** | **str**| Header parameter enum test (string) | [optional] if omitted the server will use the default value of "-efg"
**enum_query_string_array** | **[str]**| Query parameter enum test (string array) | [optional]
**enum_query_string** | **str**| Query parameter enum test (string) | [optional] if omitted the server will use the default value of '-efg'
**enum_query_string** | **str**| Query parameter enum test (string) | [optional] if omitted the server will use the default value of "-efg"
**enum_query_integer** | **int**| Query parameter enum test (double) | [optional]
**enum_query_double** | **float**| Query parameter enum test (double) | [optional]
**enum_form_string_array** | **[str]**| Form parameter enum test (string array) | [optional] if omitted the server will use the default value of '$'
**enum_form_string** | **str**| Form parameter enum test (string) | [optional] if omitted the server will use the default value of '-efg'
**enum_form_string_array** | **[str]**| Form parameter enum test (string array) | [optional] if omitted the server will use the default value of "$"
**enum_form_string** | **str**| Form parameter enum test (string) | [optional] if omitted the server will use the default value of "-efg"
### Return type
@ -917,12 +995,12 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
required_string_group = 56 # int | Required String in group parameters
required_string_group = 1 # int | Required String in group parameters
required_boolean_group = True # bool | Required Boolean in group parameters
required_int64_group = 56 # int | Required Integer in group parameters
string_group = 56 # int | String in group parameters (optional)
boolean_group = True # bool | Boolean in group parameters (optional)
int64_group = 56 # int | Integer in group parameters (optional)
required_int64_group = 1 # int | Required Integer in group parameters
string_group = 1 # int | String in group parameters (optional)
boolean_group = True # bool | Boolean in group parameters (optional)
int64_group = 1 # int | Integer in group parameters (optional)
# example passing only required values which don't have defaults set
try:
@ -994,8 +1072,10 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
param = {'key': 'param_example'} # {str: (str,)} | request body
param = {
"key": "key_example",
} # {str: (str,)} | request body
# example passing only required values which don't have defaults set
try:
# test inline additionalProperties
@ -1053,9 +1133,9 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
param = 'param_example' # str | field1
param2 = 'param2_example' # str | field2
param = "param_example" # str | field1
param2 = "param2_example" # str | field2
# example passing only required values which don't have defaults set
try:
# test json serialization of form data

View File

@ -48,8 +48,10 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = fake_classname_tags_123_api.FakeClassnameTags123Api(api_client)
body = Client() # Client | client model
body = Client(
client="client_example",
) # Client | client model
# example passing only required values which don't have defaults set
try:
# To test class name in snake case

View File

@ -50,8 +50,26 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = pet_api.PetApi(api_client)
body = Pet() # Pet | Pet object that needs to be added to the store
body = Pet(
id=1,
category=Category(
id=1,
name="default-name",
),
name="doggie",
photo_urls=[
"photo_urls_example",
],
tags=[
Tag(
id=1,
name="name_example",
full_name="full_name_example",
),
],
status="available",
) # Pet | Pet object that needs to be added to the store
# example passing only required values which don't have defaults set
try:
# Add a new pet to the store
@ -121,8 +139,8 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = pet_api.PetApi(api_client)
pet_id = 56 # int | Pet id to delete
api_key = 'api_key_example' # str | (optional)
pet_id = 1 # int | Pet id to delete
api_key = "api_key_example" # str | (optional)
# example passing only required values which don't have defaults set
try:
@ -205,8 +223,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = pet_api.PetApi(api_client)
status = ['status_example'] # [str] | Status values that need to be considered for filter
status = [
"available",
] # [str] | Status values that need to be considered for filter
# example passing only required values which don't have defaults set
try:
# Finds Pets by status
@ -280,8 +300,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = pet_api.PetApi(api_client)
tags = ['tags_example'] # [str] | Tags to filter by
tags = [
"tags_example",
] # [str] | Tags to filter by
# example passing only required values which don't have defaults set
try:
# Finds Pets by tags
@ -359,8 +381,8 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = pet_api.PetApi(api_client)
pet_id = 56 # int | ID of pet to return
pet_id = 1 # int | ID of pet to return
# example passing only required values which don't have defaults set
try:
# Find pet by ID
@ -433,8 +455,26 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = pet_api.PetApi(api_client)
body = Pet() # Pet | Pet object that needs to be added to the store
body = Pet(
id=1,
category=Category(
id=1,
name="default-name",
),
name="doggie",
photo_urls=[
"photo_urls_example",
],
tags=[
Tag(
id=1,
name="name_example",
full_name="full_name_example",
),
],
status="available",
) # Pet | Pet object that needs to be added to the store
# example passing only required values which don't have defaults set
try:
# Update an existing pet
@ -506,9 +546,9 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = pet_api.PetApi(api_client)
pet_id = 56 # int | ID of pet that needs to be updated
name = 'name_example' # str | Updated name of the pet (optional)
status = 'status_example' # str | Updated status of the pet (optional)
pet_id = 1 # int | ID of pet that needs to be updated
name = "name_example" # str | Updated name of the pet (optional)
status = "status_example" # str | Updated status of the pet (optional)
# example passing only required values which don't have defaults set
try:
@ -589,10 +629,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = pet_api.PetApi(api_client)
pet_id = 56 # int | ID of pet to update
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
file = open('/path/to/file', 'rb') # file_type | file to upload (optional)
files = open('/path/to/file', 'rb') # [file_type] | files to upload (optional)
pet_id = 1 # int | ID of pet to update
additional_metadata = "additional_metadata_example" # str | Additional data to pass to server (optional)
file = open('/path/to/file', 'rb') # file_type | file to upload (optional)
files = # [file_type] | files to upload (optional)
# example passing only required values which don't have defaults set
try:
@ -676,9 +716,9 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = pet_api.PetApi(api_client)
pet_id = 56 # int | ID of pet to update
pet_id = 1 # int | ID of pet to update
required_file = open('/path/to/file', 'rb') # file_type | file to upload
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
additional_metadata = "additional_metadata_example" # str | Additional data to pass to server (optional)
# example passing only required values which don't have defaults set
try:

View File

@ -35,8 +35,8 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = store_api.StoreApi(api_client)
order_id = 'order_id_example' # str | ID of the order that needs to be deleted
order_id = "order_id_example" # str | ID of the order that needs to be deleted
# example passing only required values which don't have defaults set
try:
# Delete purchase order by ID
@ -112,7 +112,7 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = store_api.StoreApi(api_client)
# example, this endpoint has no required or optional parameters
try:
# Returns pet inventories by status
@ -171,8 +171,8 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = store_api.StoreApi(api_client)
order_id = 56 # int | ID of pet that needs to be fetched
order_id = 1 # int | ID of pet that needs to be fetched
# example passing only required values which don't have defaults set
try:
# Find purchase order by ID
@ -234,8 +234,15 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = store_api.StoreApi(api_client)
body = Order() # Order | order placed for purchasing the pet
body = Order(
id=1,
pet_id=1,
quantity=1,
ship_date=dateutil_parser('1970-01-01T00:00:00.00Z'),
status="placed",
complete=False,
) # Order | order placed for purchasing the pet
# example passing only required values which don't have defaults set
try:
# Place an order for a pet

View File

@ -5,7 +5,7 @@ a model to test optional properties with server defaults
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**array_item** | **[int]** | |
**string_item** | **str** | | defaults to 'what'
**string_item** | **str** | | defaults to "what"
**number_item** | **float** | | defaults to 1.234
**integer_item** | **int** | | defaults to -2
**bool_item** | **bool** | | defaults to True

View File

@ -6,7 +6,7 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**bool_item** | **bool** | |
**array_item** | **[int]** | |
**string_item** | **str** | | defaults to 'what'
**string_item** | **str** | | defaults to "what"
**number_item** | **float** | | defaults to 1.234
**integer_item** | **int** | | defaults to -2

View File

@ -40,8 +40,17 @@ 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)
body = User() # User | Created user object
body = 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,
) # User | Created user object
# example passing only required values which don't have defaults set
try:
# Create user
@ -100,8 +109,19 @@ 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)
body = [User()] # [User] | List of user object
body = [
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,
),
] # [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 +180,19 @@ 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)
body = [User()] # [User] | List of user object
body = [
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,
),
] # [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 +252,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 +313,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 +375,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 +438,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 +496,18 @@ 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
body = User() # User | Updated user object
username = "username_example" # str | name that need to be deleted
body = 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,
) # User | Updated user object
# example passing only required values which don't have defaults set
try:
# Updated user

View File

@ -1188,8 +1188,8 @@ class FakeApi(object):
def __test_endpoint_enums_length_one(
self,
query_integer=3,
query_string='brillig',
path_string='hello',
query_string="brillig",
path_string="hello",
path_integer=34,
header_number=1.234,
**kwargs
@ -1200,13 +1200,13 @@ class FakeApi(object):
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.test_endpoint_enums_length_one(query_integer=3, query_string='brillig', path_string='hello', path_integer=34, header_number=1.234, async_req=True)
>>> thread = api.test_endpoint_enums_length_one(query_integer=3, query_string="brillig", path_string="hello", path_integer=34, header_number=1.234, async_req=True)
>>> result = thread.get()
Args:
query_integer (int): defaults to 3, must be one of [3]
query_string (str): defaults to 'brillig', must be one of ['brillig']
path_string (str): defaults to 'hello', must be one of ['hello']
query_string (str): defaults to "brillig", must be one of ["brillig"]
path_string (str): defaults to "hello", must be one of ["hello"]
path_integer (int): defaults to 34, must be one of [34]
header_number (float): defaults to 1.234, must be one of [1.234]
@ -1639,13 +1639,13 @@ class FakeApi(object):
Keyword Args:
enum_header_string_array ([str]): Header parameter enum test (string array). [optional]
enum_header_string (str): Header parameter enum test (string). [optional] if omitted the server will use the default value of '-efg'
enum_header_string (str): Header parameter enum test (string). [optional] if omitted the server will use the default value of "-efg"
enum_query_string_array ([str]): Query parameter enum test (string array). [optional]
enum_query_string (str): Query parameter enum test (string). [optional] if omitted the server will use the default value of '-efg'
enum_query_string (str): Query parameter enum test (string). [optional] if omitted the server will use the default value of "-efg"
enum_query_integer (int): Query parameter enum test (double). [optional]
enum_query_double (float): Query parameter enum test (double). [optional]
enum_form_string_array ([str]): Form parameter enum test (string array). [optional] if omitted the server will use the default value of '$'
enum_form_string (str): Form parameter enum test (string). [optional] if omitted the server will use the default value of '-efg'
enum_form_string_array ([str]): Form parameter enum test (string array). [optional] if omitted the server will use the default value of "$"
enum_form_string (str): Form parameter enum test (string). [optional] if omitted the server will use the default value of "-efg"
_return_http_data_only (bool): response data without head status
code and headers. Default is True.
_preload_content (bool): if False, the urllib3.HTTPResponse object

View File

@ -152,7 +152,7 @@ class Animal(ModelNormal):
Animal class but this time we won't travel
through its discriminator because we passed in
_visited_composed_classes = (Animal,)
color (str): [optional] if omitted the server will use the default value of 'red' # noqa: E501
color (str): [optional] if omitted the server will use the default value of "red" # noqa: E501
"""
_check_type = kwargs.pop('_check_type', True)

View File

@ -153,7 +153,7 @@ class Cat(ModelComposed):
through its discriminator because we passed in
_visited_composed_classes = (Animal,)
declawed (bool): [optional] # noqa: E501
color (str): [optional] if omitted the server will use the default value of 'red' # noqa: E501
color (str): [optional] if omitted the server will use the default value of "red" # noqa: E501
"""
_check_type = kwargs.pop('_check_type', True)

View File

@ -108,7 +108,7 @@ class Category(ModelNormal):
Args:
Keyword Args:
name (str): defaults to 'default-name' # noqa: E501
name (str): defaults to "default-name" # noqa: E501
_check_type (bool): if True, values for parameters in openapi_types
will be type checked and a TypeError will be
raised if the wrong type is input.
@ -142,7 +142,7 @@ class Category(ModelNormal):
id (int): [optional] # noqa: E501
"""
name = kwargs.get('name', 'default-name')
name = kwargs.get('name', "default-name")
_check_type = kwargs.pop('_check_type', True)
_spec_property_naming = kwargs.pop('_spec_property_naming', False)
_path_to_item = kwargs.pop('_path_to_item', ())

View File

@ -153,7 +153,7 @@ class Dog(ModelComposed):
through its discriminator because we passed in
_visited_composed_classes = (Animal,)
breed (str): [optional] # noqa: E501
color (str): [optional] if omitted the server will use the default value of 'red' # noqa: E501
color (str): [optional] if omitted the server will use the default value of "red" # noqa: E501
"""
_check_type = kwargs.pop('_check_type', True)

View File

@ -103,7 +103,7 @@ class EnumClass(ModelSimple):
"""EnumClass - a model defined in OpenAPI
Args:
value (str): if omitted the server will use the default value of '-efg', must be one of ["_abc", "-efg", "(xyz)", ] # noqa: E501
value (str): if omitted the server will use the default value of "-efg", must be one of ["_abc", "-efg", "(xyz)", ] # noqa: E501
Keyword Args:
_check_type (bool): if True, values for parameters in openapi_types

View File

@ -119,7 +119,7 @@ class TypeHolderDefault(ModelNormal):
array_item ([int]):
Keyword Args:
string_item (str): defaults to 'what' # noqa: E501
string_item (str): defaults to "what" # noqa: E501
number_item (float): defaults to 1.234 # noqa: E501
integer_item (int): defaults to -2 # noqa: E501
bool_item (bool): defaults to True # noqa: E501
@ -157,7 +157,7 @@ class TypeHolderDefault(ModelNormal):
datetime_item (datetime): [optional] # noqa: E501
"""
string_item = kwargs.get('string_item', 'what')
string_item = kwargs.get('string_item', "what")
number_item = kwargs.get('number_item', 1.234)
integer_item = kwargs.get('integer_item', -2)
bool_item = kwargs.get('bool_item', True)

View File

@ -125,7 +125,7 @@ class TypeHolderExample(ModelNormal):
array_item ([int]):
Keyword Args:
string_item (str): defaults to 'what', must be one of ["what", ] # noqa: E501
string_item (str): defaults to "what", must be one of ["what", ] # noqa: E501
number_item (float): defaults to 1.234, must be one of [1.234, ] # noqa: E501
integer_item (int): defaults to -2, must be one of [-2, ] # noqa: E501
_check_type (bool): if True, values for parameters in openapi_types
@ -160,7 +160,7 @@ class TypeHolderExample(ModelNormal):
_visited_composed_classes = (Animal,)
"""
string_item = kwargs.get('string_item', 'what')
string_item = kwargs.get('string_item', "what")
number_item = kwargs.get('number_item', 1.234)
integer_item = kwargs.get('integer_item', -2)
_check_type = kwargs.pop('_check_type', True)

View File

@ -61,7 +61,7 @@ configuration = x_auth_id_alias.Configuration(
with x_auth_id_alias.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = usage_api.UsageApi(api_client)
# example, this endpoint has no required or optional parameters
try:
# Use any API key
@ -145,7 +145,7 @@ configuration = x_auth_id_alias.Configuration(
with x_auth_id_alias.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = usage_api.UsageApi(api_client)
# example, this endpoint has no required or optional parameters
try:
# Use both API keys
@ -218,7 +218,7 @@ configuration = x_auth_id_alias.Configuration(
with x_auth_id_alias.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = usage_api.UsageApi(api_client)
# example, this endpoint has no required or optional parameters
try:
# Use API key in header
@ -291,7 +291,7 @@ configuration = x_auth_id_alias.Configuration(
with x_auth_id_alias.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = usage_api.UsageApi(api_client)
# example, this endpoint has no required or optional parameters
try:
# Use API key in query

View File

@ -33,7 +33,7 @@ configuration = dynamic_servers.Configuration(
with dynamic_servers.ApiClient() as api_client:
# Create an instance of the API class
api_instance = usage_api.UsageApi(api_client)
# example, this endpoint has no required or optional parameters
try:
# Use custom server
@ -91,7 +91,7 @@ configuration = dynamic_servers.Configuration(
with dynamic_servers.ApiClient() as api_client:
# Create an instance of the API class
api_instance = usage_api.UsageApi(api_client)
# example, this endpoint has no required or optional parameters
try:
# Use default server

View File

@ -63,7 +63,9 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = another_fake_api.AnotherFakeApi(api_client)
client = Client() # Client | client model
client = Client(
client="client_example",
) # Client | client model
try:
# To test special tags
@ -87,6 +89,7 @@ Class | Method | HTTP request | Description
*FakeApi* | [**boolean**](docs/FakeApi.md#boolean) | **POST** /fake/refs/boolean |
*FakeApi* | [**composed_one_of_number_with_validations**](docs/FakeApi.md#composed_one_of_number_with_validations) | **POST** /fake/refs/composed_one_of_number_with_validations |
*FakeApi* | [**fake_health_get**](docs/FakeApi.md#fake_health_get) | **GET** /fake/health | Health check endpoint
*FakeApi* | [**mammal**](docs/FakeApi.md#mammal) | **POST** /fake/refs/mammal |
*FakeApi* | [**number_with_validations**](docs/FakeApi.md#number_with_validations) | **POST** /fake/refs/number |
*FakeApi* | [**object_model_with_ref_props**](docs/FakeApi.md#object_model_with_ref_props) | **POST** /fake/refs/object_model_with_ref_props |
*FakeApi* | [**string**](docs/FakeApi.md#string) | **POST** /fake/refs/string |

View File

@ -4,7 +4,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**class_name** | **str** | |
**color** | **str** | | [optional] if omitted the server will use the default value of 'red'
**color** | **str** | | [optional] if omitted the server will use the default value of "red"
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -33,8 +33,10 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = another_fake_api.AnotherFakeApi(api_client)
client = Client() # Client | client model
client = Client(
client="client_example",
) # Client | client model
# example passing only required values which don't have defaults set
try:
# To test special tags

View File

@ -5,7 +5,7 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**class_name** | **str** | |
**declawed** | **bool** | | [optional]
**color** | **str** | | [optional] if omitted the server will use the default value of 'red'
**color** | **str** | | [optional] if omitted the server will use the default value of "red"
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -3,7 +3,7 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **str** | | defaults to 'default-name'
**name** | **str** | | defaults to "default-name"
**id** | **int** | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -5,7 +5,7 @@ this is a model that allows payloads of type object or number
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**class_name** | **str** | | defaults to nulltype.Null
**color** | **str** | | [optional] if omitted the server will use the default value of 'red'
**color** | **str** | | [optional] if omitted the server will use the default value of "red"
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -31,7 +31,7 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = default_api.DefaultApi(api_client)
# example, this endpoint has no required or optional parameters
try:
api_response = api_instance.foo_get()

View File

@ -5,7 +5,7 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**class_name** | **str** | |
**breed** | **str** | | [optional]
**color** | **str** | | [optional] if omitted the server will use the default value of 'red'
**color** | **str** | | [optional] if omitted the server will use the default value of "red"
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -3,7 +3,7 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**value** | **str** | | if omitted the server will use the default value of '-efg', must be one of ["_abc", "-efg", "(xyz)", ]
**value** | **str** | | if omitted the server will use the default value of "-efg", must be one of ["_abc", "-efg", "(xyz)", ]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -10,6 +10,7 @@ Method | HTTP request | Description
[**boolean**](FakeApi.md#boolean) | **POST** /fake/refs/boolean |
[**composed_one_of_number_with_validations**](FakeApi.md#composed_one_of_number_with_validations) | **POST** /fake/refs/composed_one_of_number_with_validations |
[**fake_health_get**](FakeApi.md#fake_health_get) | **GET** /fake/health | Health check endpoint
[**mammal**](FakeApi.md#mammal) | **POST** /fake/refs/mammal |
[**number_with_validations**](FakeApi.md#number_with_validations) | **POST** /fake/refs/number |
[**object_model_with_ref_props**](FakeApi.md#object_model_with_ref_props) | **POST** /fake/refs/object_model_with_ref_props |
[**string**](FakeApi.md#string) | **POST** /fake/refs/string |
@ -49,7 +50,11 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
additional_properties_with_array_of_enums = AdditionalPropertiesWithArrayOfEnums() # AdditionalPropertiesWithArrayOfEnums | Input enum (optional)
additional_properties_with_array_of_enums = AdditionalPropertiesWithArrayOfEnums(
"key": [
EnumClass("-efg"),
],
) # AdditionalPropertiesWithArrayOfEnums | Input enum (optional)
# example passing only required values which don't have defaults set
# and optional values
@ -113,7 +118,9 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
body = AnimalFarm() # AnimalFarm | Input model (optional)
body = AnimalFarm([
Animal(),
]) # AnimalFarm | Input model (optional)
# example passing only required values which don't have defaults set
# and optional values
@ -174,7 +181,9 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
array_of_enums = ArrayOfEnums() # ArrayOfEnums | Input enum (optional)
array_of_enums = ArrayOfEnums([
StringEnum("placed"),
]) # ArrayOfEnums | Input enum (optional)
# example passing only required values which don't have defaults set
# and optional values
@ -361,7 +370,7 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
# example, this endpoint has no required or optional parameters
try:
# Health check endpoint
@ -394,6 +403,72 @@ No authorization required
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **mammal**
> Mammal mammal(mammal)
Test serialization of mammals
### Example
```python
import time
import petstore_api
from petstore_api.api import fake_api
from petstore_api.model.mammal import Mammal
from pprint import pprint
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
# See configuration.py for a list of all supported configuration parameters.
configuration = petstore_api.Configuration(
host = "http://petstore.swagger.io:80/v2"
)
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
mammal = Mammal(
has_baleen=True,
has_teeth=True,
class_name="whale",
) # Mammal | Input mammal
# example passing only required values which don't have defaults set
try:
api_response = api_instance.mammal(mammal)
pprint(api_response)
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->mammal: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**mammal** | [**Mammal**](Mammal.md)| Input mammal |
### Return type
[**Mammal**](Mammal.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | Output mammal | - |
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **number_with_validations**
> NumberWithValidations number_with_validations()
@ -420,7 +495,7 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
body = NumberWithValidations(3.4) # NumberWithValidations | Input number as post body (optional)
body = NumberWithValidations(10) # NumberWithValidations | Input number as post body (optional)
# example passing only required values which don't have defaults set
# and optional values
@ -483,7 +558,11 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
body = ObjectModelWithRefProps() # ObjectModelWithRefProps | Input model (optional)
body = ObjectModelWithRefProps(
my_number=NumberWithValidations(10),
my_string="my_string_example",
my_boolean=True,
) # ObjectModelWithRefProps | Input model (optional)
# example passing only required values which don't have defaults set
# and optional values
@ -545,7 +624,7 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
body = 'body_example' # str | Input string as post body (optional)
body = "body_example" # str | Input string as post body (optional)
# example passing only required values which don't have defaults set
# and optional values
@ -671,8 +750,17 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
file_schema_test_class = FileSchemaTestClass() # FileSchemaTestClass |
file_schema_test_class = FileSchemaTestClass(
file=File(
source_uri="source_uri_example",
),
files=[
File(
source_uri="source_uri_example",
),
],
) # FileSchemaTestClass |
# example passing only required values which don't have defaults set
try:
api_instance.test_body_with_file_schema(file_schema_test_class)
@ -730,9 +818,22 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
query = 'query_example' # str |
user = User() # User |
query = "query_example" # str |
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 |
# example passing only required values which don't have defaults set
try:
api_instance.test_body_with_query_params(query, user)
@ -793,8 +894,10 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
client = Client() # Client | client model
client = Client(
client="client_example",
) # Client | client model
# example passing only required values which don't have defaults set
try:
# To test \"client\" model
@ -866,20 +969,20 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
number = 3.4 # float | None
double = 3.4 # float | None
pattern_without_delimiter = 'pattern_without_delimiter_example' # str | None
byte = 'byte_example' # str | None
integer = 56 # int | None (optional)
int32 = 56 # int | None (optional)
int64 = 56 # int | None (optional)
float = 3.4 # float | None (optional)
string = 'string_example' # str | None (optional)
binary = open('/path/to/file', 'rb') # file_type | None (optional)
date = '2013-10-20' # date | None (optional)
date_time = '2013-10-20T19:20:30+01:00' # datetime | None (optional)
password = 'password_example' # str | None (optional)
param_callback = 'param_callback_example' # str | None (optional)
number = 32.1 # float | None
double = 67.8 # float | None
pattern_without_delimiter = "AUR,rZ#UM/?R,Fp^l6$ARjbhJk C" # str | None
byte = 'YQ==' # str | None
integer = 10 # int | None (optional)
int32 = 20 # int | None (optional)
int64 = 1 # int | None (optional)
float = 3.14 # float | None (optional)
string = "a" # str | None (optional)
binary = open('/path/to/file', 'rb') # file_type | None (optional)
date = dateutil_parser('1970-01-01').date() # date | None (optional)
date_time = dateutil_parser('2020-02-02T20:20:20.22222Z') # datetime | None (optional) if omitted the server will use the default value of dateutil_parser('2010-02-01T10:20:10.11111+01:00')
password = "password_example" # str | None (optional)
param_callback = "param_callback_example" # str | None (optional)
# example passing only required values which don't have defaults set
try:
@ -912,7 +1015,7 @@ Name | Type | Description | Notes
**string** | **str**| None | [optional]
**binary** | **file_type**| None | [optional]
**date** | **date**| None | [optional]
**date_time** | **datetime**| None | [optional]
**date_time** | **datetime**| None | [optional] if omitted the server will use the default value of dateutil_parser('2010-02-01T10:20:10.11111+01:00')
**password** | **str**| None | [optional]
**param_callback** | **str**| None | [optional]
@ -962,14 +1065,18 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
enum_header_string_array = ['enum_header_string_array_example'] # [str] | Header parameter enum test (string array) (optional)
enum_header_string = '-efg' # str | Header parameter enum test (string) (optional) if omitted the server will use the default value of '-efg'
enum_query_string_array = ['enum_query_string_array_example'] # [str] | Query parameter enum test (string array) (optional)
enum_query_string = '-efg' # str | Query parameter enum test (string) (optional) if omitted the server will use the default value of '-efg'
enum_query_integer = 56 # int | Query parameter enum test (double) (optional)
enum_query_double = 3.4 # float | Query parameter enum test (double) (optional)
enum_form_string_array = '$' # [str] | Form parameter enum test (string array) (optional) if omitted the server will use the default value of '$'
enum_form_string = '-efg' # str | Form parameter enum test (string) (optional) if omitted the server will use the default value of '-efg'
enum_header_string_array = [
"$",
] # [str] | Header parameter enum test (string array) (optional)
enum_header_string = "-efg" # str | Header parameter enum test (string) (optional) if omitted the server will use the default value of "-efg"
enum_query_string_array = [
"$",
] # [str] | Query parameter enum test (string array) (optional)
enum_query_string = "-efg" # str | Query parameter enum test (string) (optional) if omitted the server will use the default value of "-efg"
enum_query_integer = 1 # int | Query parameter enum test (double) (optional)
enum_query_double = 1.1 # float | Query parameter enum test (double) (optional)
enum_form_string_array = "$" # [str] | Form parameter enum test (string array) (optional) if omitted the server will use the default value of "$"
enum_form_string = "-efg" # str | Form parameter enum test (string) (optional) if omitted the server will use the default value of "-efg"
# example passing only required values which don't have defaults set
# and optional values
@ -985,13 +1092,13 @@ enum_form_string = '-efg' # str | Form parameter enum test (string) (optional) i
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**enum_header_string_array** | **[str]**| Header parameter enum test (string array) | [optional]
**enum_header_string** | **str**| Header parameter enum test (string) | [optional] if omitted the server will use the default value of '-efg'
**enum_header_string** | **str**| Header parameter enum test (string) | [optional] if omitted the server will use the default value of "-efg"
**enum_query_string_array** | **[str]**| Query parameter enum test (string array) | [optional]
**enum_query_string** | **str**| Query parameter enum test (string) | [optional] if omitted the server will use the default value of '-efg'
**enum_query_string** | **str**| Query parameter enum test (string) | [optional] if omitted the server will use the default value of "-efg"
**enum_query_integer** | **int**| Query parameter enum test (double) | [optional]
**enum_query_double** | **float**| Query parameter enum test (double) | [optional]
**enum_form_string_array** | **[str]**| Form parameter enum test (string array) | [optional] if omitted the server will use the default value of '$'
**enum_form_string** | **str**| Form parameter enum test (string) | [optional] if omitted the server will use the default value of '-efg'
**enum_form_string_array** | **[str]**| Form parameter enum test (string array) | [optional] if omitted the server will use the default value of "$"
**enum_form_string** | **str**| Form parameter enum test (string) | [optional] if omitted the server will use the default value of "-efg"
### Return type
@ -1049,12 +1156,12 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
required_string_group = 56 # int | Required String in group parameters
required_string_group = 1 # int | Required String in group parameters
required_boolean_group = True # bool | Required Boolean in group parameters
required_int64_group = 56 # int | Required Integer in group parameters
string_group = 56 # int | String in group parameters (optional)
boolean_group = True # bool | Boolean in group parameters (optional)
int64_group = 56 # int | Integer in group parameters (optional)
required_int64_group = 1 # int | Required Integer in group parameters
string_group = 1 # int | String in group parameters (optional)
boolean_group = True # bool | Boolean in group parameters (optional)
int64_group = 1 # int | Integer in group parameters (optional)
# example passing only required values which don't have defaults set
try:
@ -1126,8 +1233,10 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
request_body = {'key': 'request_body_example'} # {str: (str,)} | request body
request_body = {
"key": "key_example",
} # {str: (str,)} | request body
# example passing only required values which don't have defaults set
try:
# test inline additionalProperties
@ -1185,9 +1294,9 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
param = 'param_example' # str | field1
param2 = 'param2_example' # str | field2
param = "param_example" # str | field1
param2 = "param2_example" # str | field2
# example passing only required values which don't have defaults set
try:
# test json serialization of form data
@ -1248,12 +1357,22 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
pipe = ['pipe_example'] # [str] |
ioutil = ['ioutil_example'] # [str] |
http = ['http_example'] # [str] |
url = ['url_example'] # [str] |
context = ['context_example'] # [str] |
pipe = [
"pipe_example",
] # [str] |
ioutil = [
"ioutil_example",
] # [str] |
http = [
"http_example",
] # [str] |
url = [
"url_example",
] # [str] |
context = [
"context_example",
] # [str] |
# example passing only required values which don't have defaults set
try:
api_instance.test_query_parameter_collection_format(pipe, ioutil, http, url, context)

View File

@ -48,8 +48,10 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = fake_classname_tags_123_api.FakeClassnameTags123Api(api_client)
client = Client() # Client | client model
client = Client(
client="client_example",
) # Client | client model
# example passing only required values which don't have defaults set
try:
# To test class name in snake case

View File

@ -3,7 +3,7 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**bar** | **str** | | [optional] if omitted the server will use the default value of 'bar'
**bar** | **str** | | [optional] if omitted the server will use the default value of "bar"
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -16,6 +16,7 @@ Name | Type | Description | Notes
**binary** | **file_type** | | [optional]
**date_time** | **datetime** | | [optional]
**uuid** | **str** | | [optional]
**uuid_no_example** | **str** | | [optional]
**pattern_with_digits** | **str** | A string that is a 10 digit number. Can have leading zeros. | [optional]
**pattern_with_digits_and_delimiter** | **str** | A string starting with &#39;image_&#39; (case insensitive) and one to three digits following i.e. Image_01. | [optional]

View File

@ -4,7 +4,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**enum_form_string_array** | **[str]** | Form parameter enum test (string array) | [optional]
**enum_form_string** | **str** | Form parameter enum test (string) | [optional] if omitted the server will use the default value of '-efg'
**enum_form_string** | **str** | Form parameter enum test (string) | [optional] if omitted the server will use the default value of "-efg"
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -110,8 +110,25 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = pet_api.PetApi(api_client)
pet = Pet() # Pet | Pet object that needs to be added to the store
pet = Pet(
id=1,
category=Category(
id=1,
name="default-name",
),
name="doggie",
photo_urls=[
"photo_urls_example",
],
tags=[
Tag(
id=1,
name="name_example",
),
],
status="available",
) # Pet | Pet object that needs to be added to the store
# example passing only required values which don't have defaults set
try:
# Add a new pet to the store
@ -180,8 +197,8 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = pet_api.PetApi(api_client)
pet_id = 56 # int | Pet id to delete
api_key = 'api_key_example' # str | (optional)
pet_id = 1 # int | Pet id to delete
api_key = "api_key_example" # str | (optional)
# example passing only required values which don't have defaults set
try:
@ -323,8 +340,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = pet_api.PetApi(api_client)
status = ['status_example'] # [str] | Status values that need to be considered for filter
status = [
"available",
] # [str] | Status values that need to be considered for filter
# example passing only required values which don't have defaults set
try:
# Finds Pets by status
@ -458,8 +477,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = pet_api.PetApi(api_client)
tags = ['tags_example'] # [str] | Tags to filter by
tags = [
"tags_example",
] # [str] | Tags to filter by
# example passing only required values which don't have defaults set
try:
# Finds Pets by tags
@ -537,8 +558,8 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = pet_api.PetApi(api_client)
pet_id = 56 # int | ID of pet to return
pet_id = 1 # int | ID of pet to return
# example passing only required values which don't have defaults set
try:
# Find pet by ID
@ -671,8 +692,25 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = pet_api.PetApi(api_client)
pet = Pet() # Pet | Pet object that needs to be added to the store
pet = Pet(
id=1,
category=Category(
id=1,
name="default-name",
),
name="doggie",
photo_urls=[
"photo_urls_example",
],
tags=[
Tag(
id=1,
name="name_example",
),
],
status="available",
) # Pet | Pet object that needs to be added to the store
# example passing only required values which don't have defaults set
try:
# Update an existing pet
@ -743,9 +781,9 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = pet_api.PetApi(api_client)
pet_id = 56 # int | ID of pet that needs to be updated
name = 'name_example' # str | Updated name of the pet (optional)
status = 'status_example' # str | Updated status of the pet (optional)
pet_id = 1 # int | ID of pet that needs to be updated
name = "name_example" # str | Updated name of the pet (optional)
status = "status_example" # str | Updated status of the pet (optional)
# example passing only required values which don't have defaults set
try:
@ -826,9 +864,9 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = pet_api.PetApi(api_client)
pet_id = 56 # int | ID of pet to update
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
file = open('/path/to/file', 'rb') # file_type | file to upload (optional)
pet_id = 1 # int | ID of pet to update
additional_metadata = "additional_metadata_example" # str | Additional data to pass to server (optional)
file = open('/path/to/file', 'rb') # file_type | file to upload (optional)
# example passing only required values which don't have defaults set
try:
@ -911,9 +949,9 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = pet_api.PetApi(api_client)
pet_id = 56 # int | ID of pet to update
pet_id = 1 # int | ID of pet to update
required_file = open('/path/to/file', 'rb') # file_type | file to upload
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
additional_metadata = "additional_metadata_example" # str | Additional data to pass to server (optional)
# example passing only required values which don't have defaults set
try:

View File

@ -35,8 +35,8 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = store_api.StoreApi(api_client)
order_id = 'order_id_example' # str | ID of the order that needs to be deleted
order_id = "order_id_example" # str | ID of the order that needs to be deleted
# example passing only required values which don't have defaults set
try:
# Delete purchase order by ID
@ -112,7 +112,7 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = store_api.StoreApi(api_client)
# example, this endpoint has no required or optional parameters
try:
# Returns pet inventories by status
@ -171,8 +171,8 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = store_api.StoreApi(api_client)
order_id = 56 # int | ID of pet that needs to be fetched
order_id = 1 # int | ID of pet that needs to be fetched
# example passing only required values which don't have defaults set
try:
# Find purchase order by ID
@ -234,8 +234,15 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = store_api.StoreApi(api_client)
order = Order() # Order | order placed for purchasing the pet
order = Order(
id=1,
pet_id=1,
quantity=1,
ship_date=dateutil_parser('2020-02-02T20:20:20.000222Z'),
status="placed",
complete=False,
) # Order | order placed for purchasing the pet
# example passing only required values which don't have defaults set
try:
# Place an order for a pet

View File

@ -3,7 +3,9 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**value** | **str** | | must be one of ["placed", "approved", "delivered", ]
**value** | **str** | | must be one of ["placed", "approved", "delivered", "single quoted", '''multiple
lines''', '''double quote
with newline''', ]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -3,7 +3,7 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**value** | **str** | | if omitted the server will use the default value of 'placed', must be one of ["placed", "approved", "delivered", ]
**value** | **str** | | if omitted the server will use the default value of "placed", must be one of ["placed", "approved", "delivered", ]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

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

View File

@ -30,6 +30,7 @@ from petstore_api.model.client import Client
from petstore_api.model.composed_one_of_number_with_validations import ComposedOneOfNumberWithValidations
from petstore_api.model.file_schema_test_class import FileSchemaTestClass
from petstore_api.model.health_check_result import HealthCheckResult
from petstore_api.model.mammal import Mammal
from petstore_api.model.number_with_validations import NumberWithValidations
from petstore_api.model.object_model_with_ref_props import ObjectModelWithRefProps
from petstore_api.model.string_enum import StringEnum
@ -710,6 +711,124 @@ class FakeApi(object):
callable=__fake_health_get
)
def __mammal(
self,
mammal,
**kwargs
):
"""mammal # noqa: E501
Test serialization of mammals # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.mammal(mammal, async_req=True)
>>> result = thread.get()
Args:
mammal (Mammal): Input mammal
Keyword Args:
_return_http_data_only (bool): response data without head status
code and headers. Default is True.
_preload_content (bool): if False, the urllib3.HTTPResponse object
will be returned without reading/decoding response data.
Default is True.
_request_timeout (float/tuple): timeout setting for this request. If one
number provided, it will be total request timeout. It can also
be a pair (tuple) of (connection, read) timeouts.
Default is None.
_check_input_type (bool): specifies if type checking
should be done one the data sent to the server.
Default is True.
_check_return_type (bool): specifies if type checking
should be done one the data received from the server.
Default is True.
_host_index (int/None): specifies the index of the server
that we want to use.
Default is read from the configuration.
async_req (bool): execute request asynchronously
Returns:
Mammal
If the method is called asynchronously, returns the request
thread.
"""
kwargs['async_req'] = kwargs.get(
'async_req', False
)
kwargs['_return_http_data_only'] = kwargs.get(
'_return_http_data_only', True
)
kwargs['_preload_content'] = kwargs.get(
'_preload_content', True
)
kwargs['_request_timeout'] = kwargs.get(
'_request_timeout', None
)
kwargs['_check_input_type'] = kwargs.get(
'_check_input_type', True
)
kwargs['_check_return_type'] = kwargs.get(
'_check_return_type', True
)
kwargs['_host_index'] = kwargs.get('_host_index')
kwargs['mammal'] = \
mammal
return self.call_with_http_info(**kwargs)
self.mammal = Endpoint(
settings={
'response_type': (Mammal,),
'auth': [],
'endpoint_path': '/fake/refs/mammal',
'operation_id': 'mammal',
'http_method': 'POST',
'servers': None,
},
params_map={
'all': [
'mammal',
],
'required': [
'mammal',
],
'nullable': [
],
'enum': [
],
'validation': [
]
},
root_map={
'validations': {
},
'allowed_values': {
},
'openapi_types': {
'mammal':
(Mammal,),
},
'attribute_map': {
},
'location_map': {
'mammal': 'body',
},
'collection_format_map': {
}
},
headers_map={
'accept': [
'application/json'
],
'content_type': [
'application/json'
]
},
api_client=api_client,
callable=__mammal
)
def __number_with_validations(
self,
**kwargs
@ -1549,7 +1668,7 @@ class FakeApi(object):
string (str): None. [optional]
binary (file_type): None. [optional]
date (date): None. [optional]
date_time (datetime): None. [optional]
date_time (datetime): None. [optional] if omitted the server will use the default value of dateutil_parser('2010-02-01T10:20:10.11111+01:00')
password (str): None. [optional]
param_callback (str): None. [optional]
_return_http_data_only (bool): response data without head status
@ -1792,13 +1911,13 @@ class FakeApi(object):
Keyword Args:
enum_header_string_array ([str]): Header parameter enum test (string array). [optional]
enum_header_string (str): Header parameter enum test (string). [optional] if omitted the server will use the default value of '-efg'
enum_header_string (str): Header parameter enum test (string). [optional] if omitted the server will use the default value of "-efg"
enum_query_string_array ([str]): Query parameter enum test (string array). [optional]
enum_query_string (str): Query parameter enum test (string). [optional] if omitted the server will use the default value of '-efg'
enum_query_string (str): Query parameter enum test (string). [optional] if omitted the server will use the default value of "-efg"
enum_query_integer (int): Query parameter enum test (double). [optional]
enum_query_double (float): Query parameter enum test (double). [optional]
enum_form_string_array ([str]): Form parameter enum test (string array). [optional] if omitted the server will use the default value of '$'
enum_form_string (str): Form parameter enum test (string). [optional] if omitted the server will use the default value of '-efg'
enum_form_string_array ([str]): Form parameter enum test (string array). [optional] if omitted the server will use the default value of "$"
enum_form_string (str): Form parameter enum test (string). [optional] if omitted the server will use the default value of "-efg"
_return_http_data_only (bool): response data without head status
code and headers. Default is True.
_preload_content (bool): if False, the urllib3.HTTPResponse object

View File

@ -152,7 +152,7 @@ class Animal(ModelNormal):
Animal class but this time we won't travel
through its discriminator because we passed in
_visited_composed_classes = (Animal,)
color (str): [optional] if omitted the server will use the default value of 'red' # noqa: E501
color (str): [optional] if omitted the server will use the default value of "red" # noqa: E501
"""
_check_type = kwargs.pop('_check_type', True)

View File

@ -162,7 +162,7 @@ class Cat(ModelComposed):
through its discriminator because we passed in
_visited_composed_classes = (Animal,)
declawed (bool): [optional] # noqa: E501
color (str): [optional] if omitted the server will use the default value of 'red' # noqa: E501
color (str): [optional] if omitted the server will use the default value of "red" # noqa: E501
"""
_check_type = kwargs.pop('_check_type', True)

View File

@ -108,7 +108,7 @@ class Category(ModelNormal):
Args:
Keyword Args:
name (str): defaults to 'default-name' # noqa: E501
name (str): defaults to "default-name" # noqa: E501
_check_type (bool): if True, values for parameters in openapi_types
will be type checked and a TypeError will be
raised if the wrong type is input.
@ -142,7 +142,7 @@ class Category(ModelNormal):
id (int): [optional] # noqa: E501
"""
name = kwargs.get('name', 'default-name')
name = kwargs.get('name', "default-name")
_check_type = kwargs.pop('_check_type', True)
_spec_property_naming = kwargs.pop('_spec_property_naming', False)
_path_to_item = kwargs.pop('_path_to_item', ())

View File

@ -154,7 +154,7 @@ class ComposedOneOfNumberWithValidations(ModelComposed):
Animal class but this time we won't travel
through its discriminator because we passed in
_visited_composed_classes = (Animal,)
color (str): [optional] if omitted the server will use the default value of 'red' # noqa: E501
color (str): [optional] if omitted the server will use the default value of "red" # noqa: E501
"""
class_name = kwargs.get('class_name', nulltype.Null)

View File

@ -160,7 +160,7 @@ class Dog(ModelComposed):
through its discriminator because we passed in
_visited_composed_classes = (Animal,)
breed (str): [optional] # noqa: E501
color (str): [optional] if omitted the server will use the default value of 'red' # noqa: E501
color (str): [optional] if omitted the server will use the default value of "red" # noqa: E501
"""
_check_type = kwargs.pop('_check_type', True)

View File

@ -103,7 +103,7 @@ class EnumClass(ModelSimple):
"""EnumClass - a model defined in OpenAPI
Args:
value (str): if omitted the server will use the default value of '-efg', must be one of ["_abc", "-efg", "(xyz)", ] # noqa: E501
value (str): if omitted the server will use the default value of "-efg", must be one of ["_abc", "-efg", "(xyz)", ] # noqa: E501
Keyword Args:
_check_type (bool): if True, values for parameters in openapi_types

View File

@ -134,7 +134,7 @@ class Foo(ModelNormal):
Animal class but this time we won't travel
through its discriminator because we passed in
_visited_composed_classes = (Animal,)
bar (str): [optional] if omitted the server will use the default value of 'bar' # noqa: E501
bar (str): [optional] if omitted the server will use the default value of "bar" # noqa: E501
"""
_check_type = kwargs.pop('_check_type', True)

View File

@ -132,6 +132,7 @@ class FormatTest(ModelNormal):
'binary': (file_type,), # noqa: E501
'date_time': (datetime,), # noqa: E501
'uuid': (str,), # noqa: E501
'uuid_no_example': (str,), # noqa: E501
'pattern_with_digits': (str,), # noqa: E501
'pattern_with_digits_and_delimiter': (str,), # noqa: E501
}
@ -155,6 +156,7 @@ class FormatTest(ModelNormal):
'binary': 'binary', # noqa: E501
'date_time': 'dateTime', # noqa: E501
'uuid': 'uuid', # noqa: E501
'uuid_no_example': 'uuidNoExample', # noqa: E501
'pattern_with_digits': 'pattern_with_digits', # noqa: E501
'pattern_with_digits_and_delimiter': 'pattern_with_digits_and_delimiter', # noqa: E501
}
@ -220,6 +222,7 @@ class FormatTest(ModelNormal):
binary (file_type): [optional] # noqa: E501
date_time (datetime): [optional] # noqa: E501
uuid (str): [optional] # noqa: E501
uuid_no_example (str): [optional] # noqa: E501
pattern_with_digits (str): A string that is a 10 digit number. Can have leading zeros.. [optional] # noqa: E501
pattern_with_digits_and_delimiter (str): A string starting with &#39;image_&#39; (case insensitive) and one to three digits following i.e. Image_01.. [optional] # noqa: E501
"""

View File

@ -146,7 +146,7 @@ class InlineObject2(ModelNormal):
through its discriminator because we passed in
_visited_composed_classes = (Animal,)
enum_form_string_array ([str]): Form parameter enum test (string array). [optional] # noqa: E501
enum_form_string (str): Form parameter enum test (string). [optional] if omitted the server will use the default value of '-efg' # noqa: E501
enum_form_string (str): Form parameter enum test (string). [optional] if omitted the server will use the default value of "-efg" # noqa: E501
"""
_check_type = kwargs.pop('_check_type', True)

View File

@ -57,6 +57,11 @@ class StringEnum(ModelSimple):
'PLACED': "placed",
'APPROVED': "approved",
'DELIVERED': "delivered",
'SINGLE_QUOTED': "single quoted",
'MULTIPLE_LINES': '''multiple
lines''',
'DOUBLE_QUOTE_WITH_NEWLINE': '''double quote
with newline''',
},
}
@ -104,7 +109,9 @@ class StringEnum(ModelSimple):
"""StringEnum - a model defined in OpenAPI
Args:
value (str):, must be one of ["placed", "approved", "delivered", ] # noqa: E501
value (str):, must be one of ["placed", "approved", "delivered", "single quoted", '''multiple
lines''', '''double quote
with newline''', ] # noqa: E501
Keyword Args:
_check_type (bool): if True, values for parameters in openapi_types

View File

@ -103,7 +103,7 @@ class StringEnumWithDefaultValue(ModelSimple):
"""StringEnumWithDefaultValue - a model defined in OpenAPI
Args:
value (str): if omitted the server will use the default value of 'placed', must be one of ["placed", "approved", "delivered", ] # noqa: E501
value (str): if omitted the server will use the default value of "placed", must be one of ["placed", "approved", "delivered", ] # noqa: E501
Keyword Args:
_check_type (bool): if True, values for parameters in openapi_types

View File

@ -42,7 +42,10 @@ class TestStringEnum(unittest.TestCase):
'None': None,
'PLACED': "placed",
'APPROVED': "approved",
'DELIVERED': "delivered"
'DELIVERED': "delivered",
'DOUBLE_QUOTE_WITH_NEWLINE': "double quote \n with newline",
'MULTIPLE_LINES': "multiple\nlines",
'SINGLE_QUOTED': "single quoted"
}