mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-06-02 06:50:53 +00:00
[Dart] Add configuration to add new generators and add json_serializable (#8789)
* Add Dart configuration flag to set new generator * Change templates to add json_serializable generator * Fix dart tests * Add custom serialization for standard generator * this change opens us a way to allow adding more than 2 generators * Add sample project for json_serializer * Use basename for json field name * Update samples with basename as json key * Update dart generator docs * Create AbstractDartCodegen class * Update docs, dart-dio and dart-jaguar dont get json_serializable yet * Deduplicate method calls * Dix dart-dio generation * Revert formatting change in dart mustache * Fix formatting changes again * Improve dart serialization documentation specify default serializer * Better name for cli option * Rename default dart generator to 'native' * Another attempt to reduce whitespace noise * Fix api-client and api-helper * Rename default serialization mode to include word serialization * Remove trailing whitespace in enums
This commit is contained in:
parent
34c77c2807
commit
9fc33f6a73
@ -0,0 +1,7 @@
|
||||
generatorName: dart
|
||||
outputDir: samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/dart2
|
||||
additionalProperties:
|
||||
hideGenerationTimestamp: "true"
|
||||
serializationLibrary: json_serializable
|
@ -19,6 +19,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|pubLibrary|Library name in generated code| |null|
|
||||
|pubName|Name in generated pubspec| |null|
|
||||
|pubVersion|Version in generated pubspec| |null|
|
||||
|serializationLibrary|Specify serialization library|<dl><dt>**native_serialization**</dt><dd>Use native serializer, backwards compatible</dd><dt>**json_serializable**</dt><dd>Use json_serializable</dd></dl>|native_serialization|
|
||||
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|
||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
||||
|sourceFolder|Source folder for generated code| |null|
|
||||
|
@ -0,0 +1,686 @@
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.media.StringSchema;
|
||||
import io.swagger.v3.oas.models.servers.Server;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.*;
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
public abstract class AbstractDartCodegen extends DefaultCodegen {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractDartCodegen.class);
|
||||
|
||||
public static final String PUB_LIBRARY = "pubLibrary";
|
||||
public static final String PUB_NAME = "pubName";
|
||||
public static final String PUB_VERSION = "pubVersion";
|
||||
public static final String PUB_DESCRIPTION = "pubDescription";
|
||||
public static final String PUB_AUTHOR = "pubAuthor";
|
||||
public static final String PUB_AUTHOR_EMAIL = "pubAuthorEmail";
|
||||
public static final String PUB_HOMEPAGE = "pubHomepage";
|
||||
public static final String USE_ENUM_EXTENSION = "useEnumExtension";
|
||||
|
||||
protected String pubLibrary = "openapi.api";
|
||||
protected String pubName = "openapi";
|
||||
protected String pubVersion = "1.0.0";
|
||||
protected String pubDescription = "OpenAPI API client";
|
||||
protected String pubAuthor = "Author";
|
||||
protected String pubAuthorEmail = "author@homepage";
|
||||
protected String pubHomepage = "homepage";
|
||||
protected boolean useEnumExtension = false;
|
||||
protected String sourceFolder = "";
|
||||
protected String apiDocPath = "doc" + File.separator;
|
||||
protected String modelDocPath = "doc" + File.separator;
|
||||
protected String apiTestPath = "test" + File.separator;
|
||||
protected String modelTestPath = "test" + File.separator;
|
||||
|
||||
// Names that must not be used as model names because they clash with existing
|
||||
// default imports (dart:io, dart:async, package:http etc.) but are not basic dataTypes.
|
||||
protected Set<String> additionalReservedWords;
|
||||
|
||||
public AbstractDartCodegen() {
|
||||
super();
|
||||
|
||||
modifyFeatureSet(features -> features
|
||||
.includeDocumentationFeatures(DocumentationFeature.Readme)
|
||||
.securityFeatures(EnumSet.of(
|
||||
SecurityFeature.OAuth2_Implicit,
|
||||
SecurityFeature.BasicAuth,
|
||||
SecurityFeature.ApiKey
|
||||
))
|
||||
.excludeGlobalFeatures(
|
||||
GlobalFeature.XMLStructureDefinitions,
|
||||
GlobalFeature.Callbacks,
|
||||
GlobalFeature.LinkObjects,
|
||||
GlobalFeature.ParameterStyling
|
||||
)
|
||||
.excludeSchemaSupportFeatures(
|
||||
SchemaSupportFeature.Polymorphism
|
||||
)
|
||||
.includeParameterFeatures(
|
||||
ParameterFeature.Cookie
|
||||
)
|
||||
.includeClientModificationFeatures(
|
||||
ClientModificationFeature.BasePath
|
||||
)
|
||||
);
|
||||
|
||||
outputFolder = "generated-code/dart";
|
||||
modelTemplateFiles.put("model.mustache", ".dart");
|
||||
apiTemplateFiles.put("api.mustache", ".dart");
|
||||
embeddedTemplateDir = templateDir = "dart2";
|
||||
apiPackage = "lib.api";
|
||||
modelPackage = "lib.model";
|
||||
modelDocTemplateFiles.put("object_doc.mustache", ".md");
|
||||
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
||||
|
||||
modelTestTemplateFiles.put("model_test.mustache", ".dart");
|
||||
apiTestTemplateFiles.put("api_test.mustache", ".dart");
|
||||
|
||||
final List<String> reservedWordsList = new ArrayList<>();
|
||||
try(BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(DartClientCodegen.class.getResourceAsStream("/dart/dart-keywords.txt"),
|
||||
StandardCharsets.UTF_8))) {
|
||||
while (reader.ready()) {
|
||||
reservedWordsList.add(reader.readLine());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error reading dart keywords. Exception: {}", e.getMessage());
|
||||
}
|
||||
setReservedWordsLowerCase(reservedWordsList);
|
||||
|
||||
languageSpecificPrimitives = Sets.newHashSet(
|
||||
"String",
|
||||
"bool",
|
||||
"int",
|
||||
"num",
|
||||
"double",
|
||||
"dynamic"
|
||||
);
|
||||
|
||||
typeMapping = new HashMap<>();
|
||||
typeMapping.put("Array", "List");
|
||||
typeMapping.put("array", "List");
|
||||
typeMapping.put("map", "Map");
|
||||
typeMapping.put("List", "List");
|
||||
typeMapping.put("set", "Set");
|
||||
typeMapping.put("boolean", "bool");
|
||||
typeMapping.put("string", "String");
|
||||
typeMapping.put("char", "String");
|
||||
typeMapping.put("int", "int");
|
||||
typeMapping.put("long", "int");
|
||||
typeMapping.put("short", "int");
|
||||
typeMapping.put("number", "num");
|
||||
typeMapping.put("float", "double");
|
||||
typeMapping.put("double", "double");
|
||||
typeMapping.put("decimal", "double");
|
||||
typeMapping.put("integer", "int");
|
||||
typeMapping.put("Date", "DateTime");
|
||||
typeMapping.put("date", "DateTime");
|
||||
typeMapping.put("DateTime", "DateTime");
|
||||
typeMapping.put("file", "MultipartFile");
|
||||
typeMapping.put("binary", "MultipartFile");
|
||||
typeMapping.put("UUID", "String");
|
||||
typeMapping.put("URI", "String");
|
||||
typeMapping.put("ByteArray", "String");
|
||||
typeMapping.put("object", "Object");
|
||||
typeMapping.put("AnyType", "Object");
|
||||
|
||||
// DataTypes of the above values which are automatically imported.
|
||||
// They are also not allowed to be model names.
|
||||
defaultIncludes = Sets.newHashSet(
|
||||
"String",
|
||||
"bool",
|
||||
"int",
|
||||
"num",
|
||||
"double",
|
||||
"dynamic",
|
||||
"List",
|
||||
"Set",
|
||||
"Map",
|
||||
"DateTime",
|
||||
"Object",
|
||||
"MultipartFile"
|
||||
);
|
||||
|
||||
additionalReservedWords = Sets.newHashSet(
|
||||
"File",
|
||||
"Client",
|
||||
"Future",
|
||||
"Response"
|
||||
);
|
||||
|
||||
cliOptions.add(new CliOption(PUB_LIBRARY, "Library name in generated code"));
|
||||
cliOptions.add(new CliOption(PUB_NAME, "Name in generated pubspec"));
|
||||
cliOptions.add(new CliOption(PUB_VERSION, "Version in generated pubspec"));
|
||||
cliOptions.add(new CliOption(PUB_DESCRIPTION, "Description in generated pubspec"));
|
||||
cliOptions.add(new CliOption(PUB_AUTHOR, "Author name in generated pubspec"));
|
||||
cliOptions.add(new CliOption(PUB_AUTHOR_EMAIL, "Email address of the author in generated pubspec"));
|
||||
cliOptions.add(new CliOption(PUB_HOMEPAGE, "Homepage in generated pubspec"));
|
||||
cliOptions.add(new CliOption(USE_ENUM_EXTENSION, "Allow the 'x-enum-values' extension for enums"));
|
||||
cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, "Source folder for generated code"));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "dart";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates a Dart 2.x client library.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
if (StringUtils.isEmpty(System.getenv("DART_POST_PROCESS_FILE"))) {
|
||||
LOGGER.info("Environment variable DART_POST_PROCESS_FILE not defined so the Dart code may not be properly formatted. To define it, try `export DART_POST_PROCESS_FILE=\"/usr/local/bin/dartfmt -w\"` (Linux/Mac)");
|
||||
LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(PUB_NAME)) {
|
||||
this.setPubName((String) additionalProperties.get(PUB_NAME));
|
||||
} else {
|
||||
//not set, use to be passed to template
|
||||
additionalProperties.put(PUB_NAME, pubName);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(PUB_LIBRARY)) {
|
||||
this.setPubLibrary((String) additionalProperties.get(PUB_LIBRARY));
|
||||
} else {
|
||||
//not set, use to be passed to template
|
||||
additionalProperties.put(PUB_LIBRARY, pubLibrary);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(PUB_VERSION)) {
|
||||
this.setPubVersion((String) additionalProperties.get(PUB_VERSION));
|
||||
} else {
|
||||
//not set, use to be passed to template
|
||||
additionalProperties.put(PUB_VERSION, pubVersion);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(PUB_DESCRIPTION)) {
|
||||
this.setPubDescription((String) additionalProperties.get(PUB_DESCRIPTION));
|
||||
} else {
|
||||
//not set, use to be passed to template
|
||||
additionalProperties.put(PUB_DESCRIPTION, pubDescription);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(PUB_AUTHOR)) {
|
||||
this.setPubAuthor((String) additionalProperties.get(PUB_AUTHOR));
|
||||
} else {
|
||||
//not set, use to be passed to template
|
||||
additionalProperties.put(PUB_AUTHOR, pubAuthor);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(PUB_AUTHOR_EMAIL)) {
|
||||
this.setPubAuthorEmail((String) additionalProperties.get(PUB_AUTHOR_EMAIL));
|
||||
} else {
|
||||
//not set, use to be passed to template
|
||||
additionalProperties.put(PUB_AUTHOR_EMAIL, pubAuthorEmail);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(PUB_HOMEPAGE)) {
|
||||
this.setPubHomepage((String) additionalProperties.get(PUB_HOMEPAGE));
|
||||
} else {
|
||||
//not set, use to be passed to template
|
||||
additionalProperties.put(PUB_HOMEPAGE, pubHomepage);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(USE_ENUM_EXTENSION)) {
|
||||
this.setUseEnumExtension(convertPropertyToBooleanAndWriteBack(USE_ENUM_EXTENSION));
|
||||
} else {
|
||||
// Not set, use to be passed to template.
|
||||
additionalProperties.put(USE_ENUM_EXTENSION, useEnumExtension);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) {
|
||||
this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER));
|
||||
}
|
||||
|
||||
// make api and model doc path available in mustache template
|
||||
additionalProperties.put("apiDocPath", apiDocPath);
|
||||
additionalProperties.put("modelDocPath", modelDocPath);
|
||||
|
||||
// check to not overwrite a custom templateDir
|
||||
if (templateDir == null) {
|
||||
embeddedTemplateDir = templateDir = "dart2";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isReservedWord(String word) {
|
||||
// consider everything as reserved that is either a keyword,
|
||||
// a default included type, or a type include through some library
|
||||
return super.isReservedWord(word) ||
|
||||
defaultIncludes().contains(word) ||
|
||||
additionalReservedWords.contains(word);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
return name + "_";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + File.separator + sourceFolder + File.separator + apiPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + File.separator + sourceFolder + File.separator + modelPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiTestFileFolder() {
|
||||
return outputFolder + File.separator + apiTestPath.replace('/', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelTestFileFolder() {
|
||||
return outputFolder + File.separator + modelTestPath.replace('/', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiDocFileFolder() {
|
||||
return outputFolder + File.separator + apiDocPath.replace('/', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelDocFileFolder() {
|
||||
return outputFolder + File.separator + modelDocPath.replace('/', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
// replace - with _ e.g. created-at => created_at
|
||||
name = name.replace("-", "_");
|
||||
|
||||
// always need to replace leading underscores first
|
||||
name = name.replaceAll("^_", "");
|
||||
|
||||
// if it's all upper case, do nothing
|
||||
if (name.matches("^[A-Z_]*$")) {
|
||||
return name;
|
||||
}
|
||||
|
||||
// replace all characters that have a mapping but ignore underscores
|
||||
// append an underscore to each replacement so that it can be camelized
|
||||
if (name.chars().anyMatch(character -> specialCharReplacements.containsKey("" + ((char) character)))) {
|
||||
name = escape(name, specialCharReplacements, Lists.newArrayList("_"), "_");
|
||||
}
|
||||
// remove the rest
|
||||
name = sanitizeName(name);
|
||||
|
||||
// camelize (lower first character) the variable name
|
||||
// pet_id => petId
|
||||
name = camelize(name, true);
|
||||
|
||||
if (name.matches("^\\d.*")) {
|
||||
name = "n" + name;
|
||||
}
|
||||
|
||||
if (isReservedWord(name)) {
|
||||
name = escapeReservedWord(name);
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
// should be the same as variable name
|
||||
return toVarName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelName(final String name) {
|
||||
String nameWithPrefixSuffix = sanitizeName(name);
|
||||
if (!StringUtils.isEmpty(modelNamePrefix)) {
|
||||
// add '_' so that model name can be camelized correctly
|
||||
nameWithPrefixSuffix = modelNamePrefix + "_" + nameWithPrefixSuffix;
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(modelNameSuffix)) {
|
||||
// add '_' so that model name can be camelized correctly
|
||||
nameWithPrefixSuffix = nameWithPrefixSuffix + "_" + modelNameSuffix;
|
||||
}
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
final String camelizedName = camelize(nameWithPrefixSuffix);
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(camelizedName)) {
|
||||
final String modelName = "Model" + camelizedName;
|
||||
LOGGER.warn(camelizedName + " (reserved word) cannot be used as model name. Renamed to " + modelName);
|
||||
return modelName;
|
||||
}
|
||||
|
||||
// model name starts with number
|
||||
if (camelizedName.matches("^\\d.*")) {
|
||||
final String modelName = "Model" + camelizedName; // e.g. 200Response => Model200Response (after camelize)
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + modelName);
|
||||
return modelName;
|
||||
}
|
||||
|
||||
return camelizedName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
return underscore(toModelName(name));
|
||||
}
|
||||
|
||||
@Override public String toModelDocFilename(String name) {
|
||||
return toModelName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiFilename(String name) {
|
||||
return underscore(toApiName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiTestFilename(String name) {
|
||||
return toApiFilename(name) + "_test";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelTestFilename(String name) {
|
||||
return toModelFilename(name) + "_test";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toDefaultValue(Schema schema) {
|
||||
if (ModelUtils.isMapSchema(schema) || ModelUtils.isSet(schema)) {
|
||||
return "const {}";
|
||||
}
|
||||
if (ModelUtils.isArraySchema(schema)) {
|
||||
return "const []";
|
||||
}
|
||||
|
||||
if (schema.getDefault() != null) {
|
||||
if (ModelUtils.isDateSchema(schema) || ModelUtils.isDateTimeSchema(schema)) {
|
||||
// this is currently not supported and would create compile errors
|
||||
return null;
|
||||
}
|
||||
if (ModelUtils.isStringSchema(schema)) {
|
||||
return "'" + schema.getDefault().toString().replace("'", "\\'") + "'";
|
||||
}
|
||||
return schema.getDefault().toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
Schema<?> schema = ModelUtils.unaliasSchema(this.openAPI, p, importMapping);
|
||||
Schema<?> target = ModelUtils.isGenerateAliasAsModel() ? p : schema;
|
||||
if (ModelUtils.isArraySchema(target)) {
|
||||
Schema<?> items = getSchemaItems((ArraySchema) schema);
|
||||
return getSchemaType(target) + "<" + getTypeDeclaration(items) + ">";
|
||||
}
|
||||
if (ModelUtils.isMapSchema(target)) {
|
||||
// Note: ModelUtils.isMapSchema(p) returns true when p is a composed schema that also defines
|
||||
// additionalproperties: true
|
||||
Schema<?> inner = getAdditionalProperties(target);
|
||||
if (inner == null) {
|
||||
LOGGER.error("`{}` (map property) does not have a proper inner type defined. Default to type:string", p.getName());
|
||||
inner = new StringSchema().description("TODO default missing map inner type to string");
|
||||
p.setAdditionalProperties(inner);
|
||||
}
|
||||
return getSchemaType(target) + "<String, " + getTypeDeclaration(inner) + ">";
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchemaType(Schema p) {
|
||||
String openAPIType = super.getSchemaType(p);
|
||||
if (openAPIType == null) {
|
||||
LOGGER.error("No Type defined for Schema " + p);
|
||||
}
|
||||
if (typeMapping.containsKey(openAPIType)) {
|
||||
return typeMapping.get(openAPIType);
|
||||
}
|
||||
if (languageSpecificPrimitives.contains(openAPIType)) {
|
||||
return openAPIType;
|
||||
}
|
||||
return toModelName(openAPIType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||
return postProcessModelsEnum(objs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
|
||||
super.postProcessModelProperty(model, property);
|
||||
if (!model.isEnum && property.isEnum) {
|
||||
// These are inner enums, enums which do not exist as models, just as properties.
|
||||
// They are handled via the enum_inline template and and are generated in the
|
||||
// same file as the containing class. To prevent name clashes the inline enum classes
|
||||
// are prefix with the classname of the containing class in the template.
|
||||
// Here the datatypeWithEnum template variable gets updated to match that scheme.
|
||||
// Also taking into account potential collection types e.g. List<JustSymbolEnum> -> List<EnumArraysJustSymbolEnum>
|
||||
final String enumName = model.classname + property.enumName;
|
||||
if (property.items != null) {
|
||||
// inner items e.g. enums in collections, only works for one level
|
||||
// but same is the case for DefaultCodegen
|
||||
property.setDatatypeWithEnum(property.datatypeWithEnum.replace(property.items.datatypeWithEnum, enumName));
|
||||
property.items.setDatatypeWithEnum(enumName);
|
||||
property.items.setEnumName(enumName);
|
||||
} else {
|
||||
// plain enum property
|
||||
property.setDatatypeWithEnum(property.datatypeWithEnum.replace(property.enumName, enumName));
|
||||
}
|
||||
property.setEnumName(enumName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, List<Server> servers) {
|
||||
final CodegenOperation op = super.fromOperation(path, httpMethod, operation, servers);
|
||||
for (CodegenResponse r : op.responses) {
|
||||
// By default only set types are automatically added to operation imports, not sure why.
|
||||
// Add all container type imports here, by default 'dart:core' imports are skipped
|
||||
// but other sub classes may required specific container type imports.
|
||||
if (r.containerType != null && typeMapping().containsKey(r.containerType)) {
|
||||
final String value = typeMapping().get(r.containerType);
|
||||
if (needToImport(value)) {
|
||||
op.imports.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (CodegenParameter p : op.allParams) {
|
||||
if (p.isContainer) {
|
||||
final String type = p.isArray ? "array" : "map";
|
||||
if (typeMapping().containsKey(type)) {
|
||||
final String value = typeMapping().get(type);
|
||||
// Also add container imports for parameters.
|
||||
if (needToImport(value)) {
|
||||
op.imports.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return op;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateEnumVarsWithExtensions(List<Map<String, Object>> enumVars, Map<String, Object> vendorExtensions, String dataType) {
|
||||
if (vendorExtensions != null && useEnumExtension && vendorExtensions.containsKey("x-enum-values")) {
|
||||
// Use the x-enum-values extension for this enum
|
||||
// Existing enumVars added by the default handling need to be removed first
|
||||
enumVars.clear();
|
||||
|
||||
Object extension = vendorExtensions.get("x-enum-values");
|
||||
List<Map<String, Object>> values = (List<Map<String, Object>>) extension;
|
||||
for (Map<String, Object> value : values) {
|
||||
Map<String, Object> enumVar = new HashMap<>();
|
||||
enumVar.put("name", toEnumVarName((String) value.get("identifier"), dataType));
|
||||
enumVar.put("value", toEnumValue(value.get("numericValue").toString(), dataType));
|
||||
enumVar.put("isString", isDataTypeString(dataType));
|
||||
if (value.containsKey("description")) {
|
||||
enumVar.put("description", value.get("description").toString());
|
||||
}
|
||||
enumVars.add(enumVar);
|
||||
}
|
||||
} else {
|
||||
super.updateEnumVarsWithExtensions(enumVars, vendorExtensions, dataType);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEnumVarName(String value, String datatype) {
|
||||
if (value.length() == 0) {
|
||||
return "empty";
|
||||
}
|
||||
if (("number".equalsIgnoreCase(datatype) ||
|
||||
"double".equalsIgnoreCase(datatype) ||
|
||||
"int".equalsIgnoreCase(datatype)) &&
|
||||
value.matches("^-?\\d.*")) {
|
||||
// Only rename numeric values when the datatype is numeric
|
||||
// AND the name is not changed by enum extensions (matches a numeric value).
|
||||
boolean isNegative = value.startsWith("-");
|
||||
return toVarName("number" + (isNegative ? "_negative" : "") + value);
|
||||
}
|
||||
return toVarName(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEnumValue(String value, String datatype) {
|
||||
if ("number".equalsIgnoreCase(datatype) ||
|
||||
"int".equalsIgnoreCase(datatype)) {
|
||||
return value;
|
||||
} else {
|
||||
return "'" + escapeText(value) + "'";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toOperationId(String operationId) {
|
||||
operationId = super.toOperationId(operationId);
|
||||
|
||||
operationId = camelize(sanitizeName(operationId), true);
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
String newOperationId = camelize("call_" + operationId, true);
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
|
||||
return newOperationId;
|
||||
}
|
||||
|
||||
// operationId starts with a number
|
||||
if (operationId.matches("^\\d.*")) {
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + camelize("call_" + operationId), true);
|
||||
operationId = camelize("call_" + operationId, true);
|
||||
}
|
||||
|
||||
return operationId;
|
||||
}
|
||||
|
||||
public void setPubLibrary(String pubLibrary) {
|
||||
this.pubLibrary = pubLibrary;
|
||||
}
|
||||
|
||||
public void setPubName(String pubName) {
|
||||
this.pubName = pubName;
|
||||
}
|
||||
|
||||
public void setPubVersion(String pubVersion) {
|
||||
this.pubVersion = pubVersion;
|
||||
}
|
||||
|
||||
public void setPubDescription(String pubDescription) {
|
||||
this.pubDescription = pubDescription;
|
||||
}
|
||||
|
||||
public void setPubAuthor(String pubAuthor) {
|
||||
this.pubAuthor = pubAuthor;
|
||||
}
|
||||
|
||||
public void setPubAuthorEmail(String pubAuthorEmail) {
|
||||
this.pubAuthorEmail = pubAuthorEmail;
|
||||
}
|
||||
|
||||
public void setPubHomepage(String pubHomepage) {
|
||||
this.pubHomepage = pubHomepage;
|
||||
}
|
||||
|
||||
public void setUseEnumExtension(boolean useEnumExtension) {
|
||||
this.useEnumExtension = useEnumExtension;
|
||||
}
|
||||
|
||||
public void setSourceFolder(String sourceFolder) {
|
||||
this.sourceFolder = sourceFolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeQuotationMark(String input) {
|
||||
// remove " to avoid code injection
|
||||
return input.replace("\"", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeUnsafeCharacters(String input) {
|
||||
return input.replace("*/", "*_/").replace("/*", "/_*");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessFile(File file, String fileType) {
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String dartPostProcessFile = System.getenv("DART_POST_PROCESS_FILE");
|
||||
if (StringUtils.isEmpty(dartPostProcessFile)) {
|
||||
return; // skip if DART_POST_PROCESS_FILE env variable is not defined
|
||||
}
|
||||
|
||||
// process all files with dart extension
|
||||
if ("dart".equals(FilenameUtils.getExtension(file.toString()))) {
|
||||
// currently only support "dartfmt -w yourcode.dart"
|
||||
String command = dartPostProcessFile + " " + file.toString();
|
||||
try {
|
||||
Process p = Runtime.getRuntime().exec(command);
|
||||
int exitValue = p.waitFor();
|
||||
if (exitValue != 0) {
|
||||
LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue);
|
||||
} else {
|
||||
LOGGER.info("Successfully executed: {}", command);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -17,290 +17,51 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.media.StringSchema;
|
||||
import io.swagger.v3.oas.models.servers.Server;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.ClientModificationFeature;
|
||||
import org.openapitools.codegen.meta.features.DocumentationFeature;
|
||||
import org.openapitools.codegen.meta.features.GlobalFeature;
|
||||
import org.openapitools.codegen.meta.features.ParameterFeature;
|
||||
import org.openapitools.codegen.meta.features.SchemaSupportFeature;
|
||||
import org.openapitools.codegen.meta.features.SecurityFeature;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.*;
|
||||
public class DartClientCodegen extends AbstractDartCodegen {
|
||||
|
||||
public class DartClientCodegen extends DefaultCodegen {
|
||||
private final Logger LOGGER = LoggerFactory.getLogger(DartClientCodegen.class);
|
||||
|
||||
public static final String PUB_LIBRARY = "pubLibrary";
|
||||
public static final String PUB_NAME = "pubName";
|
||||
public static final String PUB_VERSION = "pubVersion";
|
||||
public static final String PUB_DESCRIPTION = "pubDescription";
|
||||
public static final String PUB_AUTHOR = "pubAuthor";
|
||||
public static final String PUB_AUTHOR_EMAIL = "pubAuthorEmail";
|
||||
public static final String PUB_HOMEPAGE = "pubHomepage";
|
||||
public static final String USE_ENUM_EXTENSION = "useEnumExtension";
|
||||
|
||||
protected String pubLibrary = "openapi.api";
|
||||
protected String pubName = "openapi";
|
||||
protected String pubVersion = "1.0.0";
|
||||
protected String pubDescription = "OpenAPI API client";
|
||||
protected String pubAuthor = "Author";
|
||||
protected String pubAuthorEmail = "author@homepage";
|
||||
protected String pubHomepage = "homepage";
|
||||
protected boolean useEnumExtension = false;
|
||||
protected String sourceFolder = "";
|
||||
protected String apiDocPath = "doc" + File.separator;
|
||||
protected String modelDocPath = "doc" + File.separator;
|
||||
protected String apiTestPath = "test" + File.separator;
|
||||
protected String modelTestPath = "test" + File.separator;
|
||||
|
||||
// Names that must not be used as model names because they clash with existing
|
||||
// default imports (dart:io, dart:async, package:http etc.) but are not basic dataTypes.
|
||||
protected Set<String> additionalReservedWords;
|
||||
public static final String SERIALIZATION_LIBRARY_NATIVE = "native_serialization";
|
||||
public static final String SERIALIZATION_LIBRARY_JSON_SERIALIZABLE = "json_serializable";
|
||||
|
||||
public DartClientCodegen() {
|
||||
super();
|
||||
|
||||
modifyFeatureSet(features -> features
|
||||
.includeDocumentationFeatures(DocumentationFeature.Readme)
|
||||
.securityFeatures(EnumSet.of(
|
||||
SecurityFeature.OAuth2_Implicit,
|
||||
SecurityFeature.BasicAuth,
|
||||
SecurityFeature.ApiKey
|
||||
))
|
||||
.excludeGlobalFeatures(
|
||||
GlobalFeature.XMLStructureDefinitions,
|
||||
GlobalFeature.Callbacks,
|
||||
GlobalFeature.LinkObjects,
|
||||
GlobalFeature.ParameterStyling
|
||||
)
|
||||
.excludeSchemaSupportFeatures(
|
||||
SchemaSupportFeature.Polymorphism
|
||||
)
|
||||
.includeParameterFeatures(
|
||||
ParameterFeature.Cookie
|
||||
)
|
||||
.includeClientModificationFeatures(
|
||||
ClientModificationFeature.BasePath
|
||||
)
|
||||
);
|
||||
final CliOption serializationLibrary = new CliOption(CodegenConstants.SERIALIZATION_LIBRARY,
|
||||
"Specify serialization library");
|
||||
serializationLibrary.setDefault(SERIALIZATION_LIBRARY_NATIVE);
|
||||
serializationLibrary.setType("String");
|
||||
|
||||
outputFolder = "generated-code/dart";
|
||||
modelTemplateFiles.put("model.mustache", ".dart");
|
||||
apiTemplateFiles.put("api.mustache", ".dart");
|
||||
embeddedTemplateDir = templateDir = "dart2";
|
||||
apiPackage = "lib.api";
|
||||
modelPackage = "lib.model";
|
||||
modelDocTemplateFiles.put("object_doc.mustache", ".md");
|
||||
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
||||
|
||||
modelTestTemplateFiles.put("model_test.mustache", ".dart");
|
||||
apiTestTemplateFiles.put("api_test.mustache", ".dart");
|
||||
|
||||
final List<String> reservedWordsList = new ArrayList<>();
|
||||
try(BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(DartClientCodegen.class.getResourceAsStream("/dart/dart-keywords.txt"),
|
||||
StandardCharsets.UTF_8))) {
|
||||
while (reader.ready()) {
|
||||
reservedWordsList.add(reader.readLine());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error reading dart keywords. Exception: {}", e.getMessage());
|
||||
}
|
||||
setReservedWordsLowerCase(reservedWordsList);
|
||||
|
||||
languageSpecificPrimitives = Sets.newHashSet(
|
||||
"String",
|
||||
"bool",
|
||||
"int",
|
||||
"num",
|
||||
"double",
|
||||
"dynamic"
|
||||
);
|
||||
|
||||
typeMapping = new HashMap<>();
|
||||
typeMapping.put("Array", "List");
|
||||
typeMapping.put("array", "List");
|
||||
typeMapping.put("map", "Map");
|
||||
typeMapping.put("List", "List");
|
||||
typeMapping.put("set", "Set");
|
||||
typeMapping.put("boolean", "bool");
|
||||
typeMapping.put("string", "String");
|
||||
typeMapping.put("char", "String");
|
||||
typeMapping.put("int", "int");
|
||||
typeMapping.put("long", "int");
|
||||
typeMapping.put("short", "int");
|
||||
typeMapping.put("number", "num");
|
||||
typeMapping.put("float", "double");
|
||||
typeMapping.put("double", "double");
|
||||
typeMapping.put("decimal", "double");
|
||||
typeMapping.put("integer", "int");
|
||||
typeMapping.put("Date", "DateTime");
|
||||
typeMapping.put("date", "DateTime");
|
||||
typeMapping.put("DateTime", "DateTime");
|
||||
typeMapping.put("file", "MultipartFile");
|
||||
typeMapping.put("binary", "MultipartFile");
|
||||
typeMapping.put("UUID", "String");
|
||||
typeMapping.put("URI", "String");
|
||||
typeMapping.put("ByteArray", "String");
|
||||
typeMapping.put("object", "Object");
|
||||
typeMapping.put("AnyType", "Object");
|
||||
|
||||
// DataTypes of the above values which are automatically imported.
|
||||
// They are also not allowed to be model names.
|
||||
defaultIncludes = Sets.newHashSet(
|
||||
"String",
|
||||
"bool",
|
||||
"int",
|
||||
"num",
|
||||
"double",
|
||||
"dynamic",
|
||||
"List",
|
||||
"Set",
|
||||
"Map",
|
||||
"DateTime",
|
||||
"Object",
|
||||
"MultipartFile"
|
||||
);
|
||||
|
||||
additionalReservedWords = Sets.newHashSet(
|
||||
"File",
|
||||
"Client",
|
||||
"Future",
|
||||
"Response"
|
||||
);
|
||||
|
||||
cliOptions.add(new CliOption(PUB_LIBRARY, "Library name in generated code"));
|
||||
cliOptions.add(new CliOption(PUB_NAME, "Name in generated pubspec"));
|
||||
cliOptions.add(new CliOption(PUB_VERSION, "Version in generated pubspec"));
|
||||
cliOptions.add(new CliOption(PUB_DESCRIPTION, "Description in generated pubspec"));
|
||||
cliOptions.add(new CliOption(PUB_AUTHOR, "Author name in generated pubspec"));
|
||||
cliOptions.add(new CliOption(PUB_AUTHOR_EMAIL, "Email address of the author in generated pubspec"));
|
||||
cliOptions.add(new CliOption(PUB_HOMEPAGE, "Homepage in generated pubspec"));
|
||||
cliOptions.add(new CliOption(USE_ENUM_EXTENSION, "Allow the 'x-enum-values' extension for enums"));
|
||||
cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, "Source folder for generated code"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "dart";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates a Dart 2.x client library.";
|
||||
}
|
||||
|
||||
protected void defaultProcessOpts() {
|
||||
super.processOpts();
|
||||
final Map<String, String> serializationOptions = new HashMap<>();
|
||||
serializationOptions.put(SERIALIZATION_LIBRARY_NATIVE, "Use native serializer, backwards compatible");
|
||||
serializationOptions.put(SERIALIZATION_LIBRARY_JSON_SERIALIZABLE, "Use json_serializable");
|
||||
serializationLibrary.setEnum(serializationOptions);
|
||||
cliOptions.add(serializationLibrary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
defaultProcessOpts();
|
||||
super.processOpts();
|
||||
|
||||
if (StringUtils.isEmpty(System.getenv("DART_POST_PROCESS_FILE"))) {
|
||||
LOGGER.info("Environment variable DART_POST_PROCESS_FILE not defined so the Dart code may not be properly formatted. To define it, try `export DART_POST_PROCESS_FILE=\"/usr/local/bin/dartfmt -w\"` (Linux/Mac)");
|
||||
LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(PUB_NAME)) {
|
||||
this.setPubName((String) additionalProperties.get(PUB_NAME));
|
||||
// handle library not being set
|
||||
if(additionalProperties.get(CodegenConstants.SERIALIZATION_LIBRARY) == null) {
|
||||
this.library = SERIALIZATION_LIBRARY_NATIVE;
|
||||
LOGGER.debug("Serialization library not set, using default {}", SERIALIZATION_LIBRARY_NATIVE);
|
||||
} else {
|
||||
//not set, use to be passed to template
|
||||
additionalProperties.put(PUB_NAME, pubName);
|
||||
this.library = additionalProperties.get(CodegenConstants.SERIALIZATION_LIBRARY).toString();
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(PUB_LIBRARY)) {
|
||||
this.setPubLibrary((String) additionalProperties.get(PUB_LIBRARY));
|
||||
} else {
|
||||
//not set, use to be passed to template
|
||||
additionalProperties.put(PUB_LIBRARY, pubLibrary);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(PUB_VERSION)) {
|
||||
this.setPubVersion((String) additionalProperties.get(PUB_VERSION));
|
||||
} else {
|
||||
//not set, use to be passed to template
|
||||
additionalProperties.put(PUB_VERSION, pubVersion);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(PUB_DESCRIPTION)) {
|
||||
this.setPubDescription((String) additionalProperties.get(PUB_DESCRIPTION));
|
||||
} else {
|
||||
//not set, use to be passed to template
|
||||
additionalProperties.put(PUB_DESCRIPTION, pubDescription);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(PUB_AUTHOR)) {
|
||||
this.setPubAuthor((String) additionalProperties.get(PUB_AUTHOR));
|
||||
} else {
|
||||
//not set, use to be passed to template
|
||||
additionalProperties.put(PUB_AUTHOR, pubAuthor);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(PUB_AUTHOR_EMAIL)) {
|
||||
this.setPubAuthorEmail((String) additionalProperties.get(PUB_AUTHOR_EMAIL));
|
||||
} else {
|
||||
//not set, use to be passed to template
|
||||
additionalProperties.put(PUB_AUTHOR_EMAIL, pubAuthorEmail);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(PUB_HOMEPAGE)) {
|
||||
this.setPubHomepage((String) additionalProperties.get(PUB_HOMEPAGE));
|
||||
} else {
|
||||
//not set, use to be passed to template
|
||||
additionalProperties.put(PUB_HOMEPAGE, pubHomepage);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(USE_ENUM_EXTENSION)) {
|
||||
this.setUseEnumExtension(convertPropertyToBooleanAndWriteBack(USE_ENUM_EXTENSION));
|
||||
} else {
|
||||
// Not set, use to be passed to template.
|
||||
additionalProperties.put(USE_ENUM_EXTENSION, useEnumExtension);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) {
|
||||
this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER));
|
||||
}
|
||||
|
||||
// make api and model doc path available in mustache template
|
||||
additionalProperties.put("apiDocPath", apiDocPath);
|
||||
additionalProperties.put("modelDocPath", modelDocPath);
|
||||
|
||||
// check to not overwrite a custom templateDir
|
||||
if (templateDir == null) {
|
||||
embeddedTemplateDir = templateDir = "dart2";
|
||||
}
|
||||
this.setSerializationLibrary();
|
||||
|
||||
final String libFolder = sourceFolder + File.separator + "lib";
|
||||
supportingFiles.add(new SupportingFile("pubspec.mustache", "", "pubspec.yaml"));
|
||||
@ -319,416 +80,26 @@ public class DartClientCodegen extends DefaultCodegen {
|
||||
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
supportingFiles.add(new SupportingFile("travis.mustache", "", ".travis.yml"));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isReservedWord(String word) {
|
||||
// consider everything as reserved that is either a keyword,
|
||||
// a default included type, or a type include through some library
|
||||
return super.isReservedWord(word) ||
|
||||
defaultIncludes().contains(word) ||
|
||||
additionalReservedWords.contains(word);
|
||||
}
|
||||
private void setSerializationLibrary() {
|
||||
final String serialization_library = getLibrary();
|
||||
LOGGER.info("Using serialization library {}", serialization_library);
|
||||
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
return name + "_";
|
||||
}
|
||||
switch (serialization_library) {
|
||||
case SERIALIZATION_LIBRARY_JSON_SERIALIZABLE:
|
||||
additionalProperties.put(SERIALIZATION_LIBRARY_JSON_SERIALIZABLE, "true");
|
||||
// json_serializable requires build.yaml
|
||||
supportingFiles.add(new SupportingFile("build.yaml.mustache",
|
||||
"" /* main project dir */,
|
||||
"build.yaml"));
|
||||
break;
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + File.separator + sourceFolder + File.separator + apiPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
case SERIALIZATION_LIBRARY_NATIVE: // fall trough to default backwards compatible generator
|
||||
default:
|
||||
additionalProperties.put(SERIALIZATION_LIBRARY_NATIVE, "true");
|
||||
|
||||
@Override
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + File.separator + sourceFolder + File.separator + modelPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiTestFileFolder() {
|
||||
return outputFolder + File.separator + apiTestPath.replace('/', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelTestFileFolder() {
|
||||
return outputFolder + File.separator + modelTestPath.replace('/', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiDocFileFolder() {
|
||||
return outputFolder + File.separator + apiDocPath.replace('/', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelDocFileFolder() {
|
||||
return outputFolder + File.separator + modelDocPath.replace('/', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
// replace - with _ e.g. created-at => created_at
|
||||
name = name.replace("-", "_");
|
||||
|
||||
// always need to replace leading underscores first
|
||||
name = name.replaceAll("^_", "");
|
||||
|
||||
// if it's all upper case, do nothing
|
||||
if (name.matches("^[A-Z_]*$")) {
|
||||
return name;
|
||||
}
|
||||
|
||||
// replace all characters that have a mapping but ignore underscores
|
||||
// append an underscore to each replacement so that it can be camelized
|
||||
if (name.chars().anyMatch(character -> specialCharReplacements.containsKey("" + ((char) character)))) {
|
||||
name = escape(name, specialCharReplacements, Lists.newArrayList("_"), "_");
|
||||
}
|
||||
// remove the rest
|
||||
name = sanitizeName(name);
|
||||
|
||||
// camelize (lower first character) the variable name
|
||||
// pet_id => petId
|
||||
name = camelize(name, true);
|
||||
|
||||
if (name.matches("^\\d.*")) {
|
||||
name = "n" + name;
|
||||
}
|
||||
|
||||
if (isReservedWord(name)) {
|
||||
name = escapeReservedWord(name);
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
// should be the same as variable name
|
||||
return toVarName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelName(final String name) {
|
||||
String nameWithPrefixSuffix = sanitizeName(name);
|
||||
if (!StringUtils.isEmpty(modelNamePrefix)) {
|
||||
// add '_' so that model name can be camelized correctly
|
||||
nameWithPrefixSuffix = modelNamePrefix + "_" + nameWithPrefixSuffix;
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(modelNameSuffix)) {
|
||||
// add '_' so that model name can be camelized correctly
|
||||
nameWithPrefixSuffix = nameWithPrefixSuffix + "_" + modelNameSuffix;
|
||||
}
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
final String camelizedName = camelize(nameWithPrefixSuffix);
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(camelizedName)) {
|
||||
final String modelName = "Model" + camelizedName;
|
||||
LOGGER.warn(camelizedName + " (reserved word) cannot be used as model name. Renamed to " + modelName);
|
||||
return modelName;
|
||||
}
|
||||
|
||||
// model name starts with number
|
||||
if (camelizedName.matches("^\\d.*")) {
|
||||
final String modelName = "Model" + camelizedName; // e.g. 200Response => Model200Response (after camelize)
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + modelName);
|
||||
return modelName;
|
||||
}
|
||||
|
||||
return camelizedName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
return underscore(toModelName(name));
|
||||
}
|
||||
|
||||
@Override public String toModelDocFilename(String name) {
|
||||
return toModelName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiFilename(String name) {
|
||||
return underscore(toApiName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiTestFilename(String name) {
|
||||
return toApiFilename(name) + "_test";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelTestFilename(String name) {
|
||||
return toModelFilename(name) + "_test";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toDefaultValue(Schema schema) {
|
||||
if (ModelUtils.isMapSchema(schema) || ModelUtils.isSet(schema)) {
|
||||
return "const {}";
|
||||
}
|
||||
if (ModelUtils.isArraySchema(schema)) {
|
||||
return "const []";
|
||||
}
|
||||
|
||||
if (schema.getDefault() != null) {
|
||||
if (ModelUtils.isDateSchema(schema) || ModelUtils.isDateTimeSchema(schema)) {
|
||||
// this is currently not supported and would create compile errors
|
||||
return null;
|
||||
}
|
||||
if (ModelUtils.isStringSchema(schema)) {
|
||||
return "'" + schema.getDefault().toString().replace("'", "\\'") + "'";
|
||||
}
|
||||
return schema.getDefault().toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
Schema<?> schema = ModelUtils.unaliasSchema(this.openAPI, p, importMapping);
|
||||
Schema<?> target = ModelUtils.isGenerateAliasAsModel() ? p : schema;
|
||||
if (ModelUtils.isArraySchema(target)) {
|
||||
Schema<?> items = getSchemaItems((ArraySchema) schema);
|
||||
return getSchemaType(target) + "<" + getTypeDeclaration(items) + ">";
|
||||
}
|
||||
if (ModelUtils.isMapSchema(target)) {
|
||||
// Note: ModelUtils.isMapSchema(p) returns true when p is a composed schema that also defines
|
||||
// additionalproperties: true
|
||||
Schema<?> inner = getAdditionalProperties(target);
|
||||
if (inner == null) {
|
||||
LOGGER.error("`{}` (map property) does not have a proper inner type defined. Default to type:string", p.getName());
|
||||
inner = new StringSchema().description("TODO default missing map inner type to string");
|
||||
p.setAdditionalProperties(inner);
|
||||
}
|
||||
return getSchemaType(target) + "<String, " + getTypeDeclaration(inner) + ">";
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchemaType(Schema p) {
|
||||
String openAPIType = super.getSchemaType(p);
|
||||
if (openAPIType == null) {
|
||||
LOGGER.error("No Type defined for Schema " + p);
|
||||
}
|
||||
if (typeMapping.containsKey(openAPIType)) {
|
||||
return typeMapping.get(openAPIType);
|
||||
}
|
||||
if (languageSpecificPrimitives.contains(openAPIType)) {
|
||||
return openAPIType;
|
||||
}
|
||||
return toModelName(openAPIType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||
return postProcessModelsEnum(objs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
|
||||
super.postProcessModelProperty(model, property);
|
||||
if (!model.isEnum && property.isEnum) {
|
||||
// These are inner enums, enums which do not exist as models, just as properties.
|
||||
// They are handled via the enum_inline template and and are generated in the
|
||||
// same file as the containing class. To prevent name clashes the inline enum classes
|
||||
// are prefix with the classname of the containing class in the template.
|
||||
// Here the datatypeWithEnum template variable gets updated to match that scheme.
|
||||
// Also taking into account potential collection types e.g. List<JustSymbolEnum> -> List<EnumArraysJustSymbolEnum>
|
||||
final String enumName = model.classname + property.enumName;
|
||||
if (property.items != null) {
|
||||
// inner items e.g. enums in collections, only works for one level
|
||||
// but same is the case for DefaultCodegen
|
||||
property.setDatatypeWithEnum(property.datatypeWithEnum.replace(property.items.datatypeWithEnum, enumName));
|
||||
property.items.setDatatypeWithEnum(enumName);
|
||||
property.items.setEnumName(enumName);
|
||||
} else {
|
||||
// plain enum property
|
||||
property.setDatatypeWithEnum(property.datatypeWithEnum.replace(property.enumName, enumName));
|
||||
}
|
||||
property.setEnumName(enumName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, List<Server> servers) {
|
||||
final CodegenOperation op = super.fromOperation(path, httpMethod, operation, servers);
|
||||
for (CodegenResponse r : op.responses) {
|
||||
// By default only set types are automatically added to operation imports, not sure why.
|
||||
// Add all container type imports here, by default 'dart:core' imports are skipped
|
||||
// but other sub classes may required specific container type imports.
|
||||
if (r.containerType != null && typeMapping().containsKey(r.containerType)) {
|
||||
final String value = typeMapping().get(r.containerType);
|
||||
if (needToImport(value)) {
|
||||
op.imports.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (CodegenParameter p : op.allParams) {
|
||||
if (p.isContainer) {
|
||||
final String type = p.isArray ? "array" : "map";
|
||||
if (typeMapping().containsKey(type)) {
|
||||
final String value = typeMapping().get(type);
|
||||
// Also add container imports for parameters.
|
||||
if (needToImport(value)) {
|
||||
op.imports.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return op;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateEnumVarsWithExtensions(List<Map<String, Object>> enumVars, Map<String, Object> vendorExtensions, String dataType) {
|
||||
if (vendorExtensions != null && useEnumExtension && vendorExtensions.containsKey("x-enum-values")) {
|
||||
// Use the x-enum-values extension for this enum
|
||||
// Existing enumVars added by the default handling need to be removed first
|
||||
enumVars.clear();
|
||||
|
||||
Object extension = vendorExtensions.get("x-enum-values");
|
||||
List<Map<String, Object>> values = (List<Map<String, Object>>) extension;
|
||||
for (Map<String, Object> value : values) {
|
||||
Map<String, Object> enumVar = new HashMap<>();
|
||||
enumVar.put("name", toEnumVarName((String) value.get("identifier"), dataType));
|
||||
enumVar.put("value", toEnumValue(value.get("numericValue").toString(), dataType));
|
||||
enumVar.put("isString", isDataTypeString(dataType));
|
||||
if (value.containsKey("description")) {
|
||||
enumVar.put("description", value.get("description").toString());
|
||||
}
|
||||
enumVars.add(enumVar);
|
||||
}
|
||||
} else {
|
||||
super.updateEnumVarsWithExtensions(enumVars, vendorExtensions, dataType);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEnumVarName(String value, String datatype) {
|
||||
if (value.length() == 0) {
|
||||
return "empty";
|
||||
}
|
||||
if (("number".equalsIgnoreCase(datatype) ||
|
||||
"double".equalsIgnoreCase(datatype) ||
|
||||
"int".equalsIgnoreCase(datatype)) &&
|
||||
value.matches("^-?\\d.*")) {
|
||||
// Only rename numeric values when the datatype is numeric
|
||||
// AND the name is not changed by enum extensions (matches a numeric value).
|
||||
boolean isNegative = value.startsWith("-");
|
||||
return toVarName("number" + (isNegative ? "_negative" : "") + value);
|
||||
}
|
||||
return toVarName(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEnumValue(String value, String datatype) {
|
||||
if ("number".equalsIgnoreCase(datatype) ||
|
||||
"int".equalsIgnoreCase(datatype)) {
|
||||
return value;
|
||||
} else {
|
||||
return "'" + escapeText(value) + "'";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toOperationId(String operationId) {
|
||||
operationId = super.toOperationId(operationId);
|
||||
|
||||
operationId = camelize(sanitizeName(operationId), true);
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
String newOperationId = camelize("call_" + operationId, true);
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
|
||||
return newOperationId;
|
||||
}
|
||||
|
||||
// operationId starts with a number
|
||||
if (operationId.matches("^\\d.*")) {
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + camelize("call_" + operationId), true);
|
||||
operationId = camelize("call_" + operationId, true);
|
||||
}
|
||||
|
||||
return operationId;
|
||||
}
|
||||
|
||||
public void setPubLibrary(String pubLibrary) {
|
||||
this.pubLibrary = pubLibrary;
|
||||
}
|
||||
|
||||
public void setPubName(String pubName) {
|
||||
this.pubName = pubName;
|
||||
}
|
||||
|
||||
public void setPubVersion(String pubVersion) {
|
||||
this.pubVersion = pubVersion;
|
||||
}
|
||||
|
||||
public void setPubDescription(String pubDescription) {
|
||||
this.pubDescription = pubDescription;
|
||||
}
|
||||
|
||||
public void setPubAuthor(String pubAuthor) {
|
||||
this.pubAuthor = pubAuthor;
|
||||
}
|
||||
|
||||
public void setPubAuthorEmail(String pubAuthorEmail) {
|
||||
this.pubAuthorEmail = pubAuthorEmail;
|
||||
}
|
||||
|
||||
public void setPubHomepage(String pubHomepage) {
|
||||
this.pubHomepage = pubHomepage;
|
||||
}
|
||||
|
||||
public void setUseEnumExtension(boolean useEnumExtension) {
|
||||
this.useEnumExtension = useEnumExtension;
|
||||
}
|
||||
|
||||
public void setSourceFolder(String sourceFolder) {
|
||||
this.sourceFolder = sourceFolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeQuotationMark(String input) {
|
||||
// remove " to avoid code injection
|
||||
return input.replace("\"", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeUnsafeCharacters(String input) {
|
||||
return input.replace("*/", "*_/").replace("/*", "/_*");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessFile(File file, String fileType) {
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String dartPostProcessFile = System.getenv("DART_POST_PROCESS_FILE");
|
||||
if (StringUtils.isEmpty(dartPostProcessFile)) {
|
||||
return; // skip if DART_POST_PROCESS_FILE env variable is not defined
|
||||
}
|
||||
|
||||
// process all files with dart extension
|
||||
if ("dart".equals(FilenameUtils.getExtension(file.toString()))) {
|
||||
// currently only support "dartfmt -w yourcode.dart"
|
||||
String command = dartPostProcessFile + " " + file.toString();
|
||||
try {
|
||||
Process p = Runtime.getRuntime().exec(command);
|
||||
int exitValue = p.waitFor();
|
||||
if (exitValue != 0) {
|
||||
LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue);
|
||||
} else {
|
||||
LOGGER.info("Successfully executed: {}", command);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,8 @@ import java.util.*;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class DartDioClientCodegen extends DartClientCodegen {
|
||||
public class DartDioClientCodegen extends AbstractDartCodegen {
|
||||
|
||||
private final Logger LOGGER = LoggerFactory.getLogger(DartDioClientCodegen.class);
|
||||
|
||||
public static final String NULLABLE_FIELDS = "nullableFields";
|
||||
@ -149,7 +150,7 @@ public class DartDioClientCodegen extends DartClientCodegen {
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
defaultProcessOpts();
|
||||
super.processOpts();
|
||||
|
||||
if (StringUtils.isEmpty(System.getenv("DART_POST_PROCESS_FILE"))) {
|
||||
LOGGER.info("Environment variable DART_POST_PROCESS_FILE not defined so the Dart code may not be properly formatted. To define it, try `export DART_POST_PROCESS_FILE=\"/usr/local/bin/dartfmt -w\"` (Linux/Mac)");
|
||||
@ -163,49 +164,10 @@ public class DartDioClientCodegen extends DartClientCodegen {
|
||||
additionalProperties.put(NULLABLE_FIELDS, nullableFields);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(PUB_LIBRARY)) {
|
||||
this.setPubLibrary((String) additionalProperties.get(PUB_LIBRARY));
|
||||
} else {
|
||||
//not set, use to be passed to template
|
||||
additionalProperties.put(PUB_LIBRARY, pubLibrary);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(PUB_NAME)) {
|
||||
this.setPubName((String) additionalProperties.get(PUB_NAME));
|
||||
} else {
|
||||
//not set, use to be passed to template
|
||||
additionalProperties.put(PUB_NAME, pubName);
|
||||
}
|
||||
|
||||
if (!additionalProperties.containsKey(CLIENT_NAME)) {
|
||||
additionalProperties.put(CLIENT_NAME, org.openapitools.codegen.utils.StringUtils.camelize(pubName));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(PUB_VERSION)) {
|
||||
this.setPubVersion((String) additionalProperties.get(PUB_VERSION));
|
||||
} else {
|
||||
//not set, use to be passed to template
|
||||
additionalProperties.put(PUB_VERSION, pubVersion);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(PUB_DESCRIPTION)) {
|
||||
this.setPubDescription((String) additionalProperties.get(PUB_DESCRIPTION));
|
||||
} else {
|
||||
//not set, use to be passed to template
|
||||
additionalProperties.put(PUB_DESCRIPTION, pubDescription);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(USE_ENUM_EXTENSION)) {
|
||||
this.setUseEnumExtension(convertPropertyToBooleanAndWriteBack(USE_ENUM_EXTENSION));
|
||||
} else {
|
||||
// Not set, use to be passed to template.
|
||||
additionalProperties.put(USE_ENUM_EXTENSION, useEnumExtension);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) {
|
||||
this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(DATE_LIBRARY)) {
|
||||
this.setDateLibrary(additionalProperties.get(DATE_LIBRARY).toString());
|
||||
}
|
||||
|
@ -32,7 +32,8 @@ import java.util.*;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class DartJaguarClientCodegen extends DartClientCodegen {
|
||||
public class DartJaguarClientCodegen extends AbstractDartCodegen {
|
||||
|
||||
private final Logger LOGGER = LoggerFactory.getLogger(DartJaguarClientCodegen.class);
|
||||
|
||||
private static final String NULLABLE_FIELDS = "nullableFields";
|
||||
@ -150,7 +151,8 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
defaultProcessOpts();
|
||||
super.processOpts();
|
||||
|
||||
if (additionalProperties.containsKey(NULLABLE_FIELDS)) {
|
||||
nullableFields = convertPropertyToBooleanAndWriteBack(NULLABLE_FIELDS);
|
||||
} else {
|
||||
@ -172,35 +174,8 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
|
||||
additionalProperties.put(IS_FORMAT_PROTO, false);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(PUB_LIBRARY)) {
|
||||
this.setPubLibrary((String) additionalProperties.get(PUB_LIBRARY));
|
||||
} else {
|
||||
//not set, use to be passed to template
|
||||
additionalProperties.put(PUB_LIBRARY, pubLibrary);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(PUB_NAME)) {
|
||||
this.setPubName((String) additionalProperties.get(PUB_NAME));
|
||||
} else {
|
||||
//not set, use to be passed to template
|
||||
additionalProperties.put(PUB_NAME, pubName);
|
||||
}
|
||||
additionalProperties.put(CLIENT_NAME, org.openapitools.codegen.utils.StringUtils.camelize(pubName));
|
||||
|
||||
if (additionalProperties.containsKey(PUB_VERSION)) {
|
||||
this.setPubVersion((String) additionalProperties.get(PUB_VERSION));
|
||||
} else {
|
||||
//not set, use to be passed to template
|
||||
additionalProperties.put(PUB_VERSION, pubVersion);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(PUB_DESCRIPTION)) {
|
||||
this.setPubDescription((String) additionalProperties.get(PUB_DESCRIPTION));
|
||||
} else {
|
||||
//not set, use to be passed to template
|
||||
additionalProperties.put(PUB_DESCRIPTION, pubDescription);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(USE_ENUM_EXTENSION)) {
|
||||
this.setUseEnumExtension(convertPropertyToBooleanAndWriteBack(USE_ENUM_EXTENSION));
|
||||
} else {
|
||||
@ -208,10 +183,6 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
|
||||
additionalProperties.put(USE_ENUM_EXTENSION, useEnumExtension);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) {
|
||||
this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER));
|
||||
}
|
||||
|
||||
// make api and model doc path available in mustache template
|
||||
additionalProperties.put("apiDocPath", apiDocPath);
|
||||
additionalProperties.put("modelDocPath", modelDocPath);
|
||||
|
@ -179,7 +179,8 @@ class ApiClient {
|
||||
{{#model}}
|
||||
case '{{{classname}}}':
|
||||
{{#isEnum}}
|
||||
return {{{classname}}}TypeTransformer().decode(value);
|
||||
{{#native_serialization}}return {{{classname}}}TypeTransformer().decode(value);{{/native_serialization}}
|
||||
{{#json_serializable}} return _$enumDecode(_${{{classname}}}EnumMap, value);{{/json_serializable}}
|
||||
{{/isEnum}}
|
||||
{{^isEnum}}
|
||||
return {{{classname}}}.fromJson(value);
|
||||
|
@ -53,7 +53,8 @@ String parameterToString(dynamic value) {
|
||||
{{#model}}
|
||||
{{#isEnum}}
|
||||
if (value is {{{classname}}}) {
|
||||
return {{{classname}}}TypeTransformer().encode(value).toString();
|
||||
{{#native_serialization}} return {{{classname}}}TypeTransformer().encode(value).toString();{{/native_serialization}}
|
||||
{{#json_serializable}} return _${{{classname}}}EnumMap[value];{{/json_serializable}}
|
||||
}
|
||||
{{/isEnum}}
|
||||
{{/model}}
|
||||
|
@ -7,7 +7,11 @@ import 'dart:io';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
{{#json_serializable}}
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
{{/json_serializable}}
|
||||
|
||||
part 'api_client.dart';
|
||||
part 'api_helper.dart';
|
||||
@ -22,6 +26,10 @@ part 'auth/http_bearer_auth.dart';
|
||||
{{/apis}}{{/apiInfo}}
|
||||
{{#models}}{{#model}}part 'model/{{{classFilename}}}.dart';
|
||||
{{/model}}{{/models}}
|
||||
|
||||
{{#json_serializable}}
|
||||
part 'api.g.dart';
|
||||
{{/json_serializable}}
|
||||
const _delimiters = {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'};
|
||||
const _dateEpochMarker = 'epoch';
|
||||
final _dateFormatter = DateFormat('yyyy-MM-dd');
|
||||
|
19
modules/openapi-generator/src/main/resources/dart2/build.yaml.mustache
vendored
Normal file
19
modules/openapi-generator/src/main/resources/dart2/build.yaml.mustache
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
targets:
|
||||
$default:
|
||||
builders:
|
||||
json_serializable:
|
||||
options:
|
||||
# Options configure how source code is generated for every
|
||||
# `@JsonSerializable`-annotated class in the package.
|
||||
#
|
||||
# The default value for each is listed.
|
||||
any_map: false
|
||||
checked: true
|
||||
create_factory: true
|
||||
create_to_json: true
|
||||
disallow_unrecognized_keys: true
|
||||
explicit_to_json: true
|
||||
field_rename: none
|
||||
ignore_unannotated: false
|
||||
include_if_null: false
|
||||
nullable: true
|
@ -1,3 +1,11 @@
|
||||
{{#json_serializable}}
|
||||
@JsonSerializable(
|
||||
checked: true,
|
||||
createToJson: true,
|
||||
disallowUnrecognizedKeys: true,
|
||||
explicitToJson: true,
|
||||
)
|
||||
{{/json_serializable}}
|
||||
class {{{classname}}} {
|
||||
/// Returns a new [{{{classname}}}] instance.
|
||||
{{{classname}}}({
|
||||
@ -10,6 +18,7 @@ class {{{classname}}} {
|
||||
{{/vars}}
|
||||
});
|
||||
|
||||
{{^json_serializable}}
|
||||
{{#vars}}
|
||||
{{#description}}
|
||||
/// {{{description}}}
|
||||
@ -25,6 +34,34 @@ class {{{classname}}} {
|
||||
{{{datatypeWithEnum}}} {{{name}}};
|
||||
|
||||
{{/vars}}
|
||||
{{/json_serializable}}
|
||||
{{#json_serializable}}
|
||||
{{#vars}}
|
||||
{{#description}}
|
||||
/// {{{description}}}
|
||||
{{/description}}
|
||||
{{^isEnum}}
|
||||
{{#minimum}}
|
||||
// minimum: {{{minimum}}}
|
||||
{{/minimum}}
|
||||
{{#maximum}}
|
||||
// maximum: {{{maximum}}}
|
||||
{{/maximum}}
|
||||
{{/isEnum}}
|
||||
{{^isBinary}}
|
||||
@JsonKey(
|
||||
nullable: {{#nullable}}true{{/nullable}}{{^nullable}}false{{/nullable}},
|
||||
name: r'{{{baseName}}}',
|
||||
required: {{#required}}true{{/required}}{{^required}}false{{/required}},
|
||||
)
|
||||
{{/isBinary}}
|
||||
{{#isBinary}}
|
||||
@JsonKey(ignore: true)
|
||||
{{/isBinary}}
|
||||
{{{datatypeWithEnum}}} {{{name}}};
|
||||
|
||||
{{/vars}}
|
||||
{{/json_serializable}}
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is {{{classname}}} &&
|
||||
{{#vars}}
|
||||
@ -37,6 +74,7 @@ class {{{classname}}} {
|
||||
({{{name}}} == null ? 0 : {{{name}}}.hashCode){{^-last}} +{{/-last}}{{#-last}};{{/-last}}
|
||||
{{/vars}}
|
||||
|
||||
{{^json_serializable}}
|
||||
@override
|
||||
String toString() => '{{{classname}}}[{{#vars}}{{{name}}}=${{{name}}}{{^-last}}, {{/-last}}{{/vars}}]';
|
||||
|
||||
@ -218,6 +256,19 @@ class {{{classname}}} {
|
||||
}
|
||||
return map;
|
||||
}
|
||||
{{/json_serializable}}
|
||||
{{#json_serializable}}
|
||||
|
||||
factory {{{classname}}}.fromJson(Map<String, dynamic> json) => _${{{classname}}}FromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _${{{classname}}}ToJson(this);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return toJson().toString();
|
||||
}
|
||||
|
||||
{{/json_serializable}}
|
||||
}
|
||||
{{#vars}}
|
||||
{{#isEnum}}
|
||||
@ -232,4 +283,4 @@ class {{{classname}}} {
|
||||
{{/mostInnerItems}}
|
||||
{{/isContainer}}
|
||||
{{/isEnum}}
|
||||
{{/vars}}
|
||||
{{/vars}}
|
@ -1,4 +1,5 @@
|
||||
{{#description}}/// {{{description}}}{{/description}}
|
||||
{{^json_serializable}}
|
||||
class {{{classname}}} {
|
||||
/// Instantiate a new enum with the provided [value].
|
||||
const {{{classname}}}._(this.value);
|
||||
@ -71,4 +72,12 @@ class {{{classname}}}TypeTransformer {
|
||||
|
||||
/// Singleton [{{{classname}}}TypeTransformer] instance.
|
||||
static {{{classname}}}TypeTransformer _instance;
|
||||
}
|
||||
}{{/json_serializable}}{{#json_serializable}}
|
||||
enum {{{classname}}} {
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
{{{name}}},
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
}
|
||||
{{/json_serializable}}
|
@ -1,4 +1,5 @@
|
||||
{{#description}}/// {{{description}}}{{/description}}
|
||||
{{^json_serializable}}
|
||||
class {{{enumName}}} {
|
||||
/// Instantiate a new enum with the provided [value].
|
||||
const {{{enumName}}}._(this.value);
|
||||
@ -71,4 +72,11 @@ class {{{enumName}}}TypeTransformer {
|
||||
|
||||
/// Singleton [{{{enumName}}}TypeTransformer] instance.
|
||||
static {{{enumName}}}TypeTransformer _instance;
|
||||
}
|
||||
}{{/json_serializable}}{{#json_serializable}}
|
||||
enum {{{enumName}}} {
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
{{{name}}},
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
}{{/json_serializable}}
|
@ -14,5 +14,10 @@ dependencies:
|
||||
http: '>=0.12.0 <0.13.0'
|
||||
intl: '^0.16.1'
|
||||
meta: '^1.1.8'
|
||||
{{#json_serializable}}
|
||||
json_annotation: '^3.1.1'{{/json_serializable}}
|
||||
dev_dependencies:
|
||||
test: '>=1.3.0 <1.16.0'
|
||||
{{#json_serializable}}
|
||||
build_runner: '^1.0.0'
|
||||
json_serializable: '^3.5.1'{{/json_serializable}}
|
||||
|
@ -64,6 +64,7 @@ public class DartClientOptionsProvider implements OptionsProvider {
|
||||
.put(CodegenConstants.PREPEND_FORM_OR_BODY_PARAMETERS, PREPEND_FORM_OR_BODY_PARAMETERS_VALUE)
|
||||
.put(CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR, "true")
|
||||
.put(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT, "true")
|
||||
.put("serializationLibrary", "custom")
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ import 'dart:io';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
part 'api_client.dart';
|
||||
@ -37,6 +38,7 @@ part 'model/pet.dart';
|
||||
part 'model/tag.dart';
|
||||
part 'model/user.dart';
|
||||
|
||||
|
||||
const _delimiters = {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'};
|
||||
const _dateEpochMarker = 'epoch';
|
||||
final _dateFormatter = DateFormat('yyyy-MM-dd');
|
||||
|
@ -14,5 +14,7 @@ dependencies:
|
||||
http: '>=0.12.0 <0.13.0'
|
||||
intl: '^0.16.1'
|
||||
meta: '^1.1.8'
|
||||
|
||||
dev_dependencies:
|
||||
test: '>=1.3.0 <1.16.0'
|
||||
|
||||
|
@ -15,6 +15,7 @@ import 'dart:io';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
part 'api_client.dart';
|
||||
@ -37,6 +38,7 @@ part 'model/pet.dart';
|
||||
part 'model/tag.dart';
|
||||
part 'model/user.dart';
|
||||
|
||||
|
||||
const _delimiters = {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'};
|
||||
const _dateEpochMarker = 'epoch';
|
||||
final _dateFormatter = DateFormat('yyyy-MM-dd');
|
||||
|
@ -14,5 +14,7 @@ dependencies:
|
||||
http: '>=0.12.0 <0.13.0'
|
||||
intl: '^0.16.1'
|
||||
meta: '^1.1.8'
|
||||
|
||||
dev_dependencies:
|
||||
test: '>=1.3.0 <1.16.0'
|
||||
|
||||
|
@ -15,6 +15,7 @@ import 'dart:io';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
part 'api_client.dart';
|
||||
@ -78,6 +79,7 @@ part 'model/special_model_name.dart';
|
||||
part 'model/tag.dart';
|
||||
part 'model/user.dart';
|
||||
|
||||
|
||||
const _delimiters = {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'};
|
||||
const _dateEpochMarker = 'epoch';
|
||||
final _dateFormatter = DateFormat('yyyy-MM-dd');
|
||||
|
@ -201,6 +201,7 @@ class ApiClient {
|
||||
return EnumArrays.fromJson(value);
|
||||
case 'EnumClass':
|
||||
return EnumClassTypeTransformer().decode(value);
|
||||
|
||||
case 'EnumTest':
|
||||
return EnumTest.fromJson(value);
|
||||
case 'FileSchemaTestClass':
|
||||
@ -241,12 +242,16 @@ class ApiClient {
|
||||
return OuterComposite.fromJson(value);
|
||||
case 'OuterEnum':
|
||||
return OuterEnumTypeTransformer().decode(value);
|
||||
|
||||
case 'OuterEnumDefaultValue':
|
||||
return OuterEnumDefaultValueTypeTransformer().decode(value);
|
||||
|
||||
case 'OuterEnumInteger':
|
||||
return OuterEnumIntegerTypeTransformer().decode(value);
|
||||
|
||||
case 'OuterEnumIntegerDefaultValue':
|
||||
return OuterEnumIntegerDefaultValueTypeTransformer().decode(value);
|
||||
|
||||
case 'Pet':
|
||||
return Pet.fromJson(value);
|
||||
case 'ReadOnlyFirst':
|
||||
|
@ -60,18 +60,23 @@ String parameterToString(dynamic value) {
|
||||
}
|
||||
if (value is EnumClass) {
|
||||
return EnumClassTypeTransformer().encode(value).toString();
|
||||
|
||||
}
|
||||
if (value is OuterEnum) {
|
||||
return OuterEnumTypeTransformer().encode(value).toString();
|
||||
|
||||
}
|
||||
if (value is OuterEnumDefaultValue) {
|
||||
return OuterEnumDefaultValueTypeTransformer().encode(value).toString();
|
||||
|
||||
}
|
||||
if (value is OuterEnumInteger) {
|
||||
return OuterEnumIntegerTypeTransformer().encode(value).toString();
|
||||
|
||||
}
|
||||
if (value is OuterEnumIntegerDefaultValue) {
|
||||
return OuterEnumIntegerDefaultValueTypeTransformer().encode(value).toString();
|
||||
|
||||
}
|
||||
return value.toString();
|
||||
}
|
||||
|
@ -14,5 +14,7 @@ dependencies:
|
||||
http: '>=0.12.0 <0.13.0'
|
||||
intl: '^0.16.1'
|
||||
meta: '^1.1.8'
|
||||
|
||||
dev_dependencies:
|
||||
test: '>=1.3.0 <1.16.0'
|
||||
|
||||
|
27
samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/.gitignore
vendored
Normal file
27
samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/.gitignore
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
# See https://www.dartlang.org/tools/private-files.html
|
||||
|
||||
# Files and directories created by pub
|
||||
.buildlog
|
||||
.packages
|
||||
.project
|
||||
.pub/
|
||||
build/
|
||||
**/packages/
|
||||
|
||||
# Files created by dart2js
|
||||
# (Most Dart developers will use pub build to compile Dart, use/modify these
|
||||
# rules if you intend to use dart2js directly
|
||||
# Convention is to use extension '.dart.js' for Dart compiled to Javascript to
|
||||
# differentiate from explicit Javascript files)
|
||||
*.dart.js
|
||||
*.part.js
|
||||
*.js.deps
|
||||
*.js.map
|
||||
*.info.json
|
||||
|
||||
# Directory created by dartdoc
|
||||
doc/api/
|
||||
|
||||
# Don't commit pubspec lock file
|
||||
# (Library packages only! Remove pattern if developing an application package)
|
||||
pubspec.lock
|
@ -0,0 +1,23 @@
|
||||
# OpenAPI Generator Ignore
|
||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
@ -0,0 +1,115 @@
|
||||
.gitignore
|
||||
.travis.yml
|
||||
README.md
|
||||
build.yaml
|
||||
doc/AdditionalPropertiesClass.md
|
||||
doc/Animal.md
|
||||
doc/AnotherFakeApi.md
|
||||
doc/ApiResponse.md
|
||||
doc/ArrayOfArrayOfNumberOnly.md
|
||||
doc/ArrayOfNumberOnly.md
|
||||
doc/ArrayTest.md
|
||||
doc/Capitalization.md
|
||||
doc/Cat.md
|
||||
doc/CatAllOf.md
|
||||
doc/Category.md
|
||||
doc/ClassModel.md
|
||||
doc/DefaultApi.md
|
||||
doc/Dog.md
|
||||
doc/DogAllOf.md
|
||||
doc/EnumArrays.md
|
||||
doc/EnumClass.md
|
||||
doc/EnumTest.md
|
||||
doc/FakeApi.md
|
||||
doc/FakeClassnameTags123Api.md
|
||||
doc/FileSchemaTestClass.md
|
||||
doc/Foo.md
|
||||
doc/FormatTest.md
|
||||
doc/HasOnlyReadOnly.md
|
||||
doc/HealthCheckResult.md
|
||||
doc/InlineResponseDefault.md
|
||||
doc/MapTest.md
|
||||
doc/MixedPropertiesAndAdditionalPropertiesClass.md
|
||||
doc/Model200Response.md
|
||||
doc/ModelClient.md
|
||||
doc/ModelFile.md
|
||||
doc/ModelList.md
|
||||
doc/ModelReturn.md
|
||||
doc/Name.md
|
||||
doc/NullableClass.md
|
||||
doc/NumberOnly.md
|
||||
doc/Order.md
|
||||
doc/OuterComposite.md
|
||||
doc/OuterEnum.md
|
||||
doc/OuterEnumDefaultValue.md
|
||||
doc/OuterEnumInteger.md
|
||||
doc/OuterEnumIntegerDefaultValue.md
|
||||
doc/Pet.md
|
||||
doc/PetApi.md
|
||||
doc/ReadOnlyFirst.md
|
||||
doc/SpecialModelName.md
|
||||
doc/StoreApi.md
|
||||
doc/Tag.md
|
||||
doc/User.md
|
||||
doc/UserApi.md
|
||||
git_push.sh
|
||||
lib/api.dart
|
||||
lib/api/another_fake_api.dart
|
||||
lib/api/default_api.dart
|
||||
lib/api/fake_api.dart
|
||||
lib/api/fake_classname_tags123_api.dart
|
||||
lib/api/pet_api.dart
|
||||
lib/api/store_api.dart
|
||||
lib/api/user_api.dart
|
||||
lib/api_client.dart
|
||||
lib/api_exception.dart
|
||||
lib/api_helper.dart
|
||||
lib/auth/api_key_auth.dart
|
||||
lib/auth/authentication.dart
|
||||
lib/auth/http_basic_auth.dart
|
||||
lib/auth/http_bearer_auth.dart
|
||||
lib/auth/oauth.dart
|
||||
lib/model/additional_properties_class.dart
|
||||
lib/model/animal.dart
|
||||
lib/model/api_response.dart
|
||||
lib/model/array_of_array_of_number_only.dart
|
||||
lib/model/array_of_number_only.dart
|
||||
lib/model/array_test.dart
|
||||
lib/model/capitalization.dart
|
||||
lib/model/cat.dart
|
||||
lib/model/cat_all_of.dart
|
||||
lib/model/category.dart
|
||||
lib/model/class_model.dart
|
||||
lib/model/dog.dart
|
||||
lib/model/dog_all_of.dart
|
||||
lib/model/enum_arrays.dart
|
||||
lib/model/enum_class.dart
|
||||
lib/model/enum_test.dart
|
||||
lib/model/file_schema_test_class.dart
|
||||
lib/model/foo.dart
|
||||
lib/model/format_test.dart
|
||||
lib/model/has_only_read_only.dart
|
||||
lib/model/health_check_result.dart
|
||||
lib/model/inline_response_default.dart
|
||||
lib/model/map_test.dart
|
||||
lib/model/mixed_properties_and_additional_properties_class.dart
|
||||
lib/model/model200_response.dart
|
||||
lib/model/model_client.dart
|
||||
lib/model/model_file.dart
|
||||
lib/model/model_list.dart
|
||||
lib/model/model_return.dart
|
||||
lib/model/name.dart
|
||||
lib/model/nullable_class.dart
|
||||
lib/model/number_only.dart
|
||||
lib/model/order.dart
|
||||
lib/model/outer_composite.dart
|
||||
lib/model/outer_enum.dart
|
||||
lib/model/outer_enum_default_value.dart
|
||||
lib/model/outer_enum_integer.dart
|
||||
lib/model/outer_enum_integer_default_value.dart
|
||||
lib/model/pet.dart
|
||||
lib/model/read_only_first.dart
|
||||
lib/model/special_model_name.dart
|
||||
lib/model/tag.dart
|
||||
lib/model/user.dart
|
||||
pubspec.yaml
|
@ -0,0 +1 @@
|
||||
5.1.0-SNAPSHOT
|
@ -0,0 +1,14 @@
|
||||
#
|
||||
# AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
#
|
||||
# https://docs.travis-ci.com/user/languages/dart/
|
||||
#
|
||||
language: dart
|
||||
dart:
|
||||
# Install a specific stable release
|
||||
- "2.2.0"
|
||||
install:
|
||||
- pub get
|
||||
|
||||
script:
|
||||
- pub run test
|
@ -0,0 +1,189 @@
|
||||
# openapi
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
This Dart package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
|
||||
|
||||
- API version: 1.0.0
|
||||
- Build package: org.openapitools.codegen.languages.DartClientCodegen
|
||||
|
||||
## Requirements
|
||||
|
||||
Dart 2.0 or later
|
||||
|
||||
## Installation & Usage
|
||||
|
||||
### Github
|
||||
If this Dart package is published to Github, add the following dependency to your pubspec.yaml
|
||||
```
|
||||
dependencies:
|
||||
openapi:
|
||||
git: https://github.com/GIT_USER_ID/GIT_REPO_ID.git
|
||||
```
|
||||
|
||||
### Local
|
||||
To use the package in your local drive, add the following dependency to your pubspec.yaml
|
||||
```
|
||||
dependencies:
|
||||
openapi:
|
||||
path: /path/to/openapi
|
||||
```
|
||||
|
||||
## Tests
|
||||
|
||||
TODO
|
||||
|
||||
## Getting Started
|
||||
|
||||
Please follow the [installation procedure](#installation--usage) and then run the following:
|
||||
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
|
||||
final api_instance = AnotherFakeApi();
|
||||
final modelClient = ModelClient(); // ModelClient | client model
|
||||
|
||||
try {
|
||||
final result = api_instance.call123testSpecialTags(modelClient);
|
||||
print(result);
|
||||
} catch (e) {
|
||||
print('Exception when calling AnotherFakeApi->call123testSpecialTags: $e\n');
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Documentation for API Endpoints
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
*AnotherFakeApi* | [**call123testSpecialTags**](doc//AnotherFakeApi.md#call123testspecialtags) | **PATCH** /another-fake/dummy | To test special tags
|
||||
*DefaultApi* | [**fooGet**](doc//DefaultApi.md#fooget) | **GET** /foo |
|
||||
*FakeApi* | [**fakeHealthGet**](doc//FakeApi.md#fakehealthget) | **GET** /fake/health | Health check endpoint
|
||||
*FakeApi* | [**fakeHttpSignatureTest**](doc//FakeApi.md#fakehttpsignaturetest) | **GET** /fake/http-signature-test | test http signature authentication
|
||||
*FakeApi* | [**fakeOuterBooleanSerialize**](doc//FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean |
|
||||
*FakeApi* | [**fakeOuterCompositeSerialize**](doc//FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite |
|
||||
*FakeApi* | [**fakeOuterNumberSerialize**](doc//FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number |
|
||||
*FakeApi* | [**fakeOuterStringSerialize**](doc//FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string |
|
||||
*FakeApi* | [**testBodyWithFileSchema**](doc//FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema |
|
||||
*FakeApi* | [**testBodyWithQueryParams**](doc//FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params |
|
||||
*FakeApi* | [**testClientModel**](doc//FakeApi.md#testclientmodel) | **PATCH** /fake | To test \"client\" model
|
||||
*FakeApi* | [**testEndpointParameters**](doc//FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
*FakeApi* | [**testEnumParameters**](doc//FakeApi.md#testenumparameters) | **GET** /fake | To test enum parameters
|
||||
*FakeApi* | [**testGroupParameters**](doc//FakeApi.md#testgroupparameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional)
|
||||
*FakeApi* | [**testInlineAdditionalProperties**](doc//FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties
|
||||
*FakeApi* | [**testJsonFormData**](doc//FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data
|
||||
*FakeApi* | [**testQueryParameterCollectionFormat**](doc//FakeApi.md#testqueryparametercollectionformat) | **PUT** /fake/test-query-paramters |
|
||||
*FakeClassnameTags123Api* | [**testClassname**](doc//FakeClassnameTags123Api.md#testclassname) | **PATCH** /fake_classname_test | To test class name in snake case
|
||||
*PetApi* | [**addPet**](doc//PetApi.md#addpet) | **POST** /pet | Add a new pet to the store
|
||||
*PetApi* | [**deletePet**](doc//PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet
|
||||
*PetApi* | [**findPetsByStatus**](doc//PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status
|
||||
*PetApi* | [**findPetsByTags**](doc//PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags
|
||||
*PetApi* | [**getPetById**](doc//PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID
|
||||
*PetApi* | [**updatePet**](doc//PetApi.md#updatepet) | **PUT** /pet | Update an existing pet
|
||||
*PetApi* | [**updatePetWithForm**](doc//PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data
|
||||
*PetApi* | [**uploadFile**](doc//PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image
|
||||
*PetApi* | [**uploadFileWithRequiredFile**](doc//PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required)
|
||||
*StoreApi* | [**deleteOrder**](doc//StoreApi.md#deleteorder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID
|
||||
*StoreApi* | [**getInventory**](doc//StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status
|
||||
*StoreApi* | [**getOrderById**](doc//StoreApi.md#getorderbyid) | **GET** /store/order/{order_id} | Find purchase order by ID
|
||||
*StoreApi* | [**placeOrder**](doc//StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet
|
||||
*UserApi* | [**createUser**](doc//UserApi.md#createuser) | **POST** /user | Create user
|
||||
*UserApi* | [**createUsersWithArrayInput**](doc//UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array
|
||||
*UserApi* | [**createUsersWithListInput**](doc//UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array
|
||||
*UserApi* | [**deleteUser**](doc//UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user
|
||||
*UserApi* | [**getUserByName**](doc//UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name
|
||||
*UserApi* | [**loginUser**](doc//UserApi.md#loginuser) | **GET** /user/login | Logs user into the system
|
||||
*UserApi* | [**logoutUser**](doc//UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session
|
||||
*UserApi* | [**updateUser**](doc//UserApi.md#updateuser) | **PUT** /user/{username} | Updated user
|
||||
|
||||
|
||||
## Documentation For Models
|
||||
|
||||
- [AdditionalPropertiesClass](doc//AdditionalPropertiesClass.md)
|
||||
- [Animal](doc//Animal.md)
|
||||
- [ApiResponse](doc//ApiResponse.md)
|
||||
- [ArrayOfArrayOfNumberOnly](doc//ArrayOfArrayOfNumberOnly.md)
|
||||
- [ArrayOfNumberOnly](doc//ArrayOfNumberOnly.md)
|
||||
- [ArrayTest](doc//ArrayTest.md)
|
||||
- [Capitalization](doc//Capitalization.md)
|
||||
- [Cat](doc//Cat.md)
|
||||
- [CatAllOf](doc//CatAllOf.md)
|
||||
- [Category](doc//Category.md)
|
||||
- [ClassModel](doc//ClassModel.md)
|
||||
- [Dog](doc//Dog.md)
|
||||
- [DogAllOf](doc//DogAllOf.md)
|
||||
- [EnumArrays](doc//EnumArrays.md)
|
||||
- [EnumClass](doc//EnumClass.md)
|
||||
- [EnumTest](doc//EnumTest.md)
|
||||
- [FileSchemaTestClass](doc//FileSchemaTestClass.md)
|
||||
- [Foo](doc//Foo.md)
|
||||
- [FormatTest](doc//FormatTest.md)
|
||||
- [HasOnlyReadOnly](doc//HasOnlyReadOnly.md)
|
||||
- [HealthCheckResult](doc//HealthCheckResult.md)
|
||||
- [InlineResponseDefault](doc//InlineResponseDefault.md)
|
||||
- [MapTest](doc//MapTest.md)
|
||||
- [MixedPropertiesAndAdditionalPropertiesClass](doc//MixedPropertiesAndAdditionalPropertiesClass.md)
|
||||
- [Model200Response](doc//Model200Response.md)
|
||||
- [ModelClient](doc//ModelClient.md)
|
||||
- [ModelFile](doc//ModelFile.md)
|
||||
- [ModelList](doc//ModelList.md)
|
||||
- [ModelReturn](doc//ModelReturn.md)
|
||||
- [Name](doc//Name.md)
|
||||
- [NullableClass](doc//NullableClass.md)
|
||||
- [NumberOnly](doc//NumberOnly.md)
|
||||
- [Order](doc//Order.md)
|
||||
- [OuterComposite](doc//OuterComposite.md)
|
||||
- [OuterEnum](doc//OuterEnum.md)
|
||||
- [OuterEnumDefaultValue](doc//OuterEnumDefaultValue.md)
|
||||
- [OuterEnumInteger](doc//OuterEnumInteger.md)
|
||||
- [OuterEnumIntegerDefaultValue](doc//OuterEnumIntegerDefaultValue.md)
|
||||
- [Pet](doc//Pet.md)
|
||||
- [ReadOnlyFirst](doc//ReadOnlyFirst.md)
|
||||
- [SpecialModelName](doc//SpecialModelName.md)
|
||||
- [Tag](doc//Tag.md)
|
||||
- [User](doc//User.md)
|
||||
|
||||
|
||||
## Documentation For Authorization
|
||||
|
||||
|
||||
## api_key
|
||||
|
||||
- **Type**: API key
|
||||
- **API key parameter name**: api_key
|
||||
- **Location**: HTTP header
|
||||
|
||||
## api_key_query
|
||||
|
||||
- **Type**: API key
|
||||
- **API key parameter name**: api_key_query
|
||||
- **Location**: URL query string
|
||||
|
||||
## bearer_test
|
||||
|
||||
- **Type**: HTTP Bearer authentication
|
||||
|
||||
## http_basic_test
|
||||
|
||||
- **Type**: HTTP Basic authentication
|
||||
|
||||
## http_signature_test
|
||||
|
||||
|
||||
## petstore_auth
|
||||
|
||||
- **Type**: OAuth
|
||||
- **Flow**: implicit
|
||||
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
|
||||
- **Scopes**:
|
||||
- **write:pets**: modify pets in your account
|
||||
- **read:pets**: read your pets
|
||||
|
||||
|
||||
## Author
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,19 @@
|
||||
targets:
|
||||
$default:
|
||||
builders:
|
||||
json_serializable:
|
||||
options:
|
||||
# Options configure how source code is generated for every
|
||||
# `@JsonSerializable`-annotated class in the package.
|
||||
#
|
||||
# The default value for each is listed.
|
||||
any_map: false
|
||||
checked: true
|
||||
create_factory: true
|
||||
create_to_json: true
|
||||
disallow_unrecognized_keys: true
|
||||
explicit_to_json: true
|
||||
field_rename: none
|
||||
ignore_unannotated: false
|
||||
include_if_null: false
|
||||
nullable: true
|
@ -0,0 +1,16 @@
|
||||
# openapi.model.AdditionalPropertiesClass
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**mapProperty** | **Map<String, String>** | | [optional] [default to const {}]
|
||||
**mapOfMapProperty** | [**Map<String, Map<String, String>>**](Map.md) | | [optional] [default to const {}]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,16 @@
|
||||
# openapi.model.Animal
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**className** | **String** | |
|
||||
**color** | **String** | | [optional] [default to '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)
|
||||
|
||||
|
@ -0,0 +1,57 @@
|
||||
# openapi.api.AnotherFakeApi
|
||||
|
||||
## Load the API package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**call123testSpecialTags**](AnotherFakeApi.md#call123testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags
|
||||
|
||||
|
||||
# **call123testSpecialTags**
|
||||
> ModelClient call123testSpecialTags(modelClient)
|
||||
|
||||
To test special tags
|
||||
|
||||
To test special tags and operation ID starting with number
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final api_instance = AnotherFakeApi();
|
||||
final modelClient = ModelClient(); // ModelClient | client model
|
||||
|
||||
try {
|
||||
final result = api_instance.call123testSpecialTags(modelClient);
|
||||
print(result);
|
||||
} catch (e) {
|
||||
print('Exception when calling AnotherFakeApi->call123testSpecialTags: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**modelClient** | [**ModelClient**](ModelClient.md)| client model |
|
||||
|
||||
### Return type
|
||||
|
||||
[**ModelClient**](ModelClient.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: application/json
|
||||
|
||||
[[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)
|
||||
|
@ -0,0 +1,17 @@
|
||||
# openapi.model.ApiResponse
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**code** | **int** | | [optional]
|
||||
**type** | **String** | | [optional]
|
||||
**message** | **String** | | [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)
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
# openapi.model.ArrayOfArrayOfNumberOnly
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**arrayArrayNumber** | [**List<List<num>>**](List.md) | | [optional] [default to const []]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
# openapi.model.ArrayOfNumberOnly
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**arrayNumber** | **List<num>** | | [optional] [default to const []]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
# openapi.model.ArrayTest
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**arrayOfString** | **List<String>** | | [optional] [default to const []]
|
||||
**arrayArrayOfInteger** | [**List<List<int>>**](List.md) | | [optional] [default to const []]
|
||||
**arrayArrayOfModel** | [**List<List<ReadOnlyFirst>>**](List.md) | | [optional] [default to const []]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,20 @@
|
||||
# openapi.model.Capitalization
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**smallCamel** | **String** | | [optional]
|
||||
**capitalCamel** | **String** | | [optional]
|
||||
**smallSnake** | **String** | | [optional]
|
||||
**capitalSnake** | **String** | | [optional]
|
||||
**sCAETHFlowPoints** | **String** | | [optional]
|
||||
**ATT_NAME** | **String** | Name of the pet | [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)
|
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
# openapi.model.Cat
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**className** | **String** | |
|
||||
**color** | **String** | | [optional] [default to 'red']
|
||||
**declawed** | **bool** | | [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)
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
# openapi.model.CatAllOf
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**declawed** | **bool** | | [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)
|
||||
|
||||
|
@ -0,0 +1,16 @@
|
||||
# openapi.model.Category
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**id** | **int** | | [optional]
|
||||
**name** | **String** | | [default to 'default-name']
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
# openapi.model.ClassModel
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**class_** | **String** | | [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)
|
||||
|
||||
|
@ -0,0 +1,51 @@
|
||||
# openapi.api.DefaultApi
|
||||
|
||||
## Load the API package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**fooGet**](DefaultApi.md#fooGet) | **GET** /foo |
|
||||
|
||||
|
||||
# **fooGet**
|
||||
> InlineResponseDefault fooGet()
|
||||
|
||||
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final api_instance = DefaultApi();
|
||||
|
||||
try {
|
||||
final result = api_instance.fooGet();
|
||||
print(result);
|
||||
} catch (e) {
|
||||
print('Exception when calling DefaultApi->fooGet: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
[**InlineResponseDefault**](InlineResponseDefault.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json
|
||||
|
||||
[[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)
|
||||
|
@ -0,0 +1,17 @@
|
||||
# openapi.model.Dog
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**className** | **String** | |
|
||||
**color** | **String** | | [optional] [default to 'red']
|
||||
**breed** | **String** | | [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)
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
# openapi.model.DogAllOf
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**breed** | **String** | | [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)
|
||||
|
||||
|
@ -0,0 +1,16 @@
|
||||
# openapi.model.EnumArrays
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**justSymbol** | **String** | | [optional]
|
||||
**arrayEnum** | **List<String>** | | [optional] [default to const []]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,14 @@
|
||||
# openapi.model.EnumClass
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,22 @@
|
||||
# openapi.model.EnumTest
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**enumString** | **String** | | [optional]
|
||||
**enumStringRequired** | **String** | |
|
||||
**enumInteger** | **int** | | [optional]
|
||||
**enumNumber** | **double** | | [optional]
|
||||
**outerEnum** | [**OuterEnum**](OuterEnum.md) | | [optional]
|
||||
**outerEnumInteger** | [**OuterEnumInteger**](OuterEnumInteger.md) | | [optional]
|
||||
**outerEnumDefaultValue** | [**OuterEnumDefaultValue**](OuterEnumDefaultValue.md) | | [optional]
|
||||
**outerEnumIntegerDefaultValue** | [**OuterEnumIntegerDefaultValue**](OuterEnumIntegerDefaultValue.md) | | [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)
|
||||
|
||||
|
@ -0,0 +1,725 @@
|
||||
# openapi.api.FakeApi
|
||||
|
||||
## Load the API package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**fakeHealthGet**](FakeApi.md#fakeHealthGet) | **GET** /fake/health | Health check endpoint
|
||||
[**fakeHttpSignatureTest**](FakeApi.md#fakeHttpSignatureTest) | **GET** /fake/http-signature-test | test http signature authentication
|
||||
[**fakeOuterBooleanSerialize**](FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean |
|
||||
[**fakeOuterCompositeSerialize**](FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite |
|
||||
[**fakeOuterNumberSerialize**](FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number |
|
||||
[**fakeOuterStringSerialize**](FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string |
|
||||
[**testBodyWithFileSchema**](FakeApi.md#testBodyWithFileSchema) | **PUT** /fake/body-with-file-schema |
|
||||
[**testBodyWithQueryParams**](FakeApi.md#testBodyWithQueryParams) | **PUT** /fake/body-with-query-params |
|
||||
[**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model
|
||||
[**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
[**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters
|
||||
[**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional)
|
||||
[**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties
|
||||
[**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data
|
||||
[**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-paramters |
|
||||
|
||||
|
||||
# **fakeHealthGet**
|
||||
> HealthCheckResult fakeHealthGet()
|
||||
|
||||
Health check endpoint
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final api_instance = FakeApi();
|
||||
|
||||
try {
|
||||
final result = api_instance.fakeHealthGet();
|
||||
print(result);
|
||||
} catch (e) {
|
||||
print('Exception when calling FakeApi->fakeHealthGet: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
[**HealthCheckResult**](HealthCheckResult.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json
|
||||
|
||||
[[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)
|
||||
|
||||
# **fakeHttpSignatureTest**
|
||||
> fakeHttpSignatureTest(pet, query1, header1)
|
||||
|
||||
test http signature authentication
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final api_instance = FakeApi();
|
||||
final pet = Pet(); // Pet | Pet object that needs to be added to the store
|
||||
final query1 = query1_example; // String | query parameter
|
||||
final header1 = header1_example; // String | header parameter
|
||||
|
||||
try {
|
||||
api_instance.fakeHttpSignatureTest(pet, query1, header1);
|
||||
} catch (e) {
|
||||
print('Exception when calling FakeApi->fakeHttpSignatureTest: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
|
||||
**query1** | **String**| query parameter | [optional]
|
||||
**header1** | **String**| header parameter | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[http_signature_test](../README.md#http_signature_test)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json, application/xml
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[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)
|
||||
|
||||
# **fakeOuterBooleanSerialize**
|
||||
> bool fakeOuterBooleanSerialize(body)
|
||||
|
||||
|
||||
|
||||
Test serialization of outer boolean types
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final api_instance = FakeApi();
|
||||
final body = bool(); // bool | Input boolean as post body
|
||||
|
||||
try {
|
||||
final result = api_instance.fakeOuterBooleanSerialize(body);
|
||||
print(result);
|
||||
} catch (e) {
|
||||
print('Exception when calling FakeApi->fakeOuterBooleanSerialize: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | **bool**| Input boolean as post body | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
**bool**
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: */*
|
||||
|
||||
[[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)
|
||||
|
||||
# **fakeOuterCompositeSerialize**
|
||||
> OuterComposite fakeOuterCompositeSerialize(outerComposite)
|
||||
|
||||
|
||||
|
||||
Test serialization of object with outer number type
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final api_instance = FakeApi();
|
||||
final outerComposite = OuterComposite(); // OuterComposite | Input composite as post body
|
||||
|
||||
try {
|
||||
final result = api_instance.fakeOuterCompositeSerialize(outerComposite);
|
||||
print(result);
|
||||
} catch (e) {
|
||||
print('Exception when calling FakeApi->fakeOuterCompositeSerialize: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**outerComposite** | [**OuterComposite**](OuterComposite.md)| Input composite as post body | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
[**OuterComposite**](OuterComposite.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: */*
|
||||
|
||||
[[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)
|
||||
|
||||
# **fakeOuterNumberSerialize**
|
||||
> num fakeOuterNumberSerialize(body)
|
||||
|
||||
|
||||
|
||||
Test serialization of outer number types
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final api_instance = FakeApi();
|
||||
final body = num(); // num | Input number as post body
|
||||
|
||||
try {
|
||||
final result = api_instance.fakeOuterNumberSerialize(body);
|
||||
print(result);
|
||||
} catch (e) {
|
||||
print('Exception when calling FakeApi->fakeOuterNumberSerialize: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | **num**| Input number as post body | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
**num**
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: */*
|
||||
|
||||
[[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)
|
||||
|
||||
# **fakeOuterStringSerialize**
|
||||
> String fakeOuterStringSerialize(body)
|
||||
|
||||
|
||||
|
||||
Test serialization of outer string types
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final api_instance = FakeApi();
|
||||
final body = String(); // String | Input string as post body
|
||||
|
||||
try {
|
||||
final result = api_instance.fakeOuterStringSerialize(body);
|
||||
print(result);
|
||||
} catch (e) {
|
||||
print('Exception when calling FakeApi->fakeOuterStringSerialize: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | **String**| Input string as post body | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
**String**
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: */*
|
||||
|
||||
[[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)
|
||||
|
||||
# **testBodyWithFileSchema**
|
||||
> testBodyWithFileSchema(fileSchemaTestClass)
|
||||
|
||||
|
||||
|
||||
For this test, the body for this request much reference a schema named `File`.
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final api_instance = FakeApi();
|
||||
final fileSchemaTestClass = FileSchemaTestClass(); // FileSchemaTestClass |
|
||||
|
||||
try {
|
||||
api_instance.testBodyWithFileSchema(fileSchemaTestClass);
|
||||
} catch (e) {
|
||||
print('Exception when calling FakeApi->testBodyWithFileSchema: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**fileSchemaTestClass** | [**FileSchemaTestClass**](FileSchemaTestClass.md)| |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[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)
|
||||
|
||||
# **testBodyWithQueryParams**
|
||||
> testBodyWithQueryParams(query, user)
|
||||
|
||||
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final api_instance = FakeApi();
|
||||
final query = query_example; // String |
|
||||
final user = User(); // User |
|
||||
|
||||
try {
|
||||
api_instance.testBodyWithQueryParams(query, user);
|
||||
} catch (e) {
|
||||
print('Exception when calling FakeApi->testBodyWithQueryParams: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**query** | **String**| |
|
||||
**user** | [**User**](User.md)| |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[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)
|
||||
|
||||
# **testClientModel**
|
||||
> ModelClient testClientModel(modelClient)
|
||||
|
||||
To test \"client\" model
|
||||
|
||||
To test \"client\" model
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final api_instance = FakeApi();
|
||||
final modelClient = ModelClient(); // ModelClient | client model
|
||||
|
||||
try {
|
||||
final result = api_instance.testClientModel(modelClient);
|
||||
print(result);
|
||||
} catch (e) {
|
||||
print('Exception when calling FakeApi->testClientModel: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**modelClient** | [**ModelClient**](ModelClient.md)| client model |
|
||||
|
||||
### Return type
|
||||
|
||||
[**ModelClient**](ModelClient.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: application/json
|
||||
|
||||
[[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)
|
||||
|
||||
# **testEndpointParameters**
|
||||
> testEndpointParameters(number, double_, patternWithoutDelimiter, byte, integer, int32, int64, float, string, binary, date, dateTime, password, callback)
|
||||
|
||||
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
|
||||
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
// TODO Configure HTTP basic authorization: http_basic_test
|
||||
//defaultApiClient.getAuthentication<HttpBasicAuth>('http_basic_test').username = 'YOUR_USERNAME'
|
||||
//defaultApiClient.getAuthentication<HttpBasicAuth>('http_basic_test').password = 'YOUR_PASSWORD';
|
||||
|
||||
final api_instance = FakeApi();
|
||||
final number = 8.14; // num | None
|
||||
final double_ = 1.2; // double | None
|
||||
final patternWithoutDelimiter = patternWithoutDelimiter_example; // String | None
|
||||
final byte = BYTE_ARRAY_DATA_HERE; // String | None
|
||||
final integer = 56; // int | None
|
||||
final int32 = 56; // int | None
|
||||
final int64 = 789; // int | None
|
||||
final float = 3.4; // double | None
|
||||
final string = string_example; // String | None
|
||||
final binary = BINARY_DATA_HERE; // MultipartFile | None
|
||||
final date = 2013-10-20; // DateTime | None
|
||||
final dateTime = 2013-10-20T19:20:30+01:00; // DateTime | None
|
||||
final password = password_example; // String | None
|
||||
final callback = callback_example; // String | None
|
||||
|
||||
try {
|
||||
api_instance.testEndpointParameters(number, double_, patternWithoutDelimiter, byte, integer, int32, int64, float, string, binary, date, dateTime, password, callback);
|
||||
} catch (e) {
|
||||
print('Exception when calling FakeApi->testEndpointParameters: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**number** | **num**| None |
|
||||
**double_** | **double**| None |
|
||||
**patternWithoutDelimiter** | **String**| None |
|
||||
**byte** | **String**| None |
|
||||
**integer** | **int**| None | [optional]
|
||||
**int32** | **int**| None | [optional]
|
||||
**int64** | **int**| None | [optional]
|
||||
**float** | **double**| None | [optional]
|
||||
**string** | **String**| None | [optional]
|
||||
**binary** | **MultipartFile**| None | [optional]
|
||||
**date** | **DateTime**| None | [optional]
|
||||
**dateTime** | **DateTime**| None | [optional]
|
||||
**password** | **String**| None | [optional]
|
||||
**callback** | **String**| None | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[http_basic_test](../README.md#http_basic_test)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/x-www-form-urlencoded
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[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)
|
||||
|
||||
# **testEnumParameters**
|
||||
> testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString)
|
||||
|
||||
To test enum parameters
|
||||
|
||||
To test enum parameters
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final api_instance = FakeApi();
|
||||
final enumHeaderStringArray = []; // List<String> | Header parameter enum test (string array)
|
||||
final enumHeaderString = enumHeaderString_example; // String | Header parameter enum test (string)
|
||||
final enumQueryStringArray = []; // List<String> | Query parameter enum test (string array)
|
||||
final enumQueryString = enumQueryString_example; // String | Query parameter enum test (string)
|
||||
final enumQueryInteger = 56; // int | Query parameter enum test (double)
|
||||
final enumQueryDouble = 1.2; // double | Query parameter enum test (double)
|
||||
final enumFormStringArray = [enumFormStringArray_example]; // List<String> | Form parameter enum test (string array)
|
||||
final enumFormString = enumFormString_example; // String | Form parameter enum test (string)
|
||||
|
||||
try {
|
||||
api_instance.testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString);
|
||||
} catch (e) {
|
||||
print('Exception when calling FakeApi->testEnumParameters: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**enumHeaderStringArray** | [**List<String>**](String.md)| Header parameter enum test (string array) | [optional] [default to const []]
|
||||
**enumHeaderString** | **String**| Header parameter enum test (string) | [optional] [default to '-efg']
|
||||
**enumQueryStringArray** | [**List<String>**](String.md)| Query parameter enum test (string array) | [optional] [default to const []]
|
||||
**enumQueryString** | **String**| Query parameter enum test (string) | [optional] [default to '-efg']
|
||||
**enumQueryInteger** | **int**| Query parameter enum test (double) | [optional]
|
||||
**enumQueryDouble** | **double**| Query parameter enum test (double) | [optional]
|
||||
**enumFormStringArray** | [**List<String>**](String.md)| Form parameter enum test (string array) | [optional] [default to '$']
|
||||
**enumFormString** | **String**| Form parameter enum test (string) | [optional] [default to '-efg']
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/x-www-form-urlencoded
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[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)
|
||||
|
||||
# **testGroupParameters**
|
||||
> testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group)
|
||||
|
||||
Fake endpoint to test group parameters (optional)
|
||||
|
||||
Fake endpoint to test group parameters (optional)
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
// TODO Configure HTTP Bearer authorization: bearer_test
|
||||
// Case 1. Use String Token
|
||||
//defaultApiClient.getAuthentication<HttpBearerAuth>('bearer_test').setAccessToken('YOUR_ACCESS_TOKEN');
|
||||
// Case 2. Use Function which generate token.
|
||||
// String yourTokenGeneratorFunction() { ... }
|
||||
//defaultApiClient.getAuthentication<HttpBearerAuth>('bearer_test').setAccessToken(yourTokenGeneratorFunction);
|
||||
|
||||
final api_instance = FakeApi();
|
||||
final requiredStringGroup = 56; // int | Required String in group parameters
|
||||
final requiredBooleanGroup = true; // bool | Required Boolean in group parameters
|
||||
final requiredInt64Group = 789; // int | Required Integer in group parameters
|
||||
final stringGroup = 56; // int | String in group parameters
|
||||
final booleanGroup = true; // bool | Boolean in group parameters
|
||||
final int64Group = 789; // int | Integer in group parameters
|
||||
|
||||
try {
|
||||
api_instance.testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group);
|
||||
} catch (e) {
|
||||
print('Exception when calling FakeApi->testGroupParameters: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**requiredStringGroup** | **int**| Required String in group parameters |
|
||||
**requiredBooleanGroup** | **bool**| Required Boolean in group parameters |
|
||||
**requiredInt64Group** | **int**| Required Integer in group parameters |
|
||||
**stringGroup** | **int**| String in group parameters | [optional]
|
||||
**booleanGroup** | **bool**| Boolean in group parameters | [optional]
|
||||
**int64Group** | **int**| Integer in group parameters | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[bearer_test](../README.md#bearer_test)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[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)
|
||||
|
||||
# **testInlineAdditionalProperties**
|
||||
> testInlineAdditionalProperties(requestBody)
|
||||
|
||||
test inline additionalProperties
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final api_instance = FakeApi();
|
||||
final requestBody = Map<String, String>(); // Map<String, String> | request body
|
||||
|
||||
try {
|
||||
api_instance.testInlineAdditionalProperties(requestBody);
|
||||
} catch (e) {
|
||||
print('Exception when calling FakeApi->testInlineAdditionalProperties: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**requestBody** | [**Map<String, String>**](String.md)| request body |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[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)
|
||||
|
||||
# **testJsonFormData**
|
||||
> testJsonFormData(param, param2)
|
||||
|
||||
test json serialization of form data
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final api_instance = FakeApi();
|
||||
final param = param_example; // String | field1
|
||||
final param2 = param2_example; // String | field2
|
||||
|
||||
try {
|
||||
api_instance.testJsonFormData(param, param2);
|
||||
} catch (e) {
|
||||
print('Exception when calling FakeApi->testJsonFormData: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**param** | **String**| field1 |
|
||||
**param2** | **String**| field2 |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/x-www-form-urlencoded
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[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)
|
||||
|
||||
# **testQueryParameterCollectionFormat**
|
||||
> testQueryParameterCollectionFormat(pipe, ioutil, http, url, context)
|
||||
|
||||
|
||||
|
||||
To test the collection format in query parameters
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final api_instance = FakeApi();
|
||||
final pipe = []; // List<String> |
|
||||
final ioutil = []; // List<String> |
|
||||
final http = []; // List<String> |
|
||||
final url = []; // List<String> |
|
||||
final context = []; // List<String> |
|
||||
|
||||
try {
|
||||
api_instance.testQueryParameterCollectionFormat(pipe, ioutil, http, url, context);
|
||||
} catch (e) {
|
||||
print('Exception when calling FakeApi->testQueryParameterCollectionFormat: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**pipe** | [**List<String>**](String.md)| | [default to const []]
|
||||
**ioutil** | [**List<String>**](String.md)| | [default to const []]
|
||||
**http** | [**List<String>**](String.md)| | [default to const []]
|
||||
**url** | [**List<String>**](String.md)| | [default to const []]
|
||||
**context** | [**List<String>**](String.md)| | [default to const []]
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[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)
|
||||
|
@ -0,0 +1,61 @@
|
||||
# openapi.api.FakeClassnameTags123Api
|
||||
|
||||
## Load the API package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**testClassname**](FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case
|
||||
|
||||
|
||||
# **testClassname**
|
||||
> ModelClient testClassname(modelClient)
|
||||
|
||||
To test class name in snake case
|
||||
|
||||
To test class name in snake case
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
// TODO Configure API key authorization: api_key_query
|
||||
//defaultApiClient.getAuthentication<ApiKeyAuth>('api_key_query').apiKey = 'YOUR_API_KEY';
|
||||
// uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
||||
//defaultApiClient.getAuthentication<ApiKeyAuth>('api_key_query').apiKeyPrefix = 'Bearer';
|
||||
|
||||
final api_instance = FakeClassnameTags123Api();
|
||||
final modelClient = ModelClient(); // ModelClient | client model
|
||||
|
||||
try {
|
||||
final result = api_instance.testClassname(modelClient);
|
||||
print(result);
|
||||
} catch (e) {
|
||||
print('Exception when calling FakeClassnameTags123Api->testClassname: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**modelClient** | [**ModelClient**](ModelClient.md)| client model |
|
||||
|
||||
### Return type
|
||||
|
||||
[**ModelClient**](ModelClient.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[api_key_query](../README.md#api_key_query)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: application/json
|
||||
|
||||
[[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)
|
||||
|
@ -0,0 +1,16 @@
|
||||
# openapi.model.FileSchemaTestClass
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**file** | [**ModelFile**](ModelFile.md) | | [optional]
|
||||
**files** | [**List<ModelFile>**](ModelFile.md) | | [optional] [default to const []]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
# openapi.model.Foo
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**bar** | **String** | | [optional] [default to '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)
|
||||
|
||||
|
@ -0,0 +1,30 @@
|
||||
# openapi.model.FormatTest
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**integer** | **int** | | [optional]
|
||||
**int32** | **int** | | [optional]
|
||||
**int64** | **int** | | [optional]
|
||||
**number** | **num** | |
|
||||
**float** | **double** | | [optional]
|
||||
**double_** | **double** | | [optional]
|
||||
**decimal** | **double** | | [optional]
|
||||
**string** | **String** | | [optional]
|
||||
**byte** | **String** | |
|
||||
**binary** | [**MultipartFile**](MultipartFile.md) | | [optional]
|
||||
**date** | [**DateTime**](DateTime.md) | |
|
||||
**dateTime** | [**DateTime**](DateTime.md) | | [optional]
|
||||
**uuid** | **String** | | [optional]
|
||||
**password** | **String** | |
|
||||
**patternWithDigits** | **String** | A string that is a 10 digit number. Can have leading zeros. | [optional]
|
||||
**patternWithDigitsAndDelimiter** | **String** | A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. | [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)
|
||||
|
||||
|
@ -0,0 +1,16 @@
|
||||
# openapi.model.HasOnlyReadOnly
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**bar** | **String** | | [optional] [readonly]
|
||||
**foo** | **String** | | [optional] [readonly]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
# openapi.model.HealthCheckResult
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**nullableMessage** | **String** | | [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)
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
# openapi.model.InlineResponseDefault
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**string** | [**Foo**](Foo.md) | | [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)
|
||||
|
||||
|
@ -0,0 +1,18 @@
|
||||
# openapi.model.MapTest
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**mapMapOfString** | [**Map<String, Map<String, String>>**](Map.md) | | [optional] [default to const {}]
|
||||
**mapOfEnumString** | **Map<String, String>** | | [optional] [default to const {}]
|
||||
**directMap** | **Map<String, bool>** | | [optional] [default to const {}]
|
||||
**indirectMap** | **Map<String, bool>** | | [optional] [default to const {}]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
# openapi.model.MixedPropertiesAndAdditionalPropertiesClass
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**uuid** | **String** | | [optional]
|
||||
**dateTime** | [**DateTime**](DateTime.md) | | [optional]
|
||||
**map** | [**Map<String, Animal>**](Animal.md) | | [optional] [default to const {}]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,16 @@
|
||||
# openapi.model.Model200Response
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **int** | | [optional]
|
||||
**class_** | **String** | | [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)
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
# openapi.model.ModelClient
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**client** | **String** | | [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)
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
# openapi.model.ModelFile
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**sourceURI** | **String** | Test capitalization | [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)
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
# openapi.model.ModelList
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**n123list** | **String** | | [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)
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
# openapi.model.ModelReturn
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**return_** | **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)
|
||||
|
||||
|
@ -0,0 +1,18 @@
|
||||
# openapi.model.Name
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **int** | |
|
||||
**snakeCase** | **int** | | [optional] [readonly]
|
||||
**property** | **String** | | [optional]
|
||||
**n123number** | **int** | | [optional] [readonly]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,26 @@
|
||||
# openapi.model.NullableClass
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**integerProp** | **int** | | [optional]
|
||||
**numberProp** | **num** | | [optional]
|
||||
**booleanProp** | **bool** | | [optional]
|
||||
**stringProp** | **String** | | [optional]
|
||||
**dateProp** | [**DateTime**](DateTime.md) | | [optional]
|
||||
**datetimeProp** | [**DateTime**](DateTime.md) | | [optional]
|
||||
**arrayNullableProp** | [**List<Object>**](Object.md) | | [optional] [default to const []]
|
||||
**arrayAndItemsNullableProp** | [**List<Object>**](Object.md) | | [optional] [default to const []]
|
||||
**arrayItemsNullable** | [**List<Object>**](Object.md) | | [optional] [default to const []]
|
||||
**objectNullableProp** | [**Map<String, Object>**](Object.md) | | [optional] [default to const {}]
|
||||
**objectAndItemsNullableProp** | [**Map<String, Object>**](Object.md) | | [optional] [default to const {}]
|
||||
**objectItemsNullable** | [**Map<String, Object>**](Object.md) | | [optional] [default to const {}]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
# openapi.model.NumberOnly
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**justNumber** | **num** | | [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)
|
||||
|
||||
|
@ -0,0 +1,20 @@
|
||||
# openapi.model.Order
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**id** | **int** | | [optional]
|
||||
**petId** | **int** | | [optional]
|
||||
**quantity** | **int** | | [optional]
|
||||
**shipDate** | [**DateTime**](DateTime.md) | | [optional]
|
||||
**status** | **String** | Order Status | [optional]
|
||||
**complete** | **bool** | | [optional] [default to false]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
# openapi.model.OuterComposite
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**myNumber** | **num** | | [optional]
|
||||
**myString** | **String** | | [optional]
|
||||
**myBoolean** | **bool** | | [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)
|
||||
|
||||
|
@ -0,0 +1,14 @@
|
||||
# openapi.model.OuterEnum
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,14 @@
|
||||
# openapi.model.OuterEnumDefaultValue
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,14 @@
|
||||
# openapi.model.OuterEnumInteger
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,14 @@
|
||||
# openapi.model.OuterEnumIntegerDefaultValue
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,20 @@
|
||||
# openapi.model.Pet
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**id** | **int** | | [optional]
|
||||
**category** | [**Category**](Category.md) | | [optional]
|
||||
**name** | **String** | |
|
||||
**photoUrls** | **Set<String>** | | [default to const {}]
|
||||
**tags** | [**List<Tag>**](Tag.md) | | [optional] [default to const []]
|
||||
**status** | **String** | pet status in the store | [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)
|
||||
|
||||
|
@ -0,0 +1,427 @@
|
||||
# openapi.api.PetApi
|
||||
|
||||
## Load the API package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store
|
||||
[**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet
|
||||
[**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status
|
||||
[**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags
|
||||
[**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID
|
||||
[**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet
|
||||
[**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data
|
||||
[**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image
|
||||
[**uploadFileWithRequiredFile**](PetApi.md#uploadFileWithRequiredFile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required)
|
||||
|
||||
|
||||
# **addPet**
|
||||
> addPet(pet)
|
||||
|
||||
Add a new pet to the store
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
// TODO Configure OAuth2 access token for authorization: petstore_auth
|
||||
//defaultApiClient.getAuthentication<OAuth>('petstore_auth').accessToken = 'YOUR_ACCESS_TOKEN';
|
||||
|
||||
final api_instance = PetApi();
|
||||
final pet = Pet(); // Pet | Pet object that needs to be added to the store
|
||||
|
||||
try {
|
||||
api_instance.addPet(pet);
|
||||
} catch (e) {
|
||||
print('Exception when calling PetApi->addPet: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json, application/xml
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[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)
|
||||
|
||||
# **deletePet**
|
||||
> deletePet(petId, apiKey)
|
||||
|
||||
Deletes a pet
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
// TODO Configure OAuth2 access token for authorization: petstore_auth
|
||||
//defaultApiClient.getAuthentication<OAuth>('petstore_auth').accessToken = 'YOUR_ACCESS_TOKEN';
|
||||
|
||||
final api_instance = PetApi();
|
||||
final petId = 789; // int | Pet id to delete
|
||||
final apiKey = apiKey_example; // String |
|
||||
|
||||
try {
|
||||
api_instance.deletePet(petId, apiKey);
|
||||
} catch (e) {
|
||||
print('Exception when calling PetApi->deletePet: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**petId** | **int**| Pet id to delete |
|
||||
**apiKey** | **String**| | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[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)
|
||||
|
||||
# **findPetsByStatus**
|
||||
> List<Pet> findPetsByStatus(status)
|
||||
|
||||
Finds Pets by status
|
||||
|
||||
Multiple status values can be provided with comma separated strings
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
// TODO Configure OAuth2 access token for authorization: petstore_auth
|
||||
//defaultApiClient.getAuthentication<OAuth>('petstore_auth').accessToken = 'YOUR_ACCESS_TOKEN';
|
||||
|
||||
final api_instance = PetApi();
|
||||
final status = []; // List<String> | Status values that need to be considered for filter
|
||||
|
||||
try {
|
||||
final result = api_instance.findPetsByStatus(status);
|
||||
print(result);
|
||||
} catch (e) {
|
||||
print('Exception when calling PetApi->findPetsByStatus: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**status** | [**List<String>**](String.md)| Status values that need to be considered for filter | [default to const []]
|
||||
|
||||
### Return type
|
||||
|
||||
[**List<Pet>**](Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
[[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)
|
||||
|
||||
# **findPetsByTags**
|
||||
> Set<Pet> findPetsByTags(tags)
|
||||
|
||||
Finds Pets by tags
|
||||
|
||||
Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
// TODO Configure OAuth2 access token for authorization: petstore_auth
|
||||
//defaultApiClient.getAuthentication<OAuth>('petstore_auth').accessToken = 'YOUR_ACCESS_TOKEN';
|
||||
|
||||
final api_instance = PetApi();
|
||||
final tags = []; // Set<String> | Tags to filter by
|
||||
|
||||
try {
|
||||
final result = api_instance.findPetsByTags(tags);
|
||||
print(result);
|
||||
} catch (e) {
|
||||
print('Exception when calling PetApi->findPetsByTags: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**tags** | [**Set<String>**](String.md)| Tags to filter by | [default to const {}]
|
||||
|
||||
### Return type
|
||||
|
||||
[**Set<Pet>**](Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
[[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)
|
||||
|
||||
# **getPetById**
|
||||
> Pet getPetById(petId)
|
||||
|
||||
Find pet by ID
|
||||
|
||||
Returns a single pet
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
// TODO Configure API key authorization: api_key
|
||||
//defaultApiClient.getAuthentication<ApiKeyAuth>('api_key').apiKey = 'YOUR_API_KEY';
|
||||
// uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
||||
//defaultApiClient.getAuthentication<ApiKeyAuth>('api_key').apiKeyPrefix = 'Bearer';
|
||||
|
||||
final api_instance = PetApi();
|
||||
final petId = 789; // int | ID of pet to return
|
||||
|
||||
try {
|
||||
final result = api_instance.getPetById(petId);
|
||||
print(result);
|
||||
} catch (e) {
|
||||
print('Exception when calling PetApi->getPetById: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**petId** | **int**| ID of pet to return |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Pet**](Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[api_key](../README.md#api_key)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
[[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)
|
||||
|
||||
# **updatePet**
|
||||
> updatePet(pet)
|
||||
|
||||
Update an existing pet
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
// TODO Configure OAuth2 access token for authorization: petstore_auth
|
||||
//defaultApiClient.getAuthentication<OAuth>('petstore_auth').accessToken = 'YOUR_ACCESS_TOKEN';
|
||||
|
||||
final api_instance = PetApi();
|
||||
final pet = Pet(); // Pet | Pet object that needs to be added to the store
|
||||
|
||||
try {
|
||||
api_instance.updatePet(pet);
|
||||
} catch (e) {
|
||||
print('Exception when calling PetApi->updatePet: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json, application/xml
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[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)
|
||||
|
||||
# **updatePetWithForm**
|
||||
> updatePetWithForm(petId, name, status)
|
||||
|
||||
Updates a pet in the store with form data
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
// TODO Configure OAuth2 access token for authorization: petstore_auth
|
||||
//defaultApiClient.getAuthentication<OAuth>('petstore_auth').accessToken = 'YOUR_ACCESS_TOKEN';
|
||||
|
||||
final api_instance = PetApi();
|
||||
final petId = 789; // int | ID of pet that needs to be updated
|
||||
final name = name_example; // String | Updated name of the pet
|
||||
final status = status_example; // String | Updated status of the pet
|
||||
|
||||
try {
|
||||
api_instance.updatePetWithForm(petId, name, status);
|
||||
} catch (e) {
|
||||
print('Exception when calling PetApi->updatePetWithForm: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**petId** | **int**| ID of pet that needs to be updated |
|
||||
**name** | **String**| Updated name of the pet | [optional]
|
||||
**status** | **String**| Updated status of the pet | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/x-www-form-urlencoded
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[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)
|
||||
|
||||
# **uploadFile**
|
||||
> ApiResponse uploadFile(petId, additionalMetadata, file)
|
||||
|
||||
uploads an image
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
// TODO Configure OAuth2 access token for authorization: petstore_auth
|
||||
//defaultApiClient.getAuthentication<OAuth>('petstore_auth').accessToken = 'YOUR_ACCESS_TOKEN';
|
||||
|
||||
final api_instance = PetApi();
|
||||
final petId = 789; // int | ID of pet to update
|
||||
final additionalMetadata = additionalMetadata_example; // String | Additional data to pass to server
|
||||
final file = BINARY_DATA_HERE; // MultipartFile | file to upload
|
||||
|
||||
try {
|
||||
final result = api_instance.uploadFile(petId, additionalMetadata, file);
|
||||
print(result);
|
||||
} catch (e) {
|
||||
print('Exception when calling PetApi->uploadFile: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**petId** | **int**| ID of pet to update |
|
||||
**additionalMetadata** | **String**| Additional data to pass to server | [optional]
|
||||
**file** | **MultipartFile**| file to upload | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
[**ApiResponse**](ApiResponse.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: multipart/form-data
|
||||
- **Accept**: application/json
|
||||
|
||||
[[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)
|
||||
|
||||
# **uploadFileWithRequiredFile**
|
||||
> ApiResponse uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata)
|
||||
|
||||
uploads an image (required)
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
// TODO Configure OAuth2 access token for authorization: petstore_auth
|
||||
//defaultApiClient.getAuthentication<OAuth>('petstore_auth').accessToken = 'YOUR_ACCESS_TOKEN';
|
||||
|
||||
final api_instance = PetApi();
|
||||
final petId = 789; // int | ID of pet to update
|
||||
final requiredFile = BINARY_DATA_HERE; // MultipartFile | file to upload
|
||||
final additionalMetadata = additionalMetadata_example; // String | Additional data to pass to server
|
||||
|
||||
try {
|
||||
final result = api_instance.uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata);
|
||||
print(result);
|
||||
} catch (e) {
|
||||
print('Exception when calling PetApi->uploadFileWithRequiredFile: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**petId** | **int**| ID of pet to update |
|
||||
**requiredFile** | **MultipartFile**| file to upload |
|
||||
**additionalMetadata** | **String**| Additional data to pass to server | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
[**ApiResponse**](ApiResponse.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: multipart/form-data
|
||||
- **Accept**: application/json
|
||||
|
||||
[[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)
|
||||
|
@ -0,0 +1,16 @@
|
||||
# openapi.model.ReadOnlyFirst
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**bar** | **String** | | [optional] [readonly]
|
||||
**baz** | **String** | | [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)
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
# openapi.model.SpecialModelName
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket** | **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)
|
||||
|
||||
|
@ -0,0 +1,186 @@
|
||||
# openapi.api.StoreApi
|
||||
|
||||
## Load the API package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID
|
||||
[**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status
|
||||
[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{order_id} | Find purchase order by ID
|
||||
[**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet
|
||||
|
||||
|
||||
# **deleteOrder**
|
||||
> deleteOrder(orderId)
|
||||
|
||||
Delete purchase order by ID
|
||||
|
||||
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final api_instance = StoreApi();
|
||||
final orderId = orderId_example; // String | ID of the order that needs to be deleted
|
||||
|
||||
try {
|
||||
api_instance.deleteOrder(orderId);
|
||||
} catch (e) {
|
||||
print('Exception when calling StoreApi->deleteOrder: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**orderId** | **String**| ID of the order that needs to be deleted |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[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)
|
||||
|
||||
# **getInventory**
|
||||
> Map<String, int> getInventory()
|
||||
|
||||
Returns pet inventories by status
|
||||
|
||||
Returns a map of status codes to quantities
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
// TODO Configure API key authorization: api_key
|
||||
//defaultApiClient.getAuthentication<ApiKeyAuth>('api_key').apiKey = 'YOUR_API_KEY';
|
||||
// uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
||||
//defaultApiClient.getAuthentication<ApiKeyAuth>('api_key').apiKeyPrefix = 'Bearer';
|
||||
|
||||
final api_instance = StoreApi();
|
||||
|
||||
try {
|
||||
final result = api_instance.getInventory();
|
||||
print(result);
|
||||
} catch (e) {
|
||||
print('Exception when calling StoreApi->getInventory: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
**Map<String, int>**
|
||||
|
||||
### Authorization
|
||||
|
||||
[api_key](../README.md#api_key)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json
|
||||
|
||||
[[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)
|
||||
|
||||
# **getOrderById**
|
||||
> Order getOrderById(orderId)
|
||||
|
||||
Find purchase order by ID
|
||||
|
||||
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final api_instance = StoreApi();
|
||||
final orderId = 789; // int | ID of pet that needs to be fetched
|
||||
|
||||
try {
|
||||
final result = api_instance.getOrderById(orderId);
|
||||
print(result);
|
||||
} catch (e) {
|
||||
print('Exception when calling StoreApi->getOrderById: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**orderId** | **int**| ID of pet that needs to be fetched |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Order**](Order.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
[[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)
|
||||
|
||||
# **placeOrder**
|
||||
> Order placeOrder(order)
|
||||
|
||||
Place an order for a pet
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final api_instance = StoreApi();
|
||||
final order = Order(); // Order | order placed for purchasing the pet
|
||||
|
||||
try {
|
||||
final result = api_instance.placeOrder(order);
|
||||
print(result);
|
||||
} catch (e) {
|
||||
print('Exception when calling StoreApi->placeOrder: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**order** | [**Order**](Order.md)| order placed for purchasing the pet |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Order**](Order.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
[[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)
|
||||
|
@ -0,0 +1,16 @@
|
||||
# openapi.model.Tag
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**id** | **int** | | [optional]
|
||||
**name** | **String** | | [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)
|
||||
|
||||
|
@ -0,0 +1,22 @@
|
||||
# openapi.model.User
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**id** | **int** | | [optional]
|
||||
**username** | **String** | | [optional]
|
||||
**firstName** | **String** | | [optional]
|
||||
**lastName** | **String** | | [optional]
|
||||
**email** | **String** | | [optional]
|
||||
**password** | **String** | | [optional]
|
||||
**phone** | **String** | | [optional]
|
||||
**userStatus** | **int** | User Status | [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)
|
||||
|
||||
|
@ -0,0 +1,349 @@
|
||||
# openapi.api.UserApi
|
||||
|
||||
## Load the API package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**createUser**](UserApi.md#createUser) | **POST** /user | Create user
|
||||
[**createUsersWithArrayInput**](UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array
|
||||
[**createUsersWithListInput**](UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array
|
||||
[**deleteUser**](UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user
|
||||
[**getUserByName**](UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name
|
||||
[**loginUser**](UserApi.md#loginUser) | **GET** /user/login | Logs user into the system
|
||||
[**logoutUser**](UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session
|
||||
[**updateUser**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user
|
||||
|
||||
|
||||
# **createUser**
|
||||
> createUser(user)
|
||||
|
||||
Create user
|
||||
|
||||
This can only be done by the logged in user.
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final api_instance = UserApi();
|
||||
final user = User(); // User | Created user object
|
||||
|
||||
try {
|
||||
api_instance.createUser(user);
|
||||
} catch (e) {
|
||||
print('Exception when calling UserApi->createUser: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**user** | [**User**](User.md)| Created user object |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[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)
|
||||
|
||||
# **createUsersWithArrayInput**
|
||||
> createUsersWithArrayInput(user)
|
||||
|
||||
Creates list of users with given input array
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final api_instance = UserApi();
|
||||
final user = [List<User>()]; // List<User> | List of user object
|
||||
|
||||
try {
|
||||
api_instance.createUsersWithArrayInput(user);
|
||||
} catch (e) {
|
||||
print('Exception when calling UserApi->createUsersWithArrayInput: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**user** | [**List<User>**](User.md)| List of user object |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[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)
|
||||
|
||||
# **createUsersWithListInput**
|
||||
> createUsersWithListInput(user)
|
||||
|
||||
Creates list of users with given input array
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final api_instance = UserApi();
|
||||
final user = [List<User>()]; // List<User> | List of user object
|
||||
|
||||
try {
|
||||
api_instance.createUsersWithListInput(user);
|
||||
} catch (e) {
|
||||
print('Exception when calling UserApi->createUsersWithListInput: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**user** | [**List<User>**](User.md)| List of user object |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[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)
|
||||
|
||||
# **deleteUser**
|
||||
> deleteUser(username)
|
||||
|
||||
Delete user
|
||||
|
||||
This can only be done by the logged in user.
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final api_instance = UserApi();
|
||||
final username = username_example; // String | The name that needs to be deleted
|
||||
|
||||
try {
|
||||
api_instance.deleteUser(username);
|
||||
} catch (e) {
|
||||
print('Exception when calling UserApi->deleteUser: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**username** | **String**| The name that needs to be deleted |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[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)
|
||||
|
||||
# **getUserByName**
|
||||
> User getUserByName(username)
|
||||
|
||||
Get user by user name
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final api_instance = UserApi();
|
||||
final username = username_example; // String | The name that needs to be fetched. Use user1 for testing.
|
||||
|
||||
try {
|
||||
final result = api_instance.getUserByName(username);
|
||||
print(result);
|
||||
} catch (e) {
|
||||
print('Exception when calling UserApi->getUserByName: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
|
||||
|
||||
### Return type
|
||||
|
||||
[**User**](User.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
[[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)
|
||||
|
||||
# **loginUser**
|
||||
> String loginUser(username, password)
|
||||
|
||||
Logs user into the system
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final api_instance = UserApi();
|
||||
final username = username_example; // String | The user name for login
|
||||
final password = password_example; // String | The password for login in clear text
|
||||
|
||||
try {
|
||||
final result = api_instance.loginUser(username, password);
|
||||
print(result);
|
||||
} catch (e) {
|
||||
print('Exception when calling UserApi->loginUser: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**username** | **String**| The user name for login |
|
||||
**password** | **String**| The password for login in clear text |
|
||||
|
||||
### Return type
|
||||
|
||||
**String**
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
[[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)
|
||||
|
||||
# **logoutUser**
|
||||
> logoutUser()
|
||||
|
||||
Logs out current logged in user session
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final api_instance = UserApi();
|
||||
|
||||
try {
|
||||
api_instance.logoutUser();
|
||||
} catch (e) {
|
||||
print('Exception when calling UserApi->logoutUser: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[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)
|
||||
|
||||
# **updateUser**
|
||||
> updateUser(username, user)
|
||||
|
||||
Updated user
|
||||
|
||||
This can only be done by the logged in user.
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final api_instance = UserApi();
|
||||
final username = username_example; // String | name that need to be deleted
|
||||
final user = User(); // User | Updated user object
|
||||
|
||||
try {
|
||||
api_instance.updateUser(username, user);
|
||||
} catch (e) {
|
||||
print('Exception when calling UserApi->updateUser: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**username** | **String**| name that need to be deleted |
|
||||
**user** | [**User**](User.md)| Updated user object |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[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)
|
||||
|
@ -0,0 +1,58 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
git_host=$4
|
||||
|
||||
if [ "$git_host" = "" ]; then
|
||||
git_host="github.com"
|
||||
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||
fi
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="GIT_USER_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||
fi
|
||||
|
||||
if [ "$git_repo_id" = "" ]; then
|
||||
git_repo_id="GIT_REPO_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||
fi
|
||||
|
||||
if [ "$release_note" = "" ]; then
|
||||
release_note="Minor update"
|
||||
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
||||
fi
|
||||
|
||||
# Initialize the local directory as a Git repository
|
||||
git init
|
||||
|
||||
# Adds the files in the local repository and stages them for commit.
|
||||
git add .
|
||||
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
git commit -m "$release_note"
|
||||
|
||||
# Sets the new remote
|
||||
git_remote=`git remote`
|
||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
||||
|
@ -0,0 +1,92 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
library openapi.api;
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'api_client.dart';
|
||||
part 'api_helper.dart';
|
||||
part 'api_exception.dart';
|
||||
part 'auth/authentication.dart';
|
||||
part 'auth/api_key_auth.dart';
|
||||
part 'auth/oauth.dart';
|
||||
part 'auth/http_basic_auth.dart';
|
||||
part 'auth/http_bearer_auth.dart';
|
||||
|
||||
part 'api/another_fake_api.dart';
|
||||
part 'api/default_api.dart';
|
||||
part 'api/fake_api.dart';
|
||||
part 'api/fake_classname_tags123_api.dart';
|
||||
part 'api/pet_api.dart';
|
||||
part 'api/store_api.dart';
|
||||
part 'api/user_api.dart';
|
||||
|
||||
part 'model/additional_properties_class.dart';
|
||||
part 'model/animal.dart';
|
||||
part 'model/api_response.dart';
|
||||
part 'model/array_of_array_of_number_only.dart';
|
||||
part 'model/array_of_number_only.dart';
|
||||
part 'model/array_test.dart';
|
||||
part 'model/capitalization.dart';
|
||||
part 'model/cat.dart';
|
||||
part 'model/cat_all_of.dart';
|
||||
part 'model/category.dart';
|
||||
part 'model/class_model.dart';
|
||||
part 'model/dog.dart';
|
||||
part 'model/dog_all_of.dart';
|
||||
part 'model/enum_arrays.dart';
|
||||
part 'model/enum_class.dart';
|
||||
part 'model/enum_test.dart';
|
||||
part 'model/file_schema_test_class.dart';
|
||||
part 'model/foo.dart';
|
||||
part 'model/format_test.dart';
|
||||
part 'model/has_only_read_only.dart';
|
||||
part 'model/health_check_result.dart';
|
||||
part 'model/inline_response_default.dart';
|
||||
part 'model/map_test.dart';
|
||||
part 'model/mixed_properties_and_additional_properties_class.dart';
|
||||
part 'model/model200_response.dart';
|
||||
part 'model/model_client.dart';
|
||||
part 'model/model_file.dart';
|
||||
part 'model/model_list.dart';
|
||||
part 'model/model_return.dart';
|
||||
part 'model/name.dart';
|
||||
part 'model/nullable_class.dart';
|
||||
part 'model/number_only.dart';
|
||||
part 'model/order.dart';
|
||||
part 'model/outer_composite.dart';
|
||||
part 'model/outer_enum.dart';
|
||||
part 'model/outer_enum_default_value.dart';
|
||||
part 'model/outer_enum_integer.dart';
|
||||
part 'model/outer_enum_integer_default_value.dart';
|
||||
part 'model/pet.dart';
|
||||
part 'model/read_only_first.dart';
|
||||
part 'model/special_model_name.dart';
|
||||
part 'model/tag.dart';
|
||||
part 'model/user.dart';
|
||||
|
||||
|
||||
part 'api.g.dart';
|
||||
const _delimiters = {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'};
|
||||
const _dateEpochMarker = 'epoch';
|
||||
final _dateFormatter = DateFormat('yyyy-MM-dd');
|
||||
final _regList = RegExp(r'^List<(.*)>$');
|
||||
final _regSet = RegExp(r'^Set<(.*)>$');
|
||||
final _regMap = RegExp(r'^Map<String,(.*)>$');
|
||||
|
||||
ApiClient defaultApiClient = ApiClient();
|
@ -0,0 +1,91 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
|
||||
class AnotherFakeApi {
|
||||
AnotherFakeApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
|
||||
final ApiClient apiClient;
|
||||
|
||||
/// To test special tags
|
||||
///
|
||||
/// To test special tags and operation ID starting with number
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [ModelClient] modelClient (required):
|
||||
/// client model
|
||||
Future<Response> call123testSpecialTagsWithHttpInfo(ModelClient modelClient) async {
|
||||
// Verify required params are set.
|
||||
if (modelClient == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: modelClient');
|
||||
}
|
||||
|
||||
final path = '/another-fake/dummy'.replaceAll('{format}', 'json');
|
||||
|
||||
Object postBody = modelClient;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
final contentTypes = <String>['application/json'];
|
||||
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
|
||||
final authNames = <String>[];
|
||||
|
||||
if (
|
||||
nullableContentType != null &&
|
||||
nullableContentType.toLowerCase().startsWith('multipart/form-data')
|
||||
) {
|
||||
bool hasFields = false;
|
||||
final mp = MultipartRequest(null, null);
|
||||
if (hasFields) {
|
||||
postBody = mp;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
return await apiClient.invokeAPI(
|
||||
path,
|
||||
'PATCH',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
nullableContentType,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
|
||||
/// To test special tags
|
||||
///
|
||||
/// To test special tags and operation ID starting with number
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [ModelClient] modelClient (required):
|
||||
/// client model
|
||||
Future<ModelClient> call123testSpecialTags(ModelClient modelClient) async {
|
||||
final response = await call123testSpecialTagsWithHttpInfo(modelClient);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
}
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'ModelClient') as ModelClient;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
|
||||
class DefaultApi {
|
||||
DefaultApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
|
||||
final ApiClient apiClient;
|
||||
|
||||
/// Performs an HTTP 'GET /foo' operation and returns the [Response].
|
||||
Future<Response> fooGetWithHttpInfo() async {
|
||||
final path = '/foo'.replaceAll('{format}', 'json');
|
||||
|
||||
Object postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
final contentTypes = <String>[];
|
||||
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
|
||||
final authNames = <String>[];
|
||||
|
||||
if (
|
||||
nullableContentType != null &&
|
||||
nullableContentType.toLowerCase().startsWith('multipart/form-data')
|
||||
) {
|
||||
bool hasFields = false;
|
||||
final mp = MultipartRequest(null, null);
|
||||
if (hasFields) {
|
||||
postBody = mp;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
return await apiClient.invokeAPI(
|
||||
path,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
nullableContentType,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
|
||||
Future<InlineResponseDefault> fooGet() async {
|
||||
final response = await fooGetWithHttpInfo();
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
}
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'InlineResponseDefault') as InlineResponseDefault;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,91 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
|
||||
class FakeClassnameTags123Api {
|
||||
FakeClassnameTags123Api([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
|
||||
final ApiClient apiClient;
|
||||
|
||||
/// To test class name in snake case
|
||||
///
|
||||
/// To test class name in snake case
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [ModelClient] modelClient (required):
|
||||
/// client model
|
||||
Future<Response> testClassnameWithHttpInfo(ModelClient modelClient) async {
|
||||
// Verify required params are set.
|
||||
if (modelClient == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: modelClient');
|
||||
}
|
||||
|
||||
final path = '/fake_classname_test'.replaceAll('{format}', 'json');
|
||||
|
||||
Object postBody = modelClient;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
final contentTypes = <String>['application/json'];
|
||||
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
|
||||
final authNames = <String>['api_key_query'];
|
||||
|
||||
if (
|
||||
nullableContentType != null &&
|
||||
nullableContentType.toLowerCase().startsWith('multipart/form-data')
|
||||
) {
|
||||
bool hasFields = false;
|
||||
final mp = MultipartRequest(null, null);
|
||||
if (hasFields) {
|
||||
postBody = mp;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
return await apiClient.invokeAPI(
|
||||
path,
|
||||
'PATCH',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
nullableContentType,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
|
||||
/// To test class name in snake case
|
||||
///
|
||||
/// To test class name in snake case
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [ModelClient] modelClient (required):
|
||||
/// client model
|
||||
Future<ModelClient> testClassname(ModelClient modelClient) async {
|
||||
final response = await testClassnameWithHttpInfo(modelClient);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
}
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'ModelClient') as ModelClient;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,729 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
|
||||
class PetApi {
|
||||
PetApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
|
||||
final ApiClient apiClient;
|
||||
|
||||
/// Add a new pet to the store
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [Pet] pet (required):
|
||||
/// Pet object that needs to be added to the store
|
||||
Future<Response> addPetWithHttpInfo(Pet pet) async {
|
||||
// Verify required params are set.
|
||||
if (pet == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: pet');
|
||||
}
|
||||
|
||||
final path = '/pet'.replaceAll('{format}', 'json');
|
||||
|
||||
Object postBody = pet;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
final contentTypes = <String>['application/json', 'application/xml'];
|
||||
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
|
||||
final authNames = <String>['petstore_auth'];
|
||||
|
||||
if (
|
||||
nullableContentType != null &&
|
||||
nullableContentType.toLowerCase().startsWith('multipart/form-data')
|
||||
) {
|
||||
bool hasFields = false;
|
||||
final mp = MultipartRequest(null, null);
|
||||
if (hasFields) {
|
||||
postBody = mp;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
return await apiClient.invokeAPI(
|
||||
path,
|
||||
'POST',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
nullableContentType,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
|
||||
/// Add a new pet to the store
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [Pet] pet (required):
|
||||
/// Pet object that needs to be added to the store
|
||||
Future<void> addPet(Pet pet) async {
|
||||
final response = await addPetWithHttpInfo(pet);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
}
|
||||
}
|
||||
|
||||
/// Deletes a pet
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [int] petId (required):
|
||||
/// Pet id to delete
|
||||
///
|
||||
/// * [String] apiKey:
|
||||
Future<Response> deletePetWithHttpInfo(int petId, { String apiKey }) async {
|
||||
// Verify required params are set.
|
||||
if (petId == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
|
||||
final path = '/pet/{petId}'.replaceAll('{format}', 'json')
|
||||
.replaceAll('{' + 'petId' + '}', petId.toString());
|
||||
|
||||
Object postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
if (apiKey != null) {
|
||||
headerParams[r'api_key'] = parameterToString(apiKey);
|
||||
}
|
||||
|
||||
final contentTypes = <String>[];
|
||||
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
|
||||
final authNames = <String>['petstore_auth'];
|
||||
|
||||
if (
|
||||
nullableContentType != null &&
|
||||
nullableContentType.toLowerCase().startsWith('multipart/form-data')
|
||||
) {
|
||||
bool hasFields = false;
|
||||
final mp = MultipartRequest(null, null);
|
||||
if (hasFields) {
|
||||
postBody = mp;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
return await apiClient.invokeAPI(
|
||||
path,
|
||||
'DELETE',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
nullableContentType,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
|
||||
/// Deletes a pet
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [int] petId (required):
|
||||
/// Pet id to delete
|
||||
///
|
||||
/// * [String] apiKey:
|
||||
Future<void> deletePet(int petId, { String apiKey }) async {
|
||||
final response = await deletePetWithHttpInfo(petId, apiKey: apiKey );
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
}
|
||||
}
|
||||
|
||||
/// Finds Pets by status
|
||||
///
|
||||
/// Multiple status values can be provided with comma separated strings
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [List<String>] status (required):
|
||||
/// Status values that need to be considered for filter
|
||||
Future<Response> findPetsByStatusWithHttpInfo(List<String> status) async {
|
||||
// Verify required params are set.
|
||||
if (status == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: status');
|
||||
}
|
||||
|
||||
final path = '/pet/findByStatus'.replaceAll('{format}', 'json');
|
||||
|
||||
Object postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('csv', 'status', status));
|
||||
|
||||
final contentTypes = <String>[];
|
||||
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
|
||||
final authNames = <String>['petstore_auth'];
|
||||
|
||||
if (
|
||||
nullableContentType != null &&
|
||||
nullableContentType.toLowerCase().startsWith('multipart/form-data')
|
||||
) {
|
||||
bool hasFields = false;
|
||||
final mp = MultipartRequest(null, null);
|
||||
if (hasFields) {
|
||||
postBody = mp;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
return await apiClient.invokeAPI(
|
||||
path,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
nullableContentType,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
|
||||
/// Finds Pets by status
|
||||
///
|
||||
/// Multiple status values can be provided with comma separated strings
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [List<String>] status (required):
|
||||
/// Status values that need to be considered for filter
|
||||
Future<List<Pet>> findPetsByStatus(List<String> status) async {
|
||||
final response = await findPetsByStatusWithHttpInfo(status);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
}
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return (apiClient.deserialize(_decodeBodyBytes(response), 'List<Pet>') as List)
|
||||
.cast<Pet>()
|
||||
.toList(growable: false);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Finds Pets by tags
|
||||
///
|
||||
/// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [Set<String>] tags (required):
|
||||
/// Tags to filter by
|
||||
Future<Response> findPetsByTagsWithHttpInfo(Set<String> tags) async {
|
||||
// Verify required params are set.
|
||||
if (tags == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: tags');
|
||||
}
|
||||
|
||||
final path = '/pet/findByTags'.replaceAll('{format}', 'json');
|
||||
|
||||
Object postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('csv', 'tags', tags));
|
||||
|
||||
final contentTypes = <String>[];
|
||||
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
|
||||
final authNames = <String>['petstore_auth'];
|
||||
|
||||
if (
|
||||
nullableContentType != null &&
|
||||
nullableContentType.toLowerCase().startsWith('multipart/form-data')
|
||||
) {
|
||||
bool hasFields = false;
|
||||
final mp = MultipartRequest(null, null);
|
||||
if (hasFields) {
|
||||
postBody = mp;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
return await apiClient.invokeAPI(
|
||||
path,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
nullableContentType,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
|
||||
/// Finds Pets by tags
|
||||
///
|
||||
/// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [Set<String>] tags (required):
|
||||
/// Tags to filter by
|
||||
Future<Set<Pet>> findPetsByTags(Set<String> tags) async {
|
||||
final response = await findPetsByTagsWithHttpInfo(tags);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
}
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return (apiClient.deserialize(_decodeBodyBytes(response), 'Set<Pet>') as List)
|
||||
.cast<Pet>()
|
||||
.toSet();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Find pet by ID
|
||||
///
|
||||
/// Returns a single pet
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [int] petId (required):
|
||||
/// ID of pet to return
|
||||
Future<Response> getPetByIdWithHttpInfo(int petId) async {
|
||||
// Verify required params are set.
|
||||
if (petId == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
|
||||
final path = '/pet/{petId}'.replaceAll('{format}', 'json')
|
||||
.replaceAll('{' + 'petId' + '}', petId.toString());
|
||||
|
||||
Object postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
final contentTypes = <String>[];
|
||||
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
|
||||
final authNames = <String>['api_key'];
|
||||
|
||||
if (
|
||||
nullableContentType != null &&
|
||||
nullableContentType.toLowerCase().startsWith('multipart/form-data')
|
||||
) {
|
||||
bool hasFields = false;
|
||||
final mp = MultipartRequest(null, null);
|
||||
if (hasFields) {
|
||||
postBody = mp;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
return await apiClient.invokeAPI(
|
||||
path,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
nullableContentType,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
|
||||
/// Find pet by ID
|
||||
///
|
||||
/// Returns a single pet
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [int] petId (required):
|
||||
/// ID of pet to return
|
||||
Future<Pet> getPetById(int petId) async {
|
||||
final response = await getPetByIdWithHttpInfo(petId);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
}
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Pet') as Pet;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Update an existing pet
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [Pet] pet (required):
|
||||
/// Pet object that needs to be added to the store
|
||||
Future<Response> updatePetWithHttpInfo(Pet pet) async {
|
||||
// Verify required params are set.
|
||||
if (pet == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: pet');
|
||||
}
|
||||
|
||||
final path = '/pet'.replaceAll('{format}', 'json');
|
||||
|
||||
Object postBody = pet;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
final contentTypes = <String>['application/json', 'application/xml'];
|
||||
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
|
||||
final authNames = <String>['petstore_auth'];
|
||||
|
||||
if (
|
||||
nullableContentType != null &&
|
||||
nullableContentType.toLowerCase().startsWith('multipart/form-data')
|
||||
) {
|
||||
bool hasFields = false;
|
||||
final mp = MultipartRequest(null, null);
|
||||
if (hasFields) {
|
||||
postBody = mp;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
return await apiClient.invokeAPI(
|
||||
path,
|
||||
'PUT',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
nullableContentType,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
|
||||
/// Update an existing pet
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [Pet] pet (required):
|
||||
/// Pet object that needs to be added to the store
|
||||
Future<void> updatePet(Pet pet) async {
|
||||
final response = await updatePetWithHttpInfo(pet);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
}
|
||||
}
|
||||
|
||||
/// Updates a pet in the store with form data
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [int] petId (required):
|
||||
/// ID of pet that needs to be updated
|
||||
///
|
||||
/// * [String] name:
|
||||
/// Updated name of the pet
|
||||
///
|
||||
/// * [String] status:
|
||||
/// Updated status of the pet
|
||||
Future<Response> updatePetWithFormWithHttpInfo(int petId, { String name, String status }) async {
|
||||
// Verify required params are set.
|
||||
if (petId == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
|
||||
final path = '/pet/{petId}'.replaceAll('{format}', 'json')
|
||||
.replaceAll('{' + 'petId' + '}', petId.toString());
|
||||
|
||||
Object postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
final contentTypes = <String>['application/x-www-form-urlencoded'];
|
||||
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
|
||||
final authNames = <String>['petstore_auth'];
|
||||
|
||||
if (
|
||||
nullableContentType != null &&
|
||||
nullableContentType.toLowerCase().startsWith('multipart/form-data')
|
||||
) {
|
||||
bool hasFields = false;
|
||||
final mp = MultipartRequest(null, null);
|
||||
if (name != null) {
|
||||
hasFields = true;
|
||||
mp.fields[r'name'] = parameterToString(name);
|
||||
}
|
||||
if (status != null) {
|
||||
hasFields = true;
|
||||
mp.fields[r'status'] = parameterToString(status);
|
||||
}
|
||||
if (hasFields) {
|
||||
postBody = mp;
|
||||
}
|
||||
} else {
|
||||
if (name != null) {
|
||||
formParams[r'name'] = parameterToString(name);
|
||||
}
|
||||
if (status != null) {
|
||||
formParams[r'status'] = parameterToString(status);
|
||||
}
|
||||
}
|
||||
|
||||
return await apiClient.invokeAPI(
|
||||
path,
|
||||
'POST',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
nullableContentType,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
|
||||
/// Updates a pet in the store with form data
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [int] petId (required):
|
||||
/// ID of pet that needs to be updated
|
||||
///
|
||||
/// * [String] name:
|
||||
/// Updated name of the pet
|
||||
///
|
||||
/// * [String] status:
|
||||
/// Updated status of the pet
|
||||
Future<void> updatePetWithForm(int petId, { String name, String status }) async {
|
||||
final response = await updatePetWithFormWithHttpInfo(petId, name: name, status: status );
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
}
|
||||
}
|
||||
|
||||
/// uploads an image
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [int] petId (required):
|
||||
/// ID of pet to update
|
||||
///
|
||||
/// * [String] additionalMetadata:
|
||||
/// Additional data to pass to server
|
||||
///
|
||||
/// * [MultipartFile] file:
|
||||
/// file to upload
|
||||
Future<Response> uploadFileWithHttpInfo(int petId, { String additionalMetadata, MultipartFile file }) async {
|
||||
// Verify required params are set.
|
||||
if (petId == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
|
||||
final path = '/pet/{petId}/uploadImage'.replaceAll('{format}', 'json')
|
||||
.replaceAll('{' + 'petId' + '}', petId.toString());
|
||||
|
||||
Object postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
final contentTypes = <String>['multipart/form-data'];
|
||||
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
|
||||
final authNames = <String>['petstore_auth'];
|
||||
|
||||
if (
|
||||
nullableContentType != null &&
|
||||
nullableContentType.toLowerCase().startsWith('multipart/form-data')
|
||||
) {
|
||||
bool hasFields = false;
|
||||
final mp = MultipartRequest(null, null);
|
||||
if (additionalMetadata != null) {
|
||||
hasFields = true;
|
||||
mp.fields[r'additionalMetadata'] = parameterToString(additionalMetadata);
|
||||
}
|
||||
if (file != null) {
|
||||
hasFields = true;
|
||||
mp.fields[r'file'] = file.field;
|
||||
mp.files.add(file);
|
||||
}
|
||||
if (hasFields) {
|
||||
postBody = mp;
|
||||
}
|
||||
} else {
|
||||
if (additionalMetadata != null) {
|
||||
formParams[r'additionalMetadata'] = parameterToString(additionalMetadata);
|
||||
}
|
||||
}
|
||||
|
||||
return await apiClient.invokeAPI(
|
||||
path,
|
||||
'POST',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
nullableContentType,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
|
||||
/// uploads an image
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [int] petId (required):
|
||||
/// ID of pet to update
|
||||
///
|
||||
/// * [String] additionalMetadata:
|
||||
/// Additional data to pass to server
|
||||
///
|
||||
/// * [MultipartFile] file:
|
||||
/// file to upload
|
||||
Future<ApiResponse> uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async {
|
||||
final response = await uploadFileWithHttpInfo(petId, additionalMetadata: additionalMetadata, file: file );
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
}
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'ApiResponse') as ApiResponse;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// uploads an image (required)
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [int] petId (required):
|
||||
/// ID of pet to update
|
||||
///
|
||||
/// * [MultipartFile] requiredFile (required):
|
||||
/// file to upload
|
||||
///
|
||||
/// * [String] additionalMetadata:
|
||||
/// Additional data to pass to server
|
||||
Future<Response> uploadFileWithRequiredFileWithHttpInfo(int petId, MultipartFile requiredFile, { String additionalMetadata }) async {
|
||||
// Verify required params are set.
|
||||
if (petId == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
if (requiredFile == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: requiredFile');
|
||||
}
|
||||
|
||||
final path = '/fake/{petId}/uploadImageWithRequiredFile'.replaceAll('{format}', 'json')
|
||||
.replaceAll('{' + 'petId' + '}', petId.toString());
|
||||
|
||||
Object postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
final contentTypes = <String>['multipart/form-data'];
|
||||
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
|
||||
final authNames = <String>['petstore_auth'];
|
||||
|
||||
if (
|
||||
nullableContentType != null &&
|
||||
nullableContentType.toLowerCase().startsWith('multipart/form-data')
|
||||
) {
|
||||
bool hasFields = false;
|
||||
final mp = MultipartRequest(null, null);
|
||||
if (additionalMetadata != null) {
|
||||
hasFields = true;
|
||||
mp.fields[r'additionalMetadata'] = parameterToString(additionalMetadata);
|
||||
}
|
||||
if (requiredFile != null) {
|
||||
hasFields = true;
|
||||
mp.fields[r'requiredFile'] = requiredFile.field;
|
||||
mp.files.add(requiredFile);
|
||||
}
|
||||
if (hasFields) {
|
||||
postBody = mp;
|
||||
}
|
||||
} else {
|
||||
if (additionalMetadata != null) {
|
||||
formParams[r'additionalMetadata'] = parameterToString(additionalMetadata);
|
||||
}
|
||||
}
|
||||
|
||||
return await apiClient.invokeAPI(
|
||||
path,
|
||||
'POST',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
nullableContentType,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
|
||||
/// uploads an image (required)
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [int] petId (required):
|
||||
/// ID of pet to update
|
||||
///
|
||||
/// * [MultipartFile] requiredFile (required):
|
||||
/// file to upload
|
||||
///
|
||||
/// * [String] additionalMetadata:
|
||||
/// Additional data to pass to server
|
||||
Future<ApiResponse> uploadFileWithRequiredFile(int petId, MultipartFile requiredFile, { String additionalMetadata }) async {
|
||||
final response = await uploadFileWithRequiredFileWithHttpInfo(petId, requiredFile, additionalMetadata: additionalMetadata );
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
}
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'ApiResponse') as ApiResponse;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,289 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
|
||||
class StoreApi {
|
||||
StoreApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
|
||||
final ApiClient apiClient;
|
||||
|
||||
/// Delete purchase order by ID
|
||||
///
|
||||
/// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] orderId (required):
|
||||
/// ID of the order that needs to be deleted
|
||||
Future<Response> deleteOrderWithHttpInfo(String orderId) async {
|
||||
// Verify required params are set.
|
||||
if (orderId == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: orderId');
|
||||
}
|
||||
|
||||
final path = '/store/order/{order_id}'.replaceAll('{format}', 'json')
|
||||
.replaceAll('{' + 'order_id' + '}', orderId.toString());
|
||||
|
||||
Object postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
final contentTypes = <String>[];
|
||||
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
|
||||
final authNames = <String>[];
|
||||
|
||||
if (
|
||||
nullableContentType != null &&
|
||||
nullableContentType.toLowerCase().startsWith('multipart/form-data')
|
||||
) {
|
||||
bool hasFields = false;
|
||||
final mp = MultipartRequest(null, null);
|
||||
if (hasFields) {
|
||||
postBody = mp;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
return await apiClient.invokeAPI(
|
||||
path,
|
||||
'DELETE',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
nullableContentType,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
|
||||
/// Delete purchase order by ID
|
||||
///
|
||||
/// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] orderId (required):
|
||||
/// ID of the order that needs to be deleted
|
||||
Future<void> deleteOrder(String orderId) async {
|
||||
final response = await deleteOrderWithHttpInfo(orderId);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns pet inventories by status
|
||||
///
|
||||
/// Returns a map of status codes to quantities
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
Future<Response> getInventoryWithHttpInfo() async {
|
||||
final path = '/store/inventory'.replaceAll('{format}', 'json');
|
||||
|
||||
Object postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
final contentTypes = <String>[];
|
||||
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
|
||||
final authNames = <String>['api_key'];
|
||||
|
||||
if (
|
||||
nullableContentType != null &&
|
||||
nullableContentType.toLowerCase().startsWith('multipart/form-data')
|
||||
) {
|
||||
bool hasFields = false;
|
||||
final mp = MultipartRequest(null, null);
|
||||
if (hasFields) {
|
||||
postBody = mp;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
return await apiClient.invokeAPI(
|
||||
path,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
nullableContentType,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
|
||||
/// Returns pet inventories by status
|
||||
///
|
||||
/// Returns a map of status codes to quantities
|
||||
Future<Map<String, int>> getInventory() async {
|
||||
final response = await getInventoryWithHttpInfo();
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
}
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return Map<String, int>.from(apiClient.deserialize(_decodeBodyBytes(response), 'Map<String, int>'));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Find purchase order by ID
|
||||
///
|
||||
/// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [int] orderId (required):
|
||||
/// ID of pet that needs to be fetched
|
||||
Future<Response> getOrderByIdWithHttpInfo(int orderId) async {
|
||||
// Verify required params are set.
|
||||
if (orderId == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: orderId');
|
||||
}
|
||||
|
||||
final path = '/store/order/{order_id}'.replaceAll('{format}', 'json')
|
||||
.replaceAll('{' + 'order_id' + '}', orderId.toString());
|
||||
|
||||
Object postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
final contentTypes = <String>[];
|
||||
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
|
||||
final authNames = <String>[];
|
||||
|
||||
if (
|
||||
nullableContentType != null &&
|
||||
nullableContentType.toLowerCase().startsWith('multipart/form-data')
|
||||
) {
|
||||
bool hasFields = false;
|
||||
final mp = MultipartRequest(null, null);
|
||||
if (hasFields) {
|
||||
postBody = mp;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
return await apiClient.invokeAPI(
|
||||
path,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
nullableContentType,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
|
||||
/// Find purchase order by ID
|
||||
///
|
||||
/// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [int] orderId (required):
|
||||
/// ID of pet that needs to be fetched
|
||||
Future<Order> getOrderById(int orderId) async {
|
||||
final response = await getOrderByIdWithHttpInfo(orderId);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
}
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Order') as Order;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Place an order for a pet
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [Order] order (required):
|
||||
/// order placed for purchasing the pet
|
||||
Future<Response> placeOrderWithHttpInfo(Order order) async {
|
||||
// Verify required params are set.
|
||||
if (order == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: order');
|
||||
}
|
||||
|
||||
final path = '/store/order'.replaceAll('{format}', 'json');
|
||||
|
||||
Object postBody = order;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
final contentTypes = <String>['application/json'];
|
||||
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
|
||||
final authNames = <String>[];
|
||||
|
||||
if (
|
||||
nullableContentType != null &&
|
||||
nullableContentType.toLowerCase().startsWith('multipart/form-data')
|
||||
) {
|
||||
bool hasFields = false;
|
||||
final mp = MultipartRequest(null, null);
|
||||
if (hasFields) {
|
||||
postBody = mp;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
return await apiClient.invokeAPI(
|
||||
path,
|
||||
'POST',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
nullableContentType,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
|
||||
/// Place an order for a pet
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [Order] order (required):
|
||||
/// order placed for purchasing the pet
|
||||
Future<Order> placeOrder(Order order) async {
|
||||
final response = await placeOrderWithHttpInfo(order);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
}
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Order') as Order;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,556 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
|
||||
class UserApi {
|
||||
UserApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
|
||||
final ApiClient apiClient;
|
||||
|
||||
/// Create user
|
||||
///
|
||||
/// This can only be done by the logged in user.
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [User] user (required):
|
||||
/// Created user object
|
||||
Future<Response> createUserWithHttpInfo(User user) async {
|
||||
// Verify required params are set.
|
||||
if (user == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: user');
|
||||
}
|
||||
|
||||
final path = '/user'.replaceAll('{format}', 'json');
|
||||
|
||||
Object postBody = user;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
final contentTypes = <String>['application/json'];
|
||||
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
|
||||
final authNames = <String>[];
|
||||
|
||||
if (
|
||||
nullableContentType != null &&
|
||||
nullableContentType.toLowerCase().startsWith('multipart/form-data')
|
||||
) {
|
||||
bool hasFields = false;
|
||||
final mp = MultipartRequest(null, null);
|
||||
if (hasFields) {
|
||||
postBody = mp;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
return await apiClient.invokeAPI(
|
||||
path,
|
||||
'POST',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
nullableContentType,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
|
||||
/// Create user
|
||||
///
|
||||
/// This can only be done by the logged in user.
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [User] user (required):
|
||||
/// Created user object
|
||||
Future<void> createUser(User user) async {
|
||||
final response = await createUserWithHttpInfo(user);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates list of users with given input array
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [List<User>] user (required):
|
||||
/// List of user object
|
||||
Future<Response> createUsersWithArrayInputWithHttpInfo(List<User> user) async {
|
||||
// Verify required params are set.
|
||||
if (user == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: user');
|
||||
}
|
||||
|
||||
final path = '/user/createWithArray'.replaceAll('{format}', 'json');
|
||||
|
||||
Object postBody = user;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
final contentTypes = <String>['application/json'];
|
||||
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
|
||||
final authNames = <String>[];
|
||||
|
||||
if (
|
||||
nullableContentType != null &&
|
||||
nullableContentType.toLowerCase().startsWith('multipart/form-data')
|
||||
) {
|
||||
bool hasFields = false;
|
||||
final mp = MultipartRequest(null, null);
|
||||
if (hasFields) {
|
||||
postBody = mp;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
return await apiClient.invokeAPI(
|
||||
path,
|
||||
'POST',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
nullableContentType,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
|
||||
/// Creates list of users with given input array
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [List<User>] user (required):
|
||||
/// List of user object
|
||||
Future<void> createUsersWithArrayInput(List<User> user) async {
|
||||
final response = await createUsersWithArrayInputWithHttpInfo(user);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates list of users with given input array
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [List<User>] user (required):
|
||||
/// List of user object
|
||||
Future<Response> createUsersWithListInputWithHttpInfo(List<User> user) async {
|
||||
// Verify required params are set.
|
||||
if (user == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: user');
|
||||
}
|
||||
|
||||
final path = '/user/createWithList'.replaceAll('{format}', 'json');
|
||||
|
||||
Object postBody = user;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
final contentTypes = <String>['application/json'];
|
||||
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
|
||||
final authNames = <String>[];
|
||||
|
||||
if (
|
||||
nullableContentType != null &&
|
||||
nullableContentType.toLowerCase().startsWith('multipart/form-data')
|
||||
) {
|
||||
bool hasFields = false;
|
||||
final mp = MultipartRequest(null, null);
|
||||
if (hasFields) {
|
||||
postBody = mp;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
return await apiClient.invokeAPI(
|
||||
path,
|
||||
'POST',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
nullableContentType,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
|
||||
/// Creates list of users with given input array
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [List<User>] user (required):
|
||||
/// List of user object
|
||||
Future<void> createUsersWithListInput(List<User> user) async {
|
||||
final response = await createUsersWithListInputWithHttpInfo(user);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
}
|
||||
}
|
||||
|
||||
/// Delete user
|
||||
///
|
||||
/// This can only be done by the logged in user.
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] username (required):
|
||||
/// The name that needs to be deleted
|
||||
Future<Response> deleteUserWithHttpInfo(String username) async {
|
||||
// Verify required params are set.
|
||||
if (username == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: username');
|
||||
}
|
||||
|
||||
final path = '/user/{username}'.replaceAll('{format}', 'json')
|
||||
.replaceAll('{' + 'username' + '}', username.toString());
|
||||
|
||||
Object postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
final contentTypes = <String>[];
|
||||
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
|
||||
final authNames = <String>[];
|
||||
|
||||
if (
|
||||
nullableContentType != null &&
|
||||
nullableContentType.toLowerCase().startsWith('multipart/form-data')
|
||||
) {
|
||||
bool hasFields = false;
|
||||
final mp = MultipartRequest(null, null);
|
||||
if (hasFields) {
|
||||
postBody = mp;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
return await apiClient.invokeAPI(
|
||||
path,
|
||||
'DELETE',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
nullableContentType,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
|
||||
/// Delete user
|
||||
///
|
||||
/// This can only be done by the logged in user.
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] username (required):
|
||||
/// The name that needs to be deleted
|
||||
Future<void> deleteUser(String username) async {
|
||||
final response = await deleteUserWithHttpInfo(username);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
}
|
||||
}
|
||||
|
||||
/// Get user by user name
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] username (required):
|
||||
/// The name that needs to be fetched. Use user1 for testing.
|
||||
Future<Response> getUserByNameWithHttpInfo(String username) async {
|
||||
// Verify required params are set.
|
||||
if (username == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: username');
|
||||
}
|
||||
|
||||
final path = '/user/{username}'.replaceAll('{format}', 'json')
|
||||
.replaceAll('{' + 'username' + '}', username.toString());
|
||||
|
||||
Object postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
final contentTypes = <String>[];
|
||||
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
|
||||
final authNames = <String>[];
|
||||
|
||||
if (
|
||||
nullableContentType != null &&
|
||||
nullableContentType.toLowerCase().startsWith('multipart/form-data')
|
||||
) {
|
||||
bool hasFields = false;
|
||||
final mp = MultipartRequest(null, null);
|
||||
if (hasFields) {
|
||||
postBody = mp;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
return await apiClient.invokeAPI(
|
||||
path,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
nullableContentType,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
|
||||
/// Get user by user name
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] username (required):
|
||||
/// The name that needs to be fetched. Use user1 for testing.
|
||||
Future<User> getUserByName(String username) async {
|
||||
final response = await getUserByNameWithHttpInfo(username);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
}
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'User') as User;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Logs user into the system
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] username (required):
|
||||
/// The user name for login
|
||||
///
|
||||
/// * [String] password (required):
|
||||
/// The password for login in clear text
|
||||
Future<Response> loginUserWithHttpInfo(String username, String password) async {
|
||||
// Verify required params are set.
|
||||
if (username == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: username');
|
||||
}
|
||||
if (password == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: password');
|
||||
}
|
||||
|
||||
final path = '/user/login'.replaceAll('{format}', 'json');
|
||||
|
||||
Object postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('', 'username', username));
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('', 'password', password));
|
||||
|
||||
final contentTypes = <String>[];
|
||||
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
|
||||
final authNames = <String>[];
|
||||
|
||||
if (
|
||||
nullableContentType != null &&
|
||||
nullableContentType.toLowerCase().startsWith('multipart/form-data')
|
||||
) {
|
||||
bool hasFields = false;
|
||||
final mp = MultipartRequest(null, null);
|
||||
if (hasFields) {
|
||||
postBody = mp;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
return await apiClient.invokeAPI(
|
||||
path,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
nullableContentType,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
|
||||
/// Logs user into the system
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] username (required):
|
||||
/// The user name for login
|
||||
///
|
||||
/// * [String] password (required):
|
||||
/// The password for login in clear text
|
||||
Future<String> loginUser(String username, String password) async {
|
||||
final response = await loginUserWithHttpInfo(username, password);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
}
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Logs out current logged in user session
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
Future<Response> logoutUserWithHttpInfo() async {
|
||||
final path = '/user/logout'.replaceAll('{format}', 'json');
|
||||
|
||||
Object postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
final contentTypes = <String>[];
|
||||
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
|
||||
final authNames = <String>[];
|
||||
|
||||
if (
|
||||
nullableContentType != null &&
|
||||
nullableContentType.toLowerCase().startsWith('multipart/form-data')
|
||||
) {
|
||||
bool hasFields = false;
|
||||
final mp = MultipartRequest(null, null);
|
||||
if (hasFields) {
|
||||
postBody = mp;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
return await apiClient.invokeAPI(
|
||||
path,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
nullableContentType,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
|
||||
/// Logs out current logged in user session
|
||||
Future<void> logoutUser() async {
|
||||
final response = await logoutUserWithHttpInfo();
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
}
|
||||
}
|
||||
|
||||
/// Updated user
|
||||
///
|
||||
/// This can only be done by the logged in user.
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] username (required):
|
||||
/// name that need to be deleted
|
||||
///
|
||||
/// * [User] user (required):
|
||||
/// Updated user object
|
||||
Future<Response> updateUserWithHttpInfo(String username, User user) async {
|
||||
// Verify required params are set.
|
||||
if (username == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: username');
|
||||
}
|
||||
if (user == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: user');
|
||||
}
|
||||
|
||||
final path = '/user/{username}'.replaceAll('{format}', 'json')
|
||||
.replaceAll('{' + 'username' + '}', username.toString());
|
||||
|
||||
Object postBody = user;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
final contentTypes = <String>['application/json'];
|
||||
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
|
||||
final authNames = <String>[];
|
||||
|
||||
if (
|
||||
nullableContentType != null &&
|
||||
nullableContentType.toLowerCase().startsWith('multipart/form-data')
|
||||
) {
|
||||
bool hasFields = false;
|
||||
final mp = MultipartRequest(null, null);
|
||||
if (hasFields) {
|
||||
postBody = mp;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
return await apiClient.invokeAPI(
|
||||
path,
|
||||
'PUT',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
nullableContentType,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
|
||||
/// Updated user
|
||||
///
|
||||
/// This can only be done by the logged in user.
|
||||
///
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] username (required):
|
||||
/// name that need to be deleted
|
||||
///
|
||||
/// * [User] user (required):
|
||||
/// Updated user object
|
||||
Future<void> updateUser(String username, User user) async {
|
||||
final response = await updateUserWithHttpInfo(username, user);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,309 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
class ApiClient {
|
||||
ApiClient({this.basePath = 'http://petstore.swagger.io:80/v2'}) {
|
||||
// Setup authentications (key: authentication name, value: authentication).
|
||||
_authentications[r'api_key'] = ApiKeyAuth('header', 'api_key');
|
||||
_authentications[r'api_key_query'] = ApiKeyAuth('query', 'api_key_query');
|
||||
_authentications[r'bearer_test'] = HttpBearerAuth();
|
||||
_authentications[r'http_basic_test'] = HttpBasicAuth();
|
||||
_authentications[r'petstore_auth'] = OAuth();
|
||||
}
|
||||
|
||||
final String basePath;
|
||||
|
||||
var _client = Client();
|
||||
|
||||
/// Returns the current HTTP [Client] instance to use in this class.
|
||||
///
|
||||
/// The return value is guaranteed to never be null.
|
||||
Client get client => _client;
|
||||
|
||||
/// Requests to use a new HTTP [Client] in this class.
|
||||
///
|
||||
/// If the [newClient] is null, an [ArgumentError] is thrown.
|
||||
set client(Client newClient) {
|
||||
if (newClient == null) {
|
||||
throw ArgumentError('New client instance cannot be null.');
|
||||
}
|
||||
_client = newClient;
|
||||
}
|
||||
|
||||
final _defaultHeaderMap = <String, String>{};
|
||||
final _authentications = <String, Authentication>{};
|
||||
|
||||
void addDefaultHeader(String key, String value) {
|
||||
_defaultHeaderMap[key] = value;
|
||||
}
|
||||
|
||||
Map<String,String> get defaultHeaderMap => _defaultHeaderMap;
|
||||
|
||||
/// returns an unmodifiable view of the authentications, since none should be added
|
||||
/// nor deleted
|
||||
Map<String, Authentication> get authentications =>
|
||||
Map.unmodifiable(_authentications);
|
||||
|
||||
dynamic deserialize(String json, String targetType, {bool growable}) {
|
||||
// Remove all spaces. Necessary for reg expressions as well.
|
||||
targetType = targetType.replaceAll(' ', '');
|
||||
|
||||
return targetType == 'String'
|
||||
? json
|
||||
: _deserialize(jsonDecode(json), targetType, growable: true == growable);
|
||||
}
|
||||
|
||||
String serialize(Object obj) => obj == null ? '' : json.encode(obj);
|
||||
|
||||
T getAuthentication<T extends Authentication>(String name) {
|
||||
final authentication = _authentications[name];
|
||||
return authentication is T ? authentication : null;
|
||||
}
|
||||
|
||||
// We don’t use a Map<String, String> for queryParams.
|
||||
// If collectionFormat is 'multi', a key might appear multiple times.
|
||||
Future<Response> invokeAPI(
|
||||
String path,
|
||||
String method,
|
||||
Iterable<QueryParam> queryParams,
|
||||
Object body,
|
||||
Map<String, String> headerParams,
|
||||
Map<String, String> formParams,
|
||||
String nullableContentType,
|
||||
List<String> authNames,
|
||||
) async {
|
||||
_updateParamsForAuth(authNames, queryParams, headerParams);
|
||||
|
||||
headerParams.addAll(_defaultHeaderMap);
|
||||
|
||||
final urlEncodedQueryParams = queryParams
|
||||
.where((param) => param.value != null)
|
||||
.map((param) => '$param');
|
||||
|
||||
final queryString = urlEncodedQueryParams.isNotEmpty
|
||||
? '?${urlEncodedQueryParams.join('&')}'
|
||||
: '';
|
||||
|
||||
final url = '$basePath$path$queryString';
|
||||
|
||||
if (nullableContentType != null) {
|
||||
headerParams['Content-Type'] = nullableContentType;
|
||||
}
|
||||
|
||||
try {
|
||||
// Special case for uploading a single file which isn’t a 'multipart/form-data'.
|
||||
if (
|
||||
body is MultipartFile && (nullableContentType == null ||
|
||||
!nullableContentType.toLowerCase().startsWith('multipart/form-data'))
|
||||
) {
|
||||
final request = StreamedRequest(method, Uri.parse(url));
|
||||
request.headers.addAll(headerParams);
|
||||
request.contentLength = body.length;
|
||||
body.finalize().listen(
|
||||
request.sink.add,
|
||||
onDone: request.sink.close,
|
||||
onError: (error, trace) => request.sink.close(),
|
||||
cancelOnError: true,
|
||||
);
|
||||
final response = await _client.send(request);
|
||||
return Response.fromStream(response);
|
||||
}
|
||||
|
||||
if (body is MultipartRequest) {
|
||||
final request = MultipartRequest(method, Uri.parse(url));
|
||||
request.fields.addAll(body.fields);
|
||||
request.files.addAll(body.files);
|
||||
request.headers.addAll(body.headers);
|
||||
request.headers.addAll(headerParams);
|
||||
final response = await _client.send(request);
|
||||
return Response.fromStream(response);
|
||||
}
|
||||
|
||||
final msgBody = nullableContentType == 'application/x-www-form-urlencoded'
|
||||
? formParams
|
||||
: serialize(body);
|
||||
final nullableHeaderParams = headerParams.isEmpty ? null : headerParams;
|
||||
|
||||
switch(method) {
|
||||
case 'POST': return await _client.post(url, headers: nullableHeaderParams, body: msgBody,);
|
||||
case 'PUT': return await _client.put(url, headers: nullableHeaderParams, body: msgBody,);
|
||||
case 'DELETE': return await _client.delete(url, headers: nullableHeaderParams,);
|
||||
case 'PATCH': return await _client.patch(url, headers: nullableHeaderParams, body: msgBody,);
|
||||
case 'HEAD': return await _client.head(url, headers: nullableHeaderParams,);
|
||||
case 'GET': return await _client.get(url, headers: nullableHeaderParams,);
|
||||
}
|
||||
} on SocketException catch (e, trace) {
|
||||
throw ApiException.withInner(HttpStatus.badRequest, 'Socket operation failed: $method $path', e, trace,);
|
||||
} on TlsException catch (e, trace) {
|
||||
throw ApiException.withInner(HttpStatus.badRequest, 'TLS/SSL communication failed: $method $path', e, trace,);
|
||||
} on IOException catch (e, trace) {
|
||||
throw ApiException.withInner(HttpStatus.badRequest, 'I/O operation failed: $method $path', e, trace,);
|
||||
} on ClientException catch (e, trace) {
|
||||
throw ApiException.withInner(HttpStatus.badRequest, 'HTTP connection failed: $method $path', e, trace,);
|
||||
} on Exception catch (e, trace) {
|
||||
throw ApiException.withInner(HttpStatus.badRequest, 'Exception occurred: $method $path', e, trace,);
|
||||
}
|
||||
|
||||
throw ApiException(HttpStatus.badRequest, 'Invalid HTTP operation: $method $path',);
|
||||
}
|
||||
|
||||
dynamic _deserialize(dynamic value, String targetType, {bool growable}) {
|
||||
try {
|
||||
switch (targetType) {
|
||||
case 'String':
|
||||
return '$value';
|
||||
case 'int':
|
||||
return value is int ? value : int.parse('$value');
|
||||
case 'bool':
|
||||
if (value is bool) {
|
||||
return value;
|
||||
}
|
||||
final valueString = '$value'.toLowerCase();
|
||||
return valueString == 'true' || valueString == '1';
|
||||
break;
|
||||
case 'double':
|
||||
return value is double ? value : double.parse('$value');
|
||||
case 'AdditionalPropertiesClass':
|
||||
return AdditionalPropertiesClass.fromJson(value);
|
||||
case 'Animal':
|
||||
return Animal.fromJson(value);
|
||||
case 'ApiResponse':
|
||||
return ApiResponse.fromJson(value);
|
||||
case 'ArrayOfArrayOfNumberOnly':
|
||||
return ArrayOfArrayOfNumberOnly.fromJson(value);
|
||||
case 'ArrayOfNumberOnly':
|
||||
return ArrayOfNumberOnly.fromJson(value);
|
||||
case 'ArrayTest':
|
||||
return ArrayTest.fromJson(value);
|
||||
case 'Capitalization':
|
||||
return Capitalization.fromJson(value);
|
||||
case 'Cat':
|
||||
return Cat.fromJson(value);
|
||||
case 'CatAllOf':
|
||||
return CatAllOf.fromJson(value);
|
||||
case 'Category':
|
||||
return Category.fromJson(value);
|
||||
case 'ClassModel':
|
||||
return ClassModel.fromJson(value);
|
||||
case 'Dog':
|
||||
return Dog.fromJson(value);
|
||||
case 'DogAllOf':
|
||||
return DogAllOf.fromJson(value);
|
||||
case 'EnumArrays':
|
||||
return EnumArrays.fromJson(value);
|
||||
case 'EnumClass':
|
||||
|
||||
return _$enumDecode(_$EnumClassEnumMap, value);
|
||||
case 'EnumTest':
|
||||
return EnumTest.fromJson(value);
|
||||
case 'FileSchemaTestClass':
|
||||
return FileSchemaTestClass.fromJson(value);
|
||||
case 'Foo':
|
||||
return Foo.fromJson(value);
|
||||
case 'FormatTest':
|
||||
return FormatTest.fromJson(value);
|
||||
case 'HasOnlyReadOnly':
|
||||
return HasOnlyReadOnly.fromJson(value);
|
||||
case 'HealthCheckResult':
|
||||
return HealthCheckResult.fromJson(value);
|
||||
case 'InlineResponseDefault':
|
||||
return InlineResponseDefault.fromJson(value);
|
||||
case 'MapTest':
|
||||
return MapTest.fromJson(value);
|
||||
case 'MixedPropertiesAndAdditionalPropertiesClass':
|
||||
return MixedPropertiesAndAdditionalPropertiesClass.fromJson(value);
|
||||
case 'Model200Response':
|
||||
return Model200Response.fromJson(value);
|
||||
case 'ModelClient':
|
||||
return ModelClient.fromJson(value);
|
||||
case 'ModelFile':
|
||||
return ModelFile.fromJson(value);
|
||||
case 'ModelList':
|
||||
return ModelList.fromJson(value);
|
||||
case 'ModelReturn':
|
||||
return ModelReturn.fromJson(value);
|
||||
case 'Name':
|
||||
return Name.fromJson(value);
|
||||
case 'NullableClass':
|
||||
return NullableClass.fromJson(value);
|
||||
case 'NumberOnly':
|
||||
return NumberOnly.fromJson(value);
|
||||
case 'Order':
|
||||
return Order.fromJson(value);
|
||||
case 'OuterComposite':
|
||||
return OuterComposite.fromJson(value);
|
||||
case 'OuterEnum':
|
||||
|
||||
return _$enumDecode(_$OuterEnumEnumMap, value);
|
||||
case 'OuterEnumDefaultValue':
|
||||
|
||||
return _$enumDecode(_$OuterEnumDefaultValueEnumMap, value);
|
||||
case 'OuterEnumInteger':
|
||||
|
||||
return _$enumDecode(_$OuterEnumIntegerEnumMap, value);
|
||||
case 'OuterEnumIntegerDefaultValue':
|
||||
|
||||
return _$enumDecode(_$OuterEnumIntegerDefaultValueEnumMap, value);
|
||||
case 'Pet':
|
||||
return Pet.fromJson(value);
|
||||
case 'ReadOnlyFirst':
|
||||
return ReadOnlyFirst.fromJson(value);
|
||||
case 'SpecialModelName':
|
||||
return SpecialModelName.fromJson(value);
|
||||
case 'Tag':
|
||||
return Tag.fromJson(value);
|
||||
case 'User':
|
||||
return User.fromJson(value);
|
||||
default:
|
||||
Match match;
|
||||
if (value is List && (match = _regList.firstMatch(targetType)) != null) {
|
||||
final newTargetType = match[1];
|
||||
return value
|
||||
.map((v) => _deserialize(v, newTargetType, growable: growable))
|
||||
.toList(growable: true == growable);
|
||||
}
|
||||
if (value is Set && (match = _regSet.firstMatch(targetType)) != null) {
|
||||
final newTargetType = match[1];
|
||||
return value
|
||||
.map((v) => _deserialize(v, newTargetType, growable: growable))
|
||||
.toSet();
|
||||
}
|
||||
if (value is Map && (match = _regMap.firstMatch(targetType)) != null) {
|
||||
final newTargetType = match[1];
|
||||
return Map.fromIterables(
|
||||
value.keys,
|
||||
value.values.map((v) => _deserialize(v, newTargetType, growable: growable)),
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} on Exception catch (e, stack) {
|
||||
throw ApiException.withInner(HttpStatus.internalServerError, 'Exception during deserialization.', e, stack,);
|
||||
}
|
||||
throw ApiException(HttpStatus.internalServerError, 'Could not find a suitable class for deserialization',);
|
||||
}
|
||||
|
||||
/// Update query and header parameters based on authentication settings.
|
||||
/// @param authNames The authentications to apply
|
||||
void _updateParamsForAuth(
|
||||
List<String> authNames,
|
||||
List<QueryParam> queryParams,
|
||||
Map<String, String> headerParams,
|
||||
) {
|
||||
authNames.forEach((authName) {
|
||||
final auth = _authentications[authName];
|
||||
if (auth == null) {
|
||||
throw ArgumentError('Authentication undefined: $authName');
|
||||
}
|
||||
auth.applyToParams(queryParams, headerParams);
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
class ApiException implements Exception {
|
||||
ApiException(this.code, this.message);
|
||||
|
||||
ApiException.withInner(this.code, this.message, this.innerException, this.stackTrace);
|
||||
|
||||
int code = 0;
|
||||
String message;
|
||||
Exception innerException;
|
||||
StackTrace stackTrace;
|
||||
|
||||
String toString() {
|
||||
if (message == null) {
|
||||
return 'ApiException';
|
||||
}
|
||||
if (innerException == null) {
|
||||
return 'ApiException $code: $message';
|
||||
}
|
||||
return 'ApiException $code: $message (Inner exception: $innerException)\n\n$stackTrace';
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
class QueryParam {
|
||||
const QueryParam(this.name, this.value);
|
||||
|
||||
final String name;
|
||||
final String value;
|
||||
|
||||
@override
|
||||
String toString() => '${Uri.encodeQueryComponent(name)}=${Uri.encodeQueryComponent(value)}';
|
||||
}
|
||||
|
||||
// Ported from the Java version.
|
||||
Iterable<QueryParam> _convertParametersForCollectionFormat(
|
||||
String collectionFormat,
|
||||
String name,
|
||||
dynamic value,
|
||||
) {
|
||||
final params = <QueryParam>[];
|
||||
|
||||
// preconditions
|
||||
if (name != null && !name.isEmpty && value != null) {
|
||||
if (value is List) {
|
||||
// get the collection format, default: csv
|
||||
collectionFormat = (collectionFormat == null || collectionFormat.isEmpty)
|
||||
? 'csv'
|
||||
: collectionFormat;
|
||||
|
||||
if (collectionFormat == 'multi') {
|
||||
return value.map((v) => QueryParam(name, parameterToString(v)));
|
||||
}
|
||||
|
||||
final delimiter = _delimiters[collectionFormat] ?? ',';
|
||||
|
||||
params.add(QueryParam(name, value.map((v) => parameterToString(v)).join(delimiter)));
|
||||
} else {
|
||||
params.add(QueryParam(name, parameterToString(value)));
|
||||
}
|
||||
}
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
/// Format the given parameter object into a [String].
|
||||
String parameterToString(dynamic value) {
|
||||
if (value == null) {
|
||||
return '';
|
||||
}
|
||||
if (value is DateTime) {
|
||||
return value.toUtc().toIso8601String();
|
||||
}
|
||||
if (value is EnumClass) {
|
||||
|
||||
return _$EnumClassEnumMap[value];
|
||||
}
|
||||
if (value is OuterEnum) {
|
||||
|
||||
return _$OuterEnumEnumMap[value];
|
||||
}
|
||||
if (value is OuterEnumDefaultValue) {
|
||||
|
||||
return _$OuterEnumDefaultValueEnumMap[value];
|
||||
}
|
||||
if (value is OuterEnumInteger) {
|
||||
|
||||
return _$OuterEnumIntegerEnumMap[value];
|
||||
}
|
||||
if (value is OuterEnumIntegerDefaultValue) {
|
||||
|
||||
return _$OuterEnumIntegerDefaultValueEnumMap[value];
|
||||
}
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
/// Returns the decoded body as UTF-8 if the given headers indicate an 'application/json'
|
||||
/// content type. Otherwise, returns the decoded body as decoded by dart:http package.
|
||||
String _decodeBodyBytes(Response response) {
|
||||
final contentType = response.headers['content-type'];
|
||||
return contentType != null && contentType.toLowerCase().startsWith('application/json')
|
||||
? response.bodyBytes == null ? null : utf8.decode(response.bodyBytes)
|
||||
: response.body;
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
class ApiKeyAuth implements Authentication {
|
||||
ApiKeyAuth(this.location, this.paramName);
|
||||
|
||||
final String location;
|
||||
final String paramName;
|
||||
|
||||
String apiKeyPrefix;
|
||||
String apiKey;
|
||||
|
||||
@override
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
final value = apiKeyPrefix == null ? apiKey : '$apiKeyPrefix $apiKey';
|
||||
|
||||
if (location == 'query' && value != null) {
|
||||
queryParams.add(QueryParam(paramName, value));
|
||||
} else if (location == 'header' && value != null) {
|
||||
headerParams[paramName] = value;
|
||||
} else if (location == 'cookie' && value != null) {
|
||||
headerParams.update('Cookie', (String existingCookie) {
|
||||
return '$existingCookie; $paramName=$value';
|
||||
}, ifAbsent: () => '$paramName=$value');
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
abstract class Authentication {
|
||||
/// Apply authentication settings to header and query params.
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams);
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
class HttpBasicAuth implements Authentication {
|
||||
String username;
|
||||
String password;
|
||||
|
||||
@override
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
final credentials = (username ?? '') + ':' + (password ?? '');
|
||||
headerParams['Authorization'] = 'Basic ${base64.encode(utf8.encode(credentials))}';
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
typedef HttpBearerAuthProvider = String Function();
|
||||
|
||||
class HttpBearerAuth implements Authentication {
|
||||
HttpBearerAuth();
|
||||
|
||||
dynamic _accessToken;
|
||||
|
||||
dynamic get accessToken => _accessToken;
|
||||
|
||||
set accessToken(dynamic accessToken) {
|
||||
if (accessToken is! String && accessToken is! HttpBearerAuthProvider) {
|
||||
throw ArgumentError('Type of Bearer accessToken should be a String or a String Function().');
|
||||
}
|
||||
this._accessToken = accessToken;
|
||||
}
|
||||
|
||||
@override
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
if (_accessToken is String) {
|
||||
headerParams['Authorization'] = 'Bearer $_accessToken';
|
||||
} else if (_accessToken is HttpBearerAuthProvider) {
|
||||
headerParams['Authorization'] = 'Bearer ${_accessToken()}';
|
||||
} else {
|
||||
throw ArgumentError('Type of Bearer accessToken should be a String or a String Function().');
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
class OAuth implements Authentication {
|
||||
OAuth({this.accessToken});
|
||||
|
||||
String accessToken;
|
||||
|
||||
@override
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
if (accessToken != null) {
|
||||
headerParams['Authorization'] = 'Bearer $accessToken';
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
@JsonSerializable(
|
||||
checked: true,
|
||||
createToJson: true,
|
||||
disallowUnrecognizedKeys: true,
|
||||
explicitToJson: true,
|
||||
)
|
||||
class AdditionalPropertiesClass {
|
||||
/// Returns a new [AdditionalPropertiesClass] instance.
|
||||
AdditionalPropertiesClass({
|
||||
this.mapProperty = const {},
|
||||
this.mapOfMapProperty = const {},
|
||||
});
|
||||
|
||||
@JsonKey(
|
||||
nullable: false,
|
||||
name: r'map_property',
|
||||
required: false,
|
||||
)
|
||||
Map<String, String> mapProperty;
|
||||
|
||||
@JsonKey(
|
||||
nullable: false,
|
||||
name: r'map_of_map_property',
|
||||
required: false,
|
||||
)
|
||||
Map<String, Map<String, String>> mapOfMapProperty;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is AdditionalPropertiesClass &&
|
||||
other.mapProperty == mapProperty &&
|
||||
other.mapOfMapProperty == mapOfMapProperty;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
(mapProperty == null ? 0 : mapProperty.hashCode) +
|
||||
(mapOfMapProperty == null ? 0 : mapOfMapProperty.hashCode);
|
||||
|
||||
|
||||
factory AdditionalPropertiesClass.fromJson(Map<String, dynamic> json) => _$AdditionalPropertiesClassFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$AdditionalPropertiesClassToJson(this);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return toJson().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,60 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
@JsonSerializable(
|
||||
checked: true,
|
||||
createToJson: true,
|
||||
disallowUnrecognizedKeys: true,
|
||||
explicitToJson: true,
|
||||
)
|
||||
class Animal {
|
||||
/// Returns a new [Animal] instance.
|
||||
Animal({
|
||||
@required this.className,
|
||||
this.color = 'red',
|
||||
});
|
||||
|
||||
@JsonKey(
|
||||
nullable: false,
|
||||
name: r'className',
|
||||
required: true,
|
||||
)
|
||||
String className;
|
||||
|
||||
@JsonKey(
|
||||
nullable: false,
|
||||
name: r'color',
|
||||
required: false,
|
||||
)
|
||||
String color;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is Animal &&
|
||||
other.className == className &&
|
||||
other.color == color;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
(className == null ? 0 : className.hashCode) +
|
||||
(color == null ? 0 : color.hashCode);
|
||||
|
||||
|
||||
factory Animal.fromJson(Map<String, dynamic> json) => _$AnimalFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$AnimalToJson(this);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return toJson().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,70 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
@JsonSerializable(
|
||||
checked: true,
|
||||
createToJson: true,
|
||||
disallowUnrecognizedKeys: true,
|
||||
explicitToJson: true,
|
||||
)
|
||||
class ApiResponse {
|
||||
/// Returns a new [ApiResponse] instance.
|
||||
ApiResponse({
|
||||
this.code,
|
||||
this.type,
|
||||
this.message,
|
||||
});
|
||||
|
||||
@JsonKey(
|
||||
nullable: false,
|
||||
name: r'code',
|
||||
required: false,
|
||||
)
|
||||
int code;
|
||||
|
||||
@JsonKey(
|
||||
nullable: false,
|
||||
name: r'type',
|
||||
required: false,
|
||||
)
|
||||
String type;
|
||||
|
||||
@JsonKey(
|
||||
nullable: false,
|
||||
name: r'message',
|
||||
required: false,
|
||||
)
|
||||
String message;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is ApiResponse &&
|
||||
other.code == code &&
|
||||
other.type == type &&
|
||||
other.message == message;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
(code == null ? 0 : code.hashCode) +
|
||||
(type == null ? 0 : type.hashCode) +
|
||||
(message == null ? 0 : message.hashCode);
|
||||
|
||||
|
||||
factory ApiResponse.fromJson(Map<String, dynamic> json) => _$ApiResponseFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$ApiResponseToJson(this);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return toJson().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user