mirror of
https://github.com/jlengrand/openapi-generator.git
synced 2026-03-10 08:31:23 +00:00
[dart] Remove old dio generator (to be replaced with dart-dio-next) (#12109)
* remove old `dart-dio` generator which will be replaced by `dart-dio-next` in a seperate PR * remove left-over `DartJaguarClinetCodegen` class which was sunset a while ago and is unused
This commit is contained in:
39
.github/workflows/samples-dart.yaml
vendored
39
.github/workflows/samples-dart.yaml
vendored
@@ -13,41 +13,8 @@ on:
|
||||
- 'samples/openapi3/client/petstore/dart*/**'
|
||||
|
||||
jobs:
|
||||
tests-dart-2-10:
|
||||
name: Tests Dart 2.10
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 8
|
||||
- name: Cache maven dependencies
|
||||
uses: actions/cache@v3
|
||||
env:
|
||||
cache-name: maven-repository
|
||||
with:
|
||||
path: |
|
||||
~/.m2/repository
|
||||
~/.gradle
|
||||
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
|
||||
- name: Cache test dependencies
|
||||
uses: actions/cache@v3
|
||||
env:
|
||||
cache-name: pub-cache
|
||||
with:
|
||||
path: $PUB_CACHE
|
||||
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('samples/**/pubspec.yaml') }}
|
||||
- uses: dart-lang/setup-dart@v1
|
||||
with:
|
||||
sdk: 2.10.5
|
||||
- name: Run tests
|
||||
uses: ./.github/actions/run-samples
|
||||
with:
|
||||
name: samples.dart-2.10
|
||||
|
||||
tests-dart-2-13:
|
||||
name: Tests Dart 2.13
|
||||
tests-dart:
|
||||
name: Tests Dart
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
@@ -77,4 +44,4 @@ jobs:
|
||||
- name: Run tests
|
||||
uses: ./.github/actions/run-samples
|
||||
with:
|
||||
name: samples.dart-2.13
|
||||
name: samples.dart
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
generatorName: dart-dio
|
||||
outputDir: samples/openapi3/client/petstore/dart-dio/petstore_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/dart-dio
|
||||
typeMappings:
|
||||
Client: "ModelClient"
|
||||
File: "ModelFile"
|
||||
EnumClass: "ModelEnumClass"
|
||||
additionalProperties:
|
||||
hideGenerationTimestamp: "true"
|
||||
@@ -1,7 +0,0 @@
|
||||
generatorName: dart-dio
|
||||
outputDir: samples/openapi3/client/petstore/dart-dio/petstore_client_lib
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/dart-dio
|
||||
additionalProperties:
|
||||
hideGenerationTimestamp: "true"
|
||||
enumUnknownDefaultCase: "true"
|
||||
@@ -22,7 +22,6 @@ The following generators are available:
|
||||
* [csharp-dotnet2 (deprecated)](generators/csharp-dotnet2.md)
|
||||
* [csharp-netcore](generators/csharp-netcore.md)
|
||||
* [dart](generators/dart.md)
|
||||
* [dart-dio](generators/dart-dio.md)
|
||||
* [dart-dio-next (experimental)](generators/dart-dio-next.md)
|
||||
* [eiffel](generators/eiffel.md)
|
||||
* [elixir](generators/elixir.md)
|
||||
|
||||
@@ -1,326 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.samskivert.mustache.Mustache;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.ClientModificationFeature;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.openapitools.codegen.utils.ProcessUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class DartDioClientCodegen extends AbstractDartCodegen {
|
||||
|
||||
private final Logger LOGGER = LoggerFactory.getLogger(DartDioClientCodegen.class);
|
||||
|
||||
public static final String NULLABLE_FIELDS = "nullableFields";
|
||||
public static final String DATE_LIBRARY = "dateLibrary";
|
||||
|
||||
private static final String CLIENT_NAME = "clientName";
|
||||
|
||||
private boolean nullableFields = false;
|
||||
private String dateLibrary = "core";
|
||||
|
||||
public DartDioClientCodegen() {
|
||||
super();
|
||||
|
||||
modifyFeatureSet(features -> features
|
||||
.includeClientModificationFeatures(
|
||||
ClientModificationFeature.Authorizations,
|
||||
ClientModificationFeature.UserAgent
|
||||
)
|
||||
);
|
||||
|
||||
outputFolder = "generated-code/dart-dio";
|
||||
embeddedTemplateDir = "dart-dio";
|
||||
this.setTemplateDir(embeddedTemplateDir);
|
||||
|
||||
cliOptions.add(new CliOption(NULLABLE_FIELDS, "Make all fields nullable in the JSON payload"));
|
||||
CliOption dateLibrary = new CliOption(DATE_LIBRARY, "Option. Date library to use").defaultValue(this.getDateLibrary());
|
||||
Map<String, String> dateOptions = new HashMap<>();
|
||||
dateOptions.put("core", "Dart core library (DateTime)");
|
||||
dateOptions.put("timemachine", "Time Machine is date and time library for Flutter, Web, and Server with support for timezones, calendars, cultures, formatting and parsing.");
|
||||
dateLibrary.setEnum(dateOptions);
|
||||
cliOptions.add(dateLibrary);
|
||||
|
||||
typeMapping.put("Array", "BuiltList");
|
||||
typeMapping.put("array", "BuiltList");
|
||||
typeMapping.put("List", "BuiltList");
|
||||
typeMapping.put("set", "BuiltSet");
|
||||
typeMapping.put("map", "BuiltMap");
|
||||
typeMapping.put("file", "Uint8List");
|
||||
typeMapping.put("binary", "Uint8List");
|
||||
typeMapping.put("object", "JsonObject");
|
||||
typeMapping.put("AnyType", "JsonObject");
|
||||
|
||||
imports.put("BuiltList", "package:built_collection/built_collection.dart");
|
||||
imports.put("BuiltSet", "package:built_collection/built_collection.dart");
|
||||
imports.put("BuiltMap", "package:built_collection/built_collection.dart");
|
||||
imports.put("JsonObject", "package:built_value/json_object.dart");
|
||||
imports.put("Uint8List", "dart:typed_data");
|
||||
}
|
||||
|
||||
public String getDateLibrary() {
|
||||
return dateLibrary;
|
||||
}
|
||||
|
||||
public void setDateLibrary(String library) {
|
||||
this.dateLibrary = library;
|
||||
}
|
||||
|
||||
public boolean getNullableFields() {
|
||||
return nullableFields;
|
||||
}
|
||||
|
||||
public void setNullableFields(boolean nullableFields) {
|
||||
this.nullableFields = nullableFields;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "dart-dio";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates a Dart Dio client library.";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ImmutableMap.Builder<String, Mustache.Lambda> addMustacheLambdas() {
|
||||
return super.addMustacheLambdas()
|
||||
.put("escapeBuiltValueEnum", (fragment, writer) -> {
|
||||
// Raw strings don't work correctly in built_value enum strings.
|
||||
// Dollar signs need to be escaped in to make them work.
|
||||
// @BuiltValueEnumConst(wireName: r'$') produces '$' in generated code.
|
||||
// @BuiltValueEnumConst(wireName: r'\$') produces '\$' in generated code.
|
||||
writer.write(fragment.execute().replace("$", "\\$"));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toDefaultValue(Schema schema) {
|
||||
if (schema.getDefault() != null) {
|
||||
if (ModelUtils.isArraySchema(schema)) {
|
||||
if (ModelUtils.isSet(schema)) {
|
||||
return "SetBuilder()";
|
||||
}
|
||||
return "ListBuilder()";
|
||||
}
|
||||
if (ModelUtils.isMapSchema(schema)) {
|
||||
return "MapBuilder()";
|
||||
}
|
||||
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().replaceAll("'", "\\'") + "'";
|
||||
}
|
||||
return schema.getDefault().toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@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(NULLABLE_FIELDS)) {
|
||||
this.setNullableFields(convertPropertyToBooleanAndWriteBack(NULLABLE_FIELDS));
|
||||
} else {
|
||||
//not set, use to be passed to template
|
||||
additionalProperties.put(NULLABLE_FIELDS, nullableFields);
|
||||
}
|
||||
|
||||
if (!additionalProperties.containsKey(CLIENT_NAME)) {
|
||||
additionalProperties.put(CLIENT_NAME, org.openapitools.codegen.utils.StringUtils.camelize(pubName));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(DATE_LIBRARY)) {
|
||||
this.setDateLibrary(additionalProperties.get(DATE_LIBRARY).toString());
|
||||
}
|
||||
// make api and model doc path available in mustache template
|
||||
additionalProperties.put("apiDocPath", apiDocPath);
|
||||
additionalProperties.put("modelDocPath", modelDocPath);
|
||||
|
||||
final String libFolder = sourceFolder + File.separator + "lib";
|
||||
supportingFiles.add(new SupportingFile("pubspec.mustache", "", "pubspec.yaml"));
|
||||
supportingFiles.add(new SupportingFile("analysis_options.mustache", "", "analysis_options.yaml"));
|
||||
supportingFiles.add(new SupportingFile("apilib.mustache", libFolder, "api.dart"));
|
||||
supportingFiles.add(new SupportingFile("api_util.mustache", libFolder, "api_util.dart"));
|
||||
|
||||
supportingFiles.add(new SupportingFile("serializers.mustache", libFolder, "serializers.dart"));
|
||||
|
||||
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
|
||||
final String authFolder = libFolder + File.separator + "auth";
|
||||
supportingFiles.add(new SupportingFile("auth/api_key_auth.mustache", authFolder, "api_key_auth.dart"));
|
||||
supportingFiles.add(new SupportingFile("auth/basic_auth.mustache", authFolder, "basic_auth.dart"));
|
||||
supportingFiles.add(new SupportingFile("auth/oauth.mustache", authFolder, "oauth.dart"));
|
||||
supportingFiles.add(new SupportingFile("auth/auth.mustache", authFolder, "auth.dart"));
|
||||
|
||||
if ("core".equals(dateLibrary)) {
|
||||
// this option uses the same classes as normal dart generator
|
||||
additionalProperties.put("core", "true");
|
||||
} else if ("timemachine".equals(dateLibrary)) {
|
||||
additionalProperties.put("timeMachine", "true");
|
||||
typeMapping.put("date", "OffsetDate");
|
||||
typeMapping.put("Date", "OffsetDate");
|
||||
typeMapping.put("DateTime", "OffsetDateTime");
|
||||
typeMapping.put("datetime", "OffsetDateTime");
|
||||
imports.put("OffsetDate", "package:time_machine/time_machine.dart");
|
||||
imports.put("OffsetDateTime", "package:time_machine/time_machine.dart");
|
||||
supportingFiles.add(new SupportingFile("local_date_serializer.mustache", libFolder, "local_date_serializer.dart"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelsMap postProcessModels(ModelsMap objs) {
|
||||
objs = super.postProcessModels(objs);
|
||||
List<ModelMap> models = objs.getModels();
|
||||
ProcessUtils.addIndexToProperties(models, 1);
|
||||
|
||||
for (ModelMap mo : models) {
|
||||
CodegenModel cm = mo.getModel();
|
||||
cm.imports = rewriteImports(cm.imports);
|
||||
cm.vendorExtensions.put("x-has-vars", !cm.vars.isEmpty());
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
|
||||
super.postProcessModelProperty(model, property);
|
||||
if (nullableFields) {
|
||||
property.isNullable = true;
|
||||
}
|
||||
|
||||
if (property.isEnum && property.getComposedSchemas() == null) {
|
||||
// enums are generated with built_value and make use of BuiltSet
|
||||
model.imports.add("BuiltSet");
|
||||
}
|
||||
|
||||
property.getVendorExtensions().put("x-built-value-serializer-type", createBuiltValueSerializerType(property));
|
||||
}
|
||||
|
||||
private String createBuiltValueSerializerType(CodegenProperty property) {
|
||||
final StringBuilder sb = new StringBuilder("const FullType(");
|
||||
if (property.isContainer) {
|
||||
appendCollection(sb, property);
|
||||
} else {
|
||||
sb.append(property.datatypeWithEnum);
|
||||
}
|
||||
sb.append(")");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private void appendCollection(StringBuilder sb, CodegenProperty property) {
|
||||
sb.append(property.baseType);
|
||||
sb.append(", [FullType(");
|
||||
if (property.isMap) {
|
||||
// a map always has string keys
|
||||
sb.append("String), FullType(");
|
||||
}
|
||||
if (property.items.isContainer) {
|
||||
appendCollection(sb, property.items);
|
||||
} else {
|
||||
sb.append(property.items.datatypeWithEnum);
|
||||
}
|
||||
sb.append(")]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
super.postProcessOperationsWithModels(objs, allModels);
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
|
||||
Set<Map<String, Object>> serializers = new HashSet<>();
|
||||
Set<String> resultImports = new HashSet<>();
|
||||
|
||||
for (CodegenOperation op : operationList) {
|
||||
for (CodegenParameter param : op.bodyParams) {
|
||||
if (param.baseType != null && param.baseType.equalsIgnoreCase("Uint8List") && op.isMultipart) {
|
||||
param.baseType = "MultipartFile";
|
||||
param.dataType = "MultipartFile";
|
||||
}
|
||||
if (param.isContainer) {
|
||||
final Map<String, Object> serializer = new HashMap<>();
|
||||
serializer.put("isArray", param.isArray);
|
||||
serializer.put("uniqueItems", param.uniqueItems);
|
||||
serializer.put("isMap", param.isMap);
|
||||
serializer.put("baseType", param.baseType);
|
||||
serializers.add(serializer);
|
||||
}
|
||||
}
|
||||
|
||||
resultImports.addAll(rewriteImports(op.imports));
|
||||
if (op.getHasFormParams()) {
|
||||
resultImports.add("package:" + pubName + "/api_util.dart");
|
||||
}
|
||||
|
||||
if (op.returnContainer != null) {
|
||||
final Map<String, Object> serializer = new HashMap<>();
|
||||
serializer.put("isArray", Objects.equals("array", op.returnContainer) || Objects.equals("set", op.returnContainer));
|
||||
serializer.put("uniqueItems", op.uniqueItems);
|
||||
serializer.put("isMap", Objects.equals("map", op.returnContainer));
|
||||
serializer.put("baseType", op.returnBaseType);
|
||||
serializers.add(serializer);
|
||||
}
|
||||
}
|
||||
|
||||
// for some reason "import" structure is changed ..
|
||||
objs.put("imports", resultImports.stream().sorted().collect(Collectors.toList()));
|
||||
objs.put("serializers", serializers);
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
private Set<String> rewriteImports(Set<String> originalImports) {
|
||||
Set<String> resultImports = Sets.newHashSet();
|
||||
for (String modelImport : originalImports) {
|
||||
if (imports.containsKey(modelImport)) {
|
||||
resultImports.add(imports.get(modelImport));
|
||||
} else {
|
||||
resultImports.add("package:" + pubName + "/model/" + underscore(modelImport) + ".dart");
|
||||
}
|
||||
}
|
||||
return resultImports;
|
||||
}
|
||||
}
|
||||
@@ -1,334 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.utils.ProcessUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class DartJaguarClientCodegen extends AbstractDartCodegen {
|
||||
|
||||
private final Logger LOGGER = LoggerFactory.getLogger(DartJaguarClientCodegen.class);
|
||||
|
||||
private static final String NULLABLE_FIELDS = "nullableFields";
|
||||
private static final String SERIALIZATION_FORMAT = "serialization";
|
||||
private static final String IS_FORMAT_JSON = "jsonFormat";
|
||||
private static final String IS_FORMAT_PROTO = "protoFormat";
|
||||
private static final String CLIENT_NAME = "clientName";
|
||||
|
||||
private final Set<String> modelToIgnore = new HashSet<>();
|
||||
private final HashMap<String, String> protoTypeMapping = new HashMap<>();
|
||||
|
||||
private static final String SERIALIZATION_JSON = "json";
|
||||
private static final String SERIALIZATION_PROTO = "proto";
|
||||
|
||||
private boolean nullableFields = true;
|
||||
|
||||
public DartJaguarClientCodegen() {
|
||||
super();
|
||||
|
||||
modelToIgnore.add("datetime");
|
||||
modelToIgnore.add("map");
|
||||
modelToIgnore.add("object");
|
||||
modelToIgnore.add("list");
|
||||
modelToIgnore.add("file");
|
||||
modelToIgnore.add("list<int>");
|
||||
|
||||
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
|
||||
)
|
||||
.wireFormatFeatures(EnumSet.of(
|
||||
WireFormatFeature.JSON,
|
||||
WireFormatFeature.PROTOBUF
|
||||
))
|
||||
.includeClientModificationFeatures(
|
||||
ClientModificationFeature.BasePath
|
||||
)
|
||||
);
|
||||
|
||||
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
|
||||
.stability(Stability.DEPRECATED)
|
||||
.build();
|
||||
|
||||
outputFolder = "generated-code/dart-jaguar";
|
||||
embeddedTemplateDir = templateDir = "dart-jaguar";
|
||||
|
||||
cliOptions.add(new CliOption(NULLABLE_FIELDS, "Is the null fields should be in the JSON payload"));
|
||||
cliOptions.add(new CliOption(SERIALIZATION_FORMAT, "Choose serialization format JSON or PROTO is supported"));
|
||||
|
||||
typeMapping.put("file", "List<int>");
|
||||
typeMapping.put("binary", "List<int>");
|
||||
|
||||
protoTypeMapping.put("Array", "repeated");
|
||||
protoTypeMapping.put("array", "repeated");
|
||||
protoTypeMapping.put("List", "repeated");
|
||||
protoTypeMapping.put("boolean", "bool");
|
||||
protoTypeMapping.put("string", "string");
|
||||
protoTypeMapping.put("char", "string");
|
||||
protoTypeMapping.put("int", "int32");
|
||||
protoTypeMapping.put("long", "int64");
|
||||
protoTypeMapping.put("short", "int32");
|
||||
protoTypeMapping.put("number", "double");
|
||||
protoTypeMapping.put("float", "float");
|
||||
protoTypeMapping.put("double", "double");
|
||||
protoTypeMapping.put("object", "google.protobuf.Any");
|
||||
protoTypeMapping.put("integer", "int32");
|
||||
protoTypeMapping.put("Date", "google.protobuf.Timestamp");
|
||||
protoTypeMapping.put("date", "google.protobuf.Timestamp");
|
||||
protoTypeMapping.put("File", "bytes");
|
||||
protoTypeMapping.put("file", "bytes");
|
||||
protoTypeMapping.put("binary", "bytes");
|
||||
protoTypeMapping.put("UUID", "string");
|
||||
protoTypeMapping.put("URI", "string");
|
||||
protoTypeMapping.put("ByteArray", "bytes");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "dart-jaguar";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates a Dart Jaguar client library.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toDefaultValue(Schema schema) {
|
||||
if (ModelUtils.isMapSchema(schema)) {
|
||||
return "const {}";
|
||||
} else if (ModelUtils.isArraySchema(schema)) {
|
||||
return "const []";
|
||||
}
|
||||
|
||||
if (schema.getDefault() != null) {
|
||||
if (ModelUtils.isStringSchema(schema)) {
|
||||
return "'" + schema.getDefault().toString().replaceAll("'", "\\'") + "'";
|
||||
}
|
||||
return schema.getDefault().toString();
|
||||
} else {
|
||||
return "null";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
if (additionalProperties.containsKey(NULLABLE_FIELDS)) {
|
||||
nullableFields = convertPropertyToBooleanAndWriteBack(NULLABLE_FIELDS);
|
||||
} else {
|
||||
//not set, use to be passed to template
|
||||
additionalProperties.put(NULLABLE_FIELDS, nullableFields);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(SERIALIZATION_FORMAT)) {
|
||||
String serialization = ((String) additionalProperties.get(SERIALIZATION_FORMAT));
|
||||
boolean isProto = serialization.equalsIgnoreCase(SERIALIZATION_PROTO);
|
||||
additionalProperties.put(IS_FORMAT_JSON, serialization.equalsIgnoreCase(SERIALIZATION_JSON));
|
||||
additionalProperties.put(IS_FORMAT_PROTO, isProto);
|
||||
|
||||
modelTemplateFiles.put("model.mustache", isProto ? ".proto" : ".dart");
|
||||
|
||||
} else {
|
||||
//not set, use to be passed to template
|
||||
additionalProperties.put(IS_FORMAT_JSON, true);
|
||||
additionalProperties.put(IS_FORMAT_PROTO, false);
|
||||
}
|
||||
|
||||
additionalProperties.put(CLIENT_NAME, org.openapitools.codegen.utils.StringUtils.camelize(pubName));
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// make api and model doc path available in mustache template
|
||||
additionalProperties.put("apiDocPath", apiDocPath);
|
||||
additionalProperties.put("modelDocPath", modelDocPath);
|
||||
|
||||
final String libFolder = sourceFolder + File.separator + "lib";
|
||||
supportingFiles.add(new SupportingFile("pubspec.mustache", "", "pubspec.yaml"));
|
||||
supportingFiles.add(new SupportingFile("analysis_options.mustache", "", "analysis_options.yaml"));
|
||||
supportingFiles.add(new SupportingFile("apilib.mustache", libFolder, "api.dart"));
|
||||
|
||||
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
supportingFiles.add(new SupportingFile("travis.mustache", "", ".travis.yml"));
|
||||
|
||||
final String authFolder = sourceFolder + File.separator + "lib" + File.separator + "auth";
|
||||
supportingFiles.add(new SupportingFile("auth/api_key_auth.mustache", authFolder, "api_key_auth.dart"));
|
||||
supportingFiles.add(new SupportingFile("auth/basic_auth.mustache", authFolder, "basic_auth.dart"));
|
||||
supportingFiles.add(new SupportingFile("auth/oauth.mustache", authFolder, "oauth.dart"));
|
||||
supportingFiles.add(new SupportingFile("auth/auth.mustache", authFolder, "auth.dart"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelsMap postProcessModels(ModelsMap objs) {
|
||||
objs = super.postProcessModels(objs);
|
||||
List<ModelMap> models = objs.getModels();
|
||||
ProcessUtils.addIndexToProperties(models, 1);
|
||||
|
||||
for (ModelMap mo : models) {
|
||||
Set<String> modelImports = new HashSet<>();
|
||||
CodegenModel cm = mo.getModel();
|
||||
for (String modelImport : cm.imports) {
|
||||
if (!modelToIgnore.contains(modelImport.toLowerCase(Locale.ROOT))) {
|
||||
modelImports.add(underscore(modelImport));
|
||||
}
|
||||
}
|
||||
|
||||
for (CodegenProperty p : cm.vars) {
|
||||
String protoType = protoTypeMapping.get(p.openApiType);
|
||||
if (p.isArray) {
|
||||
String innerType = protoTypeMapping.get(p.mostInnerItems.openApiType);
|
||||
protoType = protoType + " " + (innerType == null ? p.mostInnerItems.openApiType : innerType);
|
||||
}
|
||||
p.vendorExtensions.put("x-proto-type", protoType == null ? p.openApiType : protoType);
|
||||
}
|
||||
|
||||
cm.imports = modelImports;
|
||||
boolean hasVars = cm.vars.size() > 0;
|
||||
cm.vendorExtensions.put("x-has-vars", hasVars);
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
objs = super.postProcessOperationsWithModels(objs, allModels);
|
||||
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
|
||||
Set<String> modelImports = new HashSet<>();
|
||||
Set<String> fullImports = new HashSet<>();
|
||||
for (CodegenOperation op : operationList) {
|
||||
op.httpMethod = StringUtils.capitalize(op.httpMethod.toLowerCase(Locale.ROOT));
|
||||
boolean isJson = true; //default to JSON
|
||||
boolean isForm = false;
|
||||
boolean isProto = false;
|
||||
boolean isMultipart = false;
|
||||
if (op.consumes != null) {
|
||||
for (Map<String, String> consume : op.consumes) {
|
||||
if (consume.containsKey("mediaType")) {
|
||||
String type = consume.get("mediaType");
|
||||
isJson = type.equalsIgnoreCase("application/json");
|
||||
isProto = type.equalsIgnoreCase("application/octet-stream");
|
||||
isForm = type.equalsIgnoreCase("application/x-www-form-urlencoded");
|
||||
isMultipart = type.equalsIgnoreCase("multipart/form-data");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (CodegenParameter param : op.allParams) {
|
||||
if (param.baseType != null && param.baseType.equalsIgnoreCase("List<int>") && isMultipart) {
|
||||
param.baseType = "MultipartFile";
|
||||
param.dataType = "MultipartFile";
|
||||
}
|
||||
}
|
||||
for (CodegenParameter param : op.formParams) {
|
||||
if (param.baseType != null && param.baseType.equalsIgnoreCase("List<int>") && isMultipart) {
|
||||
param.baseType = "MultipartFile";
|
||||
param.dataType = "MultipartFile";
|
||||
}
|
||||
}
|
||||
for (CodegenParameter param : op.bodyParams) {
|
||||
if (param.baseType != null && param.baseType.equalsIgnoreCase("List<int>") && isMultipart) {
|
||||
param.baseType = "MultipartFile";
|
||||
param.dataType = "MultipartFile";
|
||||
}
|
||||
}
|
||||
|
||||
op.vendorExtensions.put("x-is-form", isForm);
|
||||
op.vendorExtensions.put("x-is-json", isJson);
|
||||
op.vendorExtensions.put("x-is-proto", isProto);
|
||||
op.vendorExtensions.put("x-is-multipart", isMultipart);
|
||||
|
||||
|
||||
Set<String> imports = new HashSet<>();
|
||||
for (String item : op.imports) {
|
||||
if (!modelToIgnore.contains(item.toLowerCase(Locale.ROOT))) {
|
||||
imports.add(underscore(item));
|
||||
}
|
||||
}
|
||||
modelImports.addAll(imports);
|
||||
op.imports = imports;
|
||||
|
||||
String[] items = op.path.split("/", -1);
|
||||
String jaguarPath = "";
|
||||
|
||||
for (int i = 0; i < items.length; ++i) {
|
||||
if (items[i].matches("^\\{(.*)\\}$")) { // wrap in {}
|
||||
jaguarPath = jaguarPath + ":" + items[i].replace("{", "").replace("}", "");
|
||||
} else {
|
||||
jaguarPath = jaguarPath + items[i];
|
||||
}
|
||||
|
||||
if (i != items.length - 1) {
|
||||
jaguarPath = jaguarPath + "/";
|
||||
}
|
||||
}
|
||||
|
||||
op.path = jaguarPath;
|
||||
}
|
||||
|
||||
objs.put("modelImports", modelImports);
|
||||
objs.put("fullImports", fullImports);
|
||||
|
||||
return objs;
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,6 @@ org.openapitools.codegen.languages.CSharpNetCoreClientCodegen
|
||||
org.openapitools.codegen.languages.CSharpDotNet2ClientCodegen
|
||||
org.openapitools.codegen.languages.CsharpNetcoreFunctionsServerCodegen
|
||||
org.openapitools.codegen.languages.DartClientCodegen
|
||||
org.openapitools.codegen.languages.DartDioClientCodegen
|
||||
org.openapitools.codegen.languages.DartDioNextClientCodegen
|
||||
org.openapitools.codegen.languages.EiffelClientCodegen
|
||||
org.openapitools.codegen.languages.ElixirClientCodegen
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
# {{pubName}}
|
||||
{{#appDescriptionWithNewLines}}
|
||||
{{{.}}}
|
||||
{{/appDescriptionWithNewLines}}
|
||||
|
||||
This Dart package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
|
||||
|
||||
- API version: {{appVersion}}
|
||||
{{#artifactVersion}}
|
||||
- Package version: {{.}}
|
||||
{{/artifactVersion}}
|
||||
{{^hideGenerationTimestamp}}
|
||||
- Build date: {{generatedDate}}
|
||||
{{/hideGenerationTimestamp}}
|
||||
- Build package: {{generatorClass}}
|
||||
{{#infoUrl}}
|
||||
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
|
||||
{{/infoUrl}}
|
||||
|
||||
## Requirements
|
||||
|
||||
Dart 2.7.0 or later OR Flutter 1.12 or later
|
||||
|
||||
## Installation & Usage
|
||||
|
||||
### Github
|
||||
If this Dart package is published to Github, please include the following in pubspec.yaml
|
||||
```
|
||||
name: {{pubName}}
|
||||
version: {{pubVersion}}
|
||||
description: {{pubDescription}}
|
||||
dependencies:
|
||||
{{pubName}}:
|
||||
git: https://github.com/{{gitUserId}}/{{gitRepoId}}.git
|
||||
version: 'any'
|
||||
```
|
||||
|
||||
### Local
|
||||
To use the package in your local drive, please include the following in pubspec.yaml
|
||||
```
|
||||
dependencies:
|
||||
{{pubName}}:
|
||||
path: /path/to/{{pubName}}
|
||||
```
|
||||
|
||||
## Getting Started
|
||||
|
||||
Please follow the [installation procedure](#installation--usage) and then run the following:
|
||||
|
||||
```dart
|
||||
import 'package:{{pubName}}/api.dart';
|
||||
{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}
|
||||
|
||||
final api = {{classname}}();
|
||||
{{#allParams}}
|
||||
final {{paramName}} = {{#isArray}}[{{/isArray}}{{#isBodyParam}}{{dataType}}(){{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isArray}}]{{/isArray}}; // {{{dataType}}} | {{{description}}}
|
||||
{{/allParams}}
|
||||
|
||||
try {
|
||||
{{#returnType}}final response = await {{/returnType}}api.{{{operationId}}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
|
||||
{{#returnType}}
|
||||
print(response);
|
||||
{{/returnType}}
|
||||
} catch (e) {
|
||||
print("Exception when calling {{classname}}->{{operationId}}: $e\n");
|
||||
}
|
||||
{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}}
|
||||
```
|
||||
|
||||
## Documentation for API Endpoints
|
||||
|
||||
All URIs are relative to *{{basePath}}*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{summary}}
|
||||
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
||||
|
||||
## Documentation For Models
|
||||
|
||||
{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md)
|
||||
{{/model}}{{/models}}
|
||||
|
||||
## Documentation For Authorization
|
||||
|
||||
{{^authMethods}} All endpoints do not require authorization.
|
||||
{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}}
|
||||
{{#authMethods}}## {{{name}}}
|
||||
|
||||
{{#isApiKey}}- **Type**: API key
|
||||
- **API key parameter name**: {{{keyParamName}}}
|
||||
- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
|
||||
{{/isApiKey}}
|
||||
{{#isBasic}}- **Type**: HTTP basic authentication
|
||||
{{/isBasic}}
|
||||
{{#isOAuth}}- **Type**: OAuth
|
||||
- **Flow**: {{{flow}}}
|
||||
- **Authorization URL**: {{{authorizationUrl}}}
|
||||
- **Scopes**: {{^scopes}}N/A{{/scopes}}
|
||||
{{#scopes}} - **{{{scope}}}**: {{{description}}}
|
||||
{{/scopes}}
|
||||
{{/isOAuth}}
|
||||
|
||||
{{/authMethods}}
|
||||
|
||||
## Author
|
||||
|
||||
{{#apiInfo}}{{#apis}}{{#-last}}{{infoEmail}}
|
||||
{{/-last}}{{/apis}}{{/apiInfo}}
|
||||
@@ -1,9 +0,0 @@
|
||||
analyzer:
|
||||
language:
|
||||
strict-inference: true
|
||||
strict-raw-types: true
|
||||
strong-mode:
|
||||
implicit-dynamic: false
|
||||
implicit-casts: false
|
||||
exclude:
|
||||
- test/*.dart
|
||||
@@ -1,145 +0,0 @@
|
||||
{{>header}}
|
||||
import 'dart:async';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:built_value/serializer.dart';
|
||||
|
||||
{{#operations}}
|
||||
{{#imports}}import '{{.}}';
|
||||
{{/imports}}
|
||||
|
||||
class {{classname}} {
|
||||
|
||||
final Dio _dio;
|
||||
|
||||
final Serializers _serializers;
|
||||
|
||||
const {{classname}}(this._dio, this._serializers);
|
||||
|
||||
{{#operation}}
|
||||
/// {{{summary}}}
|
||||
///
|
||||
/// {{{notes}}}
|
||||
Future<Response<{{{returnType}}}{{^returnType}}void{{/returnType}}>> {{nickname}}({{^hasRequiredParams}}{ {{/hasRequiredParams}}{{#requiredParams}}
|
||||
{{{dataType}}} {{paramName}},{{#-last}} { {{/-last}}{{/requiredParams}}{{#optionalParams}}
|
||||
{{{dataType}}} {{paramName}},{{/optionalParams}}
|
||||
CancelToken cancelToken,
|
||||
Map<String, dynamic> headers,
|
||||
Map<String, dynamic> extra,
|
||||
ValidateStatus validateStatus,
|
||||
ProgressCallback onSendProgress,
|
||||
ProgressCallback onReceiveProgress,
|
||||
}) async {
|
||||
final _request = RequestOptions(
|
||||
path: r'{{{path}}}'{{#pathParams}}.replaceAll('{' r'{{{baseName}}}' '}', {{{paramName}}}.toString()){{/pathParams}},
|
||||
method: '{{#lambda.uppercase}}{{httpMethod}}{{/lambda.uppercase}}',
|
||||
{{#isResponseFile}}
|
||||
responseType: ResponseType.bytes,
|
||||
{{/isResponseFile}}
|
||||
headers: <String, dynamic>{
|
||||
{{#httpUserAgent}}
|
||||
r'User-Agent': r'{{{.}}}',
|
||||
{{/httpUserAgent}}
|
||||
{{#headerParams}}
|
||||
{{^required}}{{^nullable}}if ({{{paramName}}} != null) {{/nullable}}{{/required}}r'{{baseName}}': {{paramName}},
|
||||
{{/headerParams}}
|
||||
...?headers,
|
||||
},
|
||||
{{#hasQueryParams}}
|
||||
queryParameters: <String, dynamic>{
|
||||
{{#queryParams}}
|
||||
{{^required}}{{^nullable}}if ({{{paramName}}} != null) {{/nullable}}{{/required}}r'{{baseName}}': {{paramName}},
|
||||
{{/queryParams}}
|
||||
},
|
||||
{{/hasQueryParams}}
|
||||
extra: <String, dynamic>{
|
||||
'secure': <Map<String, String>>[{{^hasAuthMethods}}],{{/hasAuthMethods}}{{#hasAuthMethods}}
|
||||
{{#authMethods}}{
|
||||
'type': '{{type}}',
|
||||
'name': '{{name}}',{{#isApiKey}}
|
||||
'keyName': '{{keyParamName}}',
|
||||
'where': '{{#isKeyInQuery}}query{{/isKeyInQuery}}{{#isKeyInHeader}}header{{/isKeyInHeader}}',{{/isApiKey}}
|
||||
},{{/authMethods}}
|
||||
],{{/hasAuthMethods}}
|
||||
...?extra,
|
||||
},
|
||||
validateStatus: validateStatus,
|
||||
contentType: '{{^hasConsumes}}application/json{{/hasConsumes}}{{#hasConsumes}}{{#prioritizedContentTypes}}{{#-first}}{{{mediaType}}}{{/-first}}{{/prioritizedContentTypes}}{{/hasConsumes}}',
|
||||
cancelToken: cancelToken,
|
||||
onSendProgress: onSendProgress,
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
);
|
||||
|
||||
dynamic _bodyData;
|
||||
{{#hasFormParams}}
|
||||
|
||||
_bodyData = {{#isMultipart}}FormData.fromMap({{/isMultipart}}<String, dynamic>{
|
||||
{{#formParams}}
|
||||
{{^required}}{{^nullable}}if ({{{paramName}}} != null) {{/nullable}}{{/required}}r'{{{baseName}}}': {{#isFile}}MultipartFile.fromBytes({{{paramName}}}, filename: r'{{{baseName}}}'){{/isFile}}{{^isFile}}encodeFormParameter(_serializers, {{{paramName}}}, const FullType({{^isContainer}}{{{baseType}}}{{/isContainer}}{{#isContainer}}Built{{#isMap}}Map{{/isMap}}{{#isArray}}{{#uniqueItems}}Set{{/uniqueItems}}{{^uniqueItems}}List{{/uniqueItems}}{{/isArray}}, [{{#isMap}}FullType(String), {{/isMap}}FullType({{{baseType}}})]{{/isContainer}})){{/isFile}},
|
||||
{{/formParams}}
|
||||
}{{#isMultipart}}){{/isMultipart}};
|
||||
{{/hasFormParams}}
|
||||
{{#bodyParam}}
|
||||
|
||||
{{#isPrimitiveType}}
|
||||
_bodyData = {{paramName}};
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
{{#isContainer}}
|
||||
const _type = FullType(Built{{#isMap}}Map{{/isMap}}{{#isArray}}{{#uniqueItems}}Set{{/uniqueItems}}{{^uniqueItems}}List{{/uniqueItems}}{{/isArray}}, [{{#isMap}}FullType(String), {{/isMap}}FullType({{{baseType}}})]);
|
||||
_bodyData = _serializers.serialize({{paramName}}, specifiedType: _type);
|
||||
{{/isContainer}}
|
||||
{{^isContainer}}
|
||||
const _type = FullType({{{baseType}}});
|
||||
_bodyData = _serializers.serialize({{paramName}}, specifiedType: _type);
|
||||
{{/isContainer}}
|
||||
{{/isPrimitiveType}}
|
||||
{{/bodyParam}}
|
||||
|
||||
final _response = await _dio.request<dynamic>(
|
||||
_request.path,
|
||||
data: _bodyData,
|
||||
options: _request,
|
||||
);
|
||||
{{#returnType}}
|
||||
|
||||
{{#isResponseFile}}
|
||||
final {{{returnType}}} _responseData = _response.data as {{{returnType}}};
|
||||
{{/isResponseFile}}
|
||||
{{^isResponseFile}}
|
||||
{{#returnSimpleType}}
|
||||
{{#returnTypeIsPrimitive}}
|
||||
final {{{returnType}}} _responseData = _response.data as {{{returnType}}};
|
||||
{{/returnTypeIsPrimitive}}
|
||||
{{^returnTypeIsPrimitive}}
|
||||
const _responseType = FullType({{{returnType}}});
|
||||
final _responseData = _serializers.deserialize(
|
||||
_response.data,
|
||||
specifiedType: _responseType,
|
||||
) as {{{returnType}}};
|
||||
{{/returnTypeIsPrimitive}}
|
||||
{{/returnSimpleType}}
|
||||
{{^returnSimpleType}}
|
||||
const _responseType = FullType(Built{{#isArray}}{{#uniqueItems}}Set{{/uniqueItems}}{{^uniqueItems}}List{{/uniqueItems}}{{/isArray}}{{#isMap}}Map{{/isMap}}, [{{#isMap}}FullType(String), {{/isMap}}FullType({{{returnBaseType}}})]);
|
||||
final {{{returnType}}} _responseData = _serializers.deserialize(
|
||||
_response.data,
|
||||
specifiedType: _responseType,
|
||||
) as {{{returnType}}};
|
||||
{{/returnSimpleType}}
|
||||
{{/isResponseFile}}
|
||||
|
||||
return Response<{{{returnType}}}>(
|
||||
data: _responseData,
|
||||
headers: _response.headers,
|
||||
isRedirect: _response.isRedirect,
|
||||
request: _response.request,
|
||||
redirects: _response.redirects,
|
||||
statusCode: _response.statusCode,
|
||||
statusMessage: _response.statusMessage,
|
||||
extra: _response.extra,
|
||||
);{{/returnType}}{{^returnType}}
|
||||
return _response;{{/returnType}}
|
||||
}
|
||||
|
||||
{{/operation}}
|
||||
}
|
||||
{{/operations}}
|
||||
@@ -1,86 +0,0 @@
|
||||
# {{pubName}}.api.{{classname}}{{#description}}
|
||||
{{.}}{{/description}}
|
||||
|
||||
## Load the API package
|
||||
```dart
|
||||
import 'package:{{pubName}}/api.dart';
|
||||
```
|
||||
|
||||
All URIs are relative to *{{basePath}}*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{summary}}
|
||||
{{/operation}}{{/operations}}
|
||||
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
# **{{{operationId}}}**
|
||||
> {{#returnType}}{{{.}}} {{/returnType}}{{{operationId}}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}})
|
||||
|
||||
{{{summary}}}{{#notes}}
|
||||
|
||||
{{{.}}}{{/notes}}
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:{{pubName}}/api.dart';
|
||||
{{#hasAuthMethods}}
|
||||
{{#authMethods}}
|
||||
{{#isBasic}}
|
||||
// TODO Configure HTTP basic authorization: {{{name}}}
|
||||
//defaultApiClient.getAuthentication<HttpBasicAuth>('{{{name}}}').username = 'YOUR_USERNAME'
|
||||
//defaultApiClient.getAuthentication<HttpBasicAuth>('{{{name}}}').password = 'YOUR_PASSWORD';
|
||||
{{/isBasic}}
|
||||
{{#isApiKey}}
|
||||
// TODO Configure API key authorization: {{{name}}}
|
||||
//defaultApiClient.getAuthentication<ApiKeyAuth>('{{{name}}}').apiKey = 'YOUR_API_KEY';
|
||||
// uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
||||
//defaultApiClient.getAuthentication<ApiKeyAuth>('{{{name}}}').apiKeyPrefix = 'Bearer';
|
||||
{{/isApiKey}}
|
||||
{{#isOAuth}}
|
||||
// TODO Configure OAuth2 access token for authorization: {{{name}}}
|
||||
//defaultApiClient.getAuthentication<OAuth>('{{{name}}}').accessToken = 'YOUR_ACCESS_TOKEN';
|
||||
{{/isOAuth}}
|
||||
{{/authMethods}}
|
||||
{{/hasAuthMethods}}
|
||||
|
||||
var api_instance = new {{classname}}();
|
||||
{{#allParams}}
|
||||
var {{paramName}} = {{#isArray}}[{{/isArray}}{{#isBodyParam}}new {{{dataType}}}(){{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isArray}}]{{/isArray}}; // {{{dataType}}} | {{{description}}}
|
||||
{{/allParams}}
|
||||
|
||||
try {
|
||||
{{#returnType}}var result = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
|
||||
{{#returnType}}
|
||||
print(result);
|
||||
{{/returnType}}
|
||||
} catch (e) {
|
||||
print('Exception when calling {{classname}}->{{operationId}}: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}}
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}
|
||||
{{#allParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{{dataType}}}**]({{baseType}}.md){{/isPrimitiveType}}| {{{description}}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
|
||||
{{/allParams}}
|
||||
|
||||
### Return type
|
||||
|
||||
{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void (empty response body){{/returnType}}
|
||||
|
||||
### Authorization
|
||||
|
||||
{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}}
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: {{#consumes}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
|
||||
- **Accept**: {{#produces}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/produces}}{{^produces}}Not defined{{/produces}}
|
||||
|
||||
[[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)
|
||||
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
@@ -1,30 +0,0 @@
|
||||
{{>header}}
|
||||
import 'package:{{pubName}}/api.dart';
|
||||
import 'package:{{pubName}}/api/{{classFilename}}.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
{{#operations}}
|
||||
|
||||
/// tests for {{{classname}}}
|
||||
void main() {
|
||||
final instance = {{{clientName}}}().get{{{classname}}}();
|
||||
|
||||
group({{{classname}}}, () {
|
||||
{{#operation}}
|
||||
{{#summary}}
|
||||
// {{{.}}}
|
||||
//
|
||||
{{/summary}}
|
||||
{{#notes}}
|
||||
// {{{.}}}
|
||||
//
|
||||
{{/notes}}
|
||||
//{{#returnType}}Future<{{{.}}}> {{/returnType}}{{^returnType}}Future {{/returnType}}{{{operationId}}}({{#allParams}}{{#required}}{{{dataType}}} {{{paramName}}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}} {{{paramName}}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async
|
||||
test('test {{{operationId}}}', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
{{/operation}}
|
||||
});
|
||||
}
|
||||
{{/operations}}
|
||||
@@ -1,25 +0,0 @@
|
||||
{{>header}}
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:built_collection/built_collection.dart';
|
||||
import 'package:built_value/serializer.dart';
|
||||
|
||||
/// Format the given form parameter object into something that Dio can handle.
|
||||
/// Returns primitive or String.
|
||||
/// Returns List/Map if the value is BuildList/BuiltMap.
|
||||
dynamic encodeFormParameter(Serializers serializers, dynamic value, FullType type) {
|
||||
if (value == null) {
|
||||
return '';
|
||||
}
|
||||
if (value is String || value is num || value is bool) {
|
||||
return value;
|
||||
}
|
||||
final serialized = serializers.serialize(value, specifiedType: type);
|
||||
if (serialized is String) {
|
||||
return serialized;
|
||||
}
|
||||
if (value is BuiltList || value is BuiltMap) {
|
||||
return serialized;
|
||||
}
|
||||
return json.encode(serialized);
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
{{>header}}
|
||||
library {{pubName}}.api;
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:built_value/serializer.dart';
|
||||
import 'package:{{pubName}}/serializers.dart';
|
||||
import 'package:{{pubName}}/auth/api_key_auth.dart';
|
||||
import 'package:{{pubName}}/auth/basic_auth.dart';
|
||||
import 'package:{{pubName}}/auth/oauth.dart';
|
||||
{{#apiInfo}}{{#apis}}import 'package:{{pubName}}/api/{{classFilename}}.dart';
|
||||
{{/apis}}{{/apiInfo}}
|
||||
|
||||
final _defaultInterceptors = [
|
||||
OAuthInterceptor(),
|
||||
BasicAuthInterceptor(),
|
||||
ApiKeyAuthInterceptor(),
|
||||
];
|
||||
|
||||
class {{clientName}} {
|
||||
|
||||
static const String basePath = r'{{{basePath}}}';
|
||||
|
||||
final Dio dio;
|
||||
|
||||
final Serializers serializers;
|
||||
|
||||
{{clientName}}({
|
||||
Dio dio,
|
||||
Serializers serializers,
|
||||
String basePathOverride,
|
||||
List<Interceptor> interceptors,
|
||||
}) : this.serializers = serializers ?? standardSerializers,
|
||||
this.dio = dio ??
|
||||
Dio(BaseOptions(
|
||||
baseUrl: basePathOverride ?? basePath,
|
||||
connectTimeout: 5000,
|
||||
receiveTimeout: 3000,
|
||||
)) {
|
||||
if (interceptors == null) {
|
||||
this.dio.interceptors.addAll(_defaultInterceptors);
|
||||
} else {
|
||||
this.dio.interceptors.addAll(interceptors);
|
||||
}
|
||||
}
|
||||
|
||||
void setOAuthToken(String name, String token) {
|
||||
(this.dio.interceptors.firstWhere((element) => element is OAuthInterceptor, orElse: null) as OAuthInterceptor)?.tokens[name] = token;
|
||||
}
|
||||
|
||||
void setBasicAuth(String name, String username, String password) {
|
||||
(this.dio.interceptors.firstWhere((element) => element is BasicAuthInterceptor, orElse: null) as BasicAuthInterceptor)?.authInfo[name] = BasicAuthInfo(username, password);
|
||||
}
|
||||
|
||||
void setApiKey(String name, String apiKey) {
|
||||
(this.dio.interceptors.firstWhere((element) => element is ApiKeyAuthInterceptor, orElse: null) as ApiKeyAuthInterceptor)?.apiKeys[name] = apiKey;
|
||||
}
|
||||
|
||||
{{#apiInfo}}{{#apis}}
|
||||
/**
|
||||
* Get {{classname}} instance, base route and serializer can be overridden by a given but be careful,
|
||||
* by doing that all interceptors will not be executed
|
||||
*/
|
||||
{{classname}} get{{classname}}() {
|
||||
return {{classname}}(dio, serializers);
|
||||
}
|
||||
|
||||
{{/apis}}{{/apiInfo}}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
{{>header}}
|
||||
import 'dart:async';
|
||||
import 'package:{{pubName}}/auth/auth.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
class ApiKeyAuthInterceptor extends AuthInterceptor {
|
||||
Map<String, String> apiKeys = {};
|
||||
|
||||
@override
|
||||
Future<dynamic> onRequest(RequestOptions options) {
|
||||
final authInfo = getAuthInfo(options, 'apiKey');
|
||||
for (final info in authInfo) {
|
||||
final authName = info['name'] as String;
|
||||
final authKeyName = info['keyName'] as String;
|
||||
final authWhere = info['where'] as String;
|
||||
final apiKey = apiKeys[authName];
|
||||
if (apiKey != null) {
|
||||
if (authWhere == 'query') {
|
||||
options.queryParameters[authKeyName] = apiKey;
|
||||
} else {
|
||||
options.headers[authKeyName] = apiKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.onRequest(options);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
{{>header}}
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
abstract class AuthInterceptor extends Interceptor {
|
||||
/// Get auth information on given route for the given type.
|
||||
/// Can return an empty list if type is not present on auth data or
|
||||
/// if route doesn't need authentication.
|
||||
List<Map<String, dynamic>> getAuthInfo(RequestOptions route, String type) {
|
||||
if (route.extra.containsKey('secure')) {
|
||||
final auth = route.extra['secure'] as List<Map<String, String>>;
|
||||
final results = <Map<String, dynamic>>[];
|
||||
for (final info in auth) {
|
||||
if (info['type'] == type) {
|
||||
results.add(info);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
{{>header}}
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'package:{{pubName}}/auth/auth.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
class BasicAuthInfo {
|
||||
final String username;
|
||||
final String password;
|
||||
|
||||
const BasicAuthInfo(this.username, this.password);
|
||||
}
|
||||
|
||||
class BasicAuthInterceptor extends AuthInterceptor {
|
||||
Map<String, BasicAuthInfo> authInfo = {};
|
||||
|
||||
@override
|
||||
Future<dynamic> onRequest(RequestOptions options) {
|
||||
final metadataAuthInfo = getAuthInfo(options, 'basic');
|
||||
for (final info in metadataAuthInfo) {
|
||||
final authName = info['name'] as String;
|
||||
final basicAuthInfo = authInfo[authName];
|
||||
if (basicAuthInfo != null) {
|
||||
final basicAuth = 'Basic ' + base64Encode(utf8.encode('${basicAuthInfo.username}:${basicAuthInfo.password}'));
|
||||
options.headers['Authorization'] = basicAuth;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return super.onRequest(options);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
{{>header}}
|
||||
import 'dart:async';
|
||||
import 'package:{{pubName}}/auth/auth.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
class OAuthInterceptor extends AuthInterceptor {
|
||||
Map<String, String> tokens = {};
|
||||
|
||||
@override
|
||||
Future<dynamic> onRequest(RequestOptions options) {
|
||||
final authInfo = getAuthInfo(options, 'oauth');
|
||||
for (final info in authInfo) {
|
||||
final token = tokens[info['name']];
|
||||
if (token != null) {
|
||||
options.headers['Authorization'] = 'Bearer ${token}';
|
||||
break;
|
||||
}
|
||||
}
|
||||
return super.onRequest(options);
|
||||
}
|
||||
}
|
||||
@@ -1,151 +0,0 @@
|
||||
import 'package:built_value/built_value.dart';
|
||||
import 'package:built_value/serializer.dart';
|
||||
|
||||
part '{{classFilename}}.g.dart';
|
||||
|
||||
abstract class {{classname}} implements Built<{{classname}}, {{classname}}Builder> {
|
||||
|
||||
{{#vars}}
|
||||
{{#description}}
|
||||
/// {{{.}}}
|
||||
{{/description}}
|
||||
{{!
|
||||
A field is @nullable in built_value when it is
|
||||
nullable || (!required && !defaultValue) in OAS
|
||||
}}
|
||||
{{#isNullable}}
|
||||
@nullable
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
{{^required}}
|
||||
{{^defaultValue}}
|
||||
@nullable
|
||||
{{/defaultValue}}
|
||||
{{/required}}
|
||||
{{/isNullable}}
|
||||
@BuiltValueField(wireName: r'{{baseName}}')
|
||||
{{{datatypeWithEnum}}} get {{name}};
|
||||
{{#allowableValues}}
|
||||
// {{#min}}range from {{{min}}} to {{{max}}}{{/min}}{{^min}}enum {{name}}Enum { {{#values}} {{{.}}}, {{/values}} };{{/min}}
|
||||
{{/allowableValues}}
|
||||
|
||||
{{/vars}}
|
||||
{{classname}}._();
|
||||
|
||||
static void _initializeBuilder({{{classname}}}Builder b) => b{{#vars}}{{#defaultValue}}
|
||||
..{{{name}}} = {{#isEnum}}{{^isContainer}}const {{{enumName}}}._({{/isContainer}}{{/isEnum}}{{{defaultValue}}}{{#isEnum}}{{^isContainer}}){{/isContainer}}{{/isEnum}}{{/defaultValue}}{{/vars}};
|
||||
|
||||
factory {{classname}}([void updates({{classname}}Builder b)]) = _${{classname}};
|
||||
|
||||
@BuiltValueSerializer(custom: true)
|
||||
static Serializer<{{classname}}> get serializer => _${{classname}}Serializer();
|
||||
}
|
||||
|
||||
{{!
|
||||
Generate a custom serializer in order to support combinations of required and nullable.
|
||||
By default built_value does not serialize null fields.
|
||||
}}
|
||||
class _${{classname}}Serializer implements StructuredSerializer<{{classname}}> {
|
||||
|
||||
@override
|
||||
final Iterable<Type> types = const [{{classname}}, _${{classname}}];
|
||||
@override
|
||||
final String wireName = r'{{classname}}';
|
||||
|
||||
@override
|
||||
Iterable<Object> serialize(Serializers serializers, {{{classname}}} object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = <Object>[];
|
||||
{{#vars}}
|
||||
{{#required}}
|
||||
{{!
|
||||
A required property need to always be part of the serialized output.
|
||||
When it is nullable, null is serialized, otherwise it is an error if it is null.
|
||||
}}
|
||||
result
|
||||
..add(r'{{baseName}}')
|
||||
..add({{#isNullable}}object.{{{name}}} == null ? null : {{/isNullable}}serializers.serialize(object.{{{name}}},
|
||||
specifiedType: {{{vendorExtensions.x-built-value-serializer-type}}}));
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
if (object.{{{name}}} != null) {
|
||||
{{! Non-required properties are only serialized if not null. }}
|
||||
result
|
||||
..add(r'{{baseName}}')
|
||||
..add(serializers.serialize(object.{{{name}}},
|
||||
specifiedType: {{{vendorExtensions.x-built-value-serializer-type}}}));
|
||||
}
|
||||
{{/required}}
|
||||
{{/vars}}
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
{{classname}} deserialize(Serializers serializers, Iterable<Object> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = {{classname}}Builder();
|
||||
|
||||
final iterator = serialized.iterator;
|
||||
while (iterator.moveNext()) {
|
||||
final key = iterator.current as String;
|
||||
iterator.moveNext();
|
||||
final dynamic value = iterator.current;
|
||||
switch (key) {
|
||||
{{#vars}}
|
||||
case r'{{baseName}}':
|
||||
{{#isContainer}}
|
||||
result.{{{name}}}.replace(serializers.deserialize(value,
|
||||
specifiedType: {{{vendorExtensions.x-built-value-serializer-type}}}) as {{{datatypeWithEnum}}});
|
||||
{{/isContainer}}
|
||||
{{^isContainer}}
|
||||
{{#isEnum}}
|
||||
result.{{{name}}} = serializers.deserialize(value,
|
||||
specifiedType: {{{vendorExtensions.x-built-value-serializer-type}}}) as {{{datatypeWithEnum}}};
|
||||
{{/isEnum}}
|
||||
{{^isEnum}}
|
||||
{{#isModel}}
|
||||
{{#isPrimitiveType}}
|
||||
{{! These are models that have been manually marked as primitive via generator param. }} result.{{{name}}} = valueDes;
|
||||
result.{{{name}}} = serializers.deserialize(value,
|
||||
specifiedType: {{{vendorExtensions.x-built-value-serializer-type}}}) as {{{datatypeWithEnum}}};
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
result.{{{name}}}.replace(serializers.deserialize(value,
|
||||
specifiedType: {{{vendorExtensions.x-built-value-serializer-type}}}) as {{{datatypeWithEnum}}});
|
||||
{{/isPrimitiveType}}
|
||||
{{/isModel}}
|
||||
{{^isModel}}
|
||||
result.{{{name}}} = serializers.deserialize(value,
|
||||
specifiedType: {{{vendorExtensions.x-built-value-serializer-type}}}) as {{{datatypeWithEnum}}};
|
||||
{{/isModel}}
|
||||
{{/isEnum}}
|
||||
{{/isContainer}}
|
||||
break;
|
||||
{{/vars}}
|
||||
}
|
||||
}
|
||||
return result.build();
|
||||
}
|
||||
}
|
||||
{{!
|
||||
Generate an enum for any variables that are declared as inline enums
|
||||
isEnum is only true for inline variables that are enums.
|
||||
If an enum is declared as a definition, isEnum is false and the enum is generated from the
|
||||
enum.mustache template.
|
||||
}}
|
||||
{{#vars}}
|
||||
{{^isModel}}
|
||||
{{#isEnum}}
|
||||
{{^isContainer}}
|
||||
|
||||
{{>enum_inline}}
|
||||
{{/isContainer}}
|
||||
{{#isContainer}}
|
||||
{{#mostInnerItems}}
|
||||
|
||||
{{>enum_inline}}
|
||||
{{/mostInnerItems}}
|
||||
{{/isContainer}}
|
||||
{{/isEnum}}
|
||||
{{/isModel}}
|
||||
{{/vars}}
|
||||
@@ -1,33 +0,0 @@
|
||||
import 'package:built_collection/built_collection.dart';
|
||||
import 'package:built_value/built_value.dart';
|
||||
import 'package:built_value/serializer.dart';
|
||||
|
||||
part '{{classFilename}}.g.dart';
|
||||
|
||||
class {{classname}} extends EnumClass {
|
||||
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
{{#description}}
|
||||
/// {{{.}}}
|
||||
{{/description}}
|
||||
@BuiltValueEnumConst({{#isInteger}}wireNumber: {{{value}}}{{/isInteger}}{{^isInteger}}wireName: r{{#lambda.escapeBuiltValueEnum}}{{{value}}}{{/lambda.escapeBuiltValueEnum}}{{/isInteger}}{{#enumUnknownDefaultCase}}{{#-last}}, fallback: true{{/-last}}{{/enumUnknownDefaultCase}})
|
||||
static const {{classname}} {{name}} = _${{name}};
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
|
||||
static Serializer<{{classname}}> get serializer => _${{#lambda.camelcase}}{{{classname}}}{{/lambda.camelcase}}Serializer;
|
||||
|
||||
const {{classname}}._(String name): super(name);
|
||||
|
||||
static BuiltSet<{{classname}}> get values => _$values;
|
||||
static {{classname}} valueOf(String name) => _$valueOf(name);
|
||||
}
|
||||
|
||||
/// Optionally, enum_class can generate a mixin to go with your enum for use
|
||||
/// with Angular. It exposes your enum constants as getters. So, if you mix it
|
||||
/// in to your Dart component class, the values become available to the
|
||||
/// corresponding Angular template.
|
||||
///
|
||||
/// Trigger mixin generation by writing a line like this one next to your enum.
|
||||
abstract class {{classname}}Mixin = Object with _${{classname}}Mixin;
|
||||
@@ -1,19 +0,0 @@
|
||||
class {{{enumName}}} extends EnumClass {
|
||||
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
{{#description}}
|
||||
/// {{{.}}}
|
||||
{{/description}}
|
||||
@BuiltValueEnumConst({{#isInteger}}wireNumber: {{{value}}}{{/isInteger}}{{^isInteger}}wireName: r{{#lambda.escapeBuiltValueEnum}}{{{value}}}{{/lambda.escapeBuiltValueEnum}}{{/isInteger}}{{#enumUnknownDefaultCase}}{{#-last}}, fallback: true{{/-last}}{{/enumUnknownDefaultCase}})
|
||||
static const {{{enumName}}} {{name}} = _${{#lambda.camelcase}}{{{enumName}}}{{/lambda.camelcase}}_{{name}};
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
|
||||
static Serializer<{{{enumName}}}> get serializer => _${{#lambda.camelcase}}{{{enumName}}}{{/lambda.camelcase}}Serializer;
|
||||
|
||||
const {{{enumName}}}._(String name): super(name);
|
||||
|
||||
static BuiltSet<{{{enumName}}}> get values => _${{#lambda.camelcase}}{{{enumName}}}{{/lambda.camelcase}}Values;
|
||||
static {{{enumName}}} valueOf(String name) => _${{#lambda.camelcase}}{{{enumName}}}{{/lambda.camelcase}}ValueOf(name);
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
# See https://dart.dev/guides/libraries/private-files
|
||||
|
||||
# Files and directories created by pub
|
||||
.dart_tool/
|
||||
.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
|
||||
|
||||
# Don’t commit files and directories created by other development environments.
|
||||
# For example, if your development environment creates any of the following files,
|
||||
# consider putting them in a global ignore file:
|
||||
|
||||
# IntelliJ
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# Mac
|
||||
.DS_Store
|
||||
@@ -1,6 +0,0 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.7
|
||||
|
||||
// ignore_for_file: unused_import
|
||||
@@ -1,52 +0,0 @@
|
||||
{{>header}}
|
||||
import 'package:built_collection/built_collection.dart';
|
||||
import 'package:built_value/serializer.dart';
|
||||
import 'package:time_machine/time_machine.dart';
|
||||
|
||||
class OffsetDateSerializer implements PrimitiveSerializer<OffsetDate> {
|
||||
|
||||
const OffsetDateSerializer();
|
||||
|
||||
@override
|
||||
Iterable<Type> get types => BuiltList<Type>([OffsetDate]);
|
||||
|
||||
@override
|
||||
String get wireName => 'OffsetDate';
|
||||
|
||||
@override
|
||||
OffsetDate deserialize(Serializers serializers, Object serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final local = LocalDate.dateTime(DateTime.parse(serialized as String));
|
||||
return OffsetDate(local, Offset(0));
|
||||
}
|
||||
|
||||
@override
|
||||
Object serialize(Serializers serializers, OffsetDate offsetDate,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
return offsetDate.toString('yyyy-MM-dd');
|
||||
}
|
||||
}
|
||||
|
||||
class OffsetDateTimeSerializer implements PrimitiveSerializer<OffsetDateTime> {
|
||||
|
||||
const OffsetDateTimeSerializer();
|
||||
|
||||
@override
|
||||
Iterable<Type> get types => BuiltList<Type>([OffsetDateTime]);
|
||||
|
||||
@override
|
||||
String get wireName => 'OffsetDateTime';
|
||||
|
||||
@override
|
||||
OffsetDateTime deserialize(Serializers serializers, Object serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final local = LocalDateTime.dateTime(DateTime.parse(serialized as String));
|
||||
return OffsetDateTime(local, Offset(0));
|
||||
}
|
||||
|
||||
@override
|
||||
Object serialize(Serializers serializers, OffsetDateTime offsetDateTime,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
return offsetDateTime.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{{>header}}
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
{{#imports}}
|
||||
import '{{.}}';
|
||||
{{/imports}}
|
||||
{{#isEnum}}{{>enum}}{{/isEnum}}{{^isEnum}}{{>class}}{{/isEnum}}
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
@@ -1,31 +0,0 @@
|
||||
{{>header}}
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
import 'package:{{pubName}}/model/{{classFilename}}.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
// tests for {{{classname}}}
|
||||
void main() {
|
||||
{{^isEnum}}
|
||||
{{! Due to required vars without default value we can not create a full instance here }}
|
||||
final instance = {{{classname}}}Builder();
|
||||
// TODO add properties to the builder and call build()
|
||||
{{/isEnum}}
|
||||
|
||||
group({{{classname}}}, () {
|
||||
{{#vars}}
|
||||
{{#description}}
|
||||
// {{{.}}}
|
||||
{{/description}}
|
||||
// {{{dataType}}} {{{name}}}{{#defaultValue}} (default value: {{{.}}}){{/defaultValue}}
|
||||
test('to test the property `{{{name}}}`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
{{/vars}}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
@@ -1,16 +0,0 @@
|
||||
{{#models}}{{#model}}# {{pubName}}.model.{{classname}}
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:{{pubName}}/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{{dataType}}}**]({{complexType}}.md){{/isPrimitiveType}} | {{{description}}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
|
||||
{{/vars}}
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
{{/model}}{{/models}}
|
||||
@@ -1,20 +0,0 @@
|
||||
name: {{pubName}}
|
||||
version: {{pubVersion}}
|
||||
description: {{pubDescription}}
|
||||
homepage: {{pubHomepage}}
|
||||
|
||||
environment:
|
||||
sdk: '>=2.7.0 <3.0.0'
|
||||
|
||||
dependencies:
|
||||
dio: '^3.0.9'
|
||||
built_value: '>=7.1.0 <8.0.0'
|
||||
built_collection: '>=4.3.2 <5.0.0'
|
||||
{{#timeMachine}}
|
||||
time_machine: '^0.9.12'
|
||||
{{/timeMachine}}
|
||||
|
||||
dev_dependencies:
|
||||
built_value_generator: '>=7.1.0 <8.0.0'
|
||||
build_runner: any
|
||||
test: '>=1.3.0 <1.16.0'
|
||||
@@ -1,35 +0,0 @@
|
||||
{{>header}}
|
||||
library serializers;
|
||||
|
||||
import 'package:built_value/iso_8601_date_time_serializer.dart';
|
||||
import 'package:built_value/serializer.dart';
|
||||
import 'package:built_collection/built_collection.dart';
|
||||
import 'package:built_value/json_object.dart';
|
||||
import 'package:built_value/standard_json_plugin.dart';
|
||||
{{#timeMachine}}import 'package:time_machine/time_machine.dart';
|
||||
import 'package:{{pubName}}/local_date_serializer.dart';{{/timeMachine}}
|
||||
{{#models}}{{#model}}import 'package:{{pubName}}/model/{{classFilename}}.dart';
|
||||
{{/model}}{{/models}}
|
||||
part 'serializers.g.dart';
|
||||
|
||||
@SerializersFor(const [{{#models}}{{#model}}
|
||||
{{classname}},{{/model}}{{/models}}
|
||||
])
|
||||
Serializers serializers = (_$serializers.toBuilder(){{#apiInfo}}{{#apis}}{{#serializers}}
|
||||
..addBuilderFactory(
|
||||
{{#isArray}}
|
||||
const FullType(Built{{#uniqueItems}}Set{{/uniqueItems}}{{^uniqueItems}}List{{/uniqueItems}}, [FullType({{baseType}})]),
|
||||
() => {{#uniqueItems}}Set{{/uniqueItems}}{{^uniqueItems}}List{{/uniqueItems}}Builder<{{baseType}}>(),
|
||||
{{/isArray}}
|
||||
{{#isMap}}
|
||||
const FullType(BuiltMap, [FullType(String), FullType({{baseType}})]),
|
||||
() => MapBuilder<String, {{baseType}}>(),
|
||||
{{/isMap}}
|
||||
){{/serializers}}{{/apis}}{{/apiInfo}}{{#timeMachine}}
|
||||
..add(const OffsetDateSerializer())
|
||||
..add(const OffsetDateTimeSerializer()){{/timeMachine}}
|
||||
..add(Iso8601DateTimeSerializer()))
|
||||
.build();
|
||||
|
||||
Serializers standardSerializers =
|
||||
(serializers.toBuilder()..addPlugin(StandardJsonPlugin())).build();
|
||||
@@ -24,7 +24,6 @@ import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.languages.DartClientCodegen;
|
||||
import org.openapitools.codegen.languages.DartDioClientCodegen;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -565,29 +564,4 @@ public class DartModelTest {
|
||||
Assert.assertEquals(op.returnType, "DateTime");
|
||||
Assert.assertEquals(op.bodyParam.dataType, "DateTime");
|
||||
}
|
||||
|
||||
@Test(description = "correctly generate date/datetime default values, currently null")
|
||||
public void dateDefaultValues() {
|
||||
final DateSchema date = new DateSchema();
|
||||
date.setDefault("2021-01-01");
|
||||
final DateTimeSchema dateTime = new DateTimeSchema();
|
||||
dateTime.setDefault("2021-01-01T14:00:00Z");
|
||||
final Schema model = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("date", date)
|
||||
.addProperties("dateTime", dateTime)
|
||||
.addProperties("mapNoDefault", new MapSchema());
|
||||
final DefaultCodegen codegen = new DartDioClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
final CodegenProperty dateDefault = cm.vars.get(0);
|
||||
Assert.assertEquals(dateDefault.name, "date");
|
||||
Assert.assertNull(dateDefault.defaultValue);
|
||||
|
||||
final CodegenProperty dateTimeDefault = cm.vars.get(1);
|
||||
Assert.assertEquals(dateTimeDefault.name, "dateTime");
|
||||
Assert.assertNull(dateTimeDefault.defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
* Copyright 2018 SmartBear Software
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen.dart.dio;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.languages.DartDioClientCodegen;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class DartDioClientCodegenTest {
|
||||
|
||||
@Test
|
||||
public void testInitialConfigValues() throws Exception {
|
||||
final DartDioClientCodegen codegen = new DartDioClientCodegen();
|
||||
codegen.processOpts();
|
||||
|
||||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE);
|
||||
Assert.assertTrue(codegen.isHideGenerationTimestamp());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSettersForConfigValues() throws Exception {
|
||||
final DartDioClientCodegen codegen = new DartDioClientCodegen();
|
||||
codegen.setHideGenerationTimestamp(false);
|
||||
codegen.processOpts();
|
||||
|
||||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE);
|
||||
Assert.assertFalse(codegen.isHideGenerationTimestamp());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAdditionalPropertiesPutForConfigValues() throws Exception {
|
||||
final DartDioClientCodegen codegen = new DartDioClientCodegen();
|
||||
codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false);
|
||||
codegen.processOpts();
|
||||
|
||||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE);
|
||||
Assert.assertFalse(codegen.isHideGenerationTimestamp());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testKeywords() throws Exception {
|
||||
final DartDioClientCodegen codegen = new DartDioClientCodegen();
|
||||
|
||||
List<String> reservedWordsList = new ArrayList<String>();
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("src/main/resources/dart/dart-keywords.txt"), StandardCharsets.UTF_8));
|
||||
while(reader.ready()) { reservedWordsList.add(reader.readLine()); }
|
||||
reader.close();
|
||||
} catch (Exception e) {
|
||||
String errorString = String.format(Locale.ROOT, "Error reading dart keywords: %s", e);
|
||||
Assert.fail(errorString, e);
|
||||
}
|
||||
|
||||
Assert.assertTrue(reservedWordsList.size() > 20);
|
||||
Assert.assertEquals(codegen.reservedWords().size(), reservedWordsList.size());
|
||||
for(String keyword : reservedWordsList) {
|
||||
// reserved words are stored in lowercase
|
||||
Assert.assertTrue(codegen.reservedWords().contains(keyword.toLowerCase(Locale.ROOT)), String.format(Locale.ROOT, "%s, part of %s, was not found in %s", keyword, reservedWordsList, codegen.reservedWords().toString()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
* Copyright 2018 SmartBear Software
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen.dart.dio;
|
||||
|
||||
import org.openapitools.codegen.AbstractOptionsTest;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.languages.DartDioClientCodegen;
|
||||
import org.openapitools.codegen.options.DartDioClientOptionsProvider;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
public class DartDioClientOptionsTest extends AbstractOptionsTest {
|
||||
private DartDioClientCodegen clientCodegen = mock(DartDioClientCodegen.class, mockSettings);
|
||||
|
||||
public DartDioClientOptionsTest() {
|
||||
super(new DartDioClientOptionsProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CodegenConfig getCodegenConfig() {
|
||||
return clientCodegen;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Override
|
||||
protected void verifyOptions() {
|
||||
verify(clientCodegen).setSortParamsByRequiredFlag(Boolean.valueOf(DartDioClientOptionsProvider.SORT_PARAMS_VALUE));
|
||||
verify(clientCodegen).setPubLibrary(DartDioClientOptionsProvider.PUB_LIBRARY_VALUE);
|
||||
verify(clientCodegen).setPubName(DartDioClientOptionsProvider.PUB_NAME_VALUE);
|
||||
verify(clientCodegen).setPubVersion(DartDioClientOptionsProvider.PUB_VERSION_VALUE);
|
||||
verify(clientCodegen).setPubDescription(DartDioClientOptionsProvider.PUB_DESCRIPTION_VALUE);
|
||||
//verify(clientCodegen).setPubAuthor(DartDioClientOptionsProvider.PUB_AUTHOR_VALUE);
|
||||
//verify(clientCodegen).setPubAuthorEmail(DartDioClientOptionsProvider.PUB_AUTHOR_EMAIL_VALUE);
|
||||
//verify(clientCodegen).setPubHomepage(DartDioClientOptionsProvider.PUB_HOMEPAGE_VALUE);
|
||||
verify(clientCodegen).setSourceFolder(DartDioClientOptionsProvider.SOURCE_FOLDER_VALUE);
|
||||
verify(clientCodegen).setUseEnumExtension(Boolean.parseBoolean(DartDioClientOptionsProvider.USE_ENUM_EXTENSION));
|
||||
verify(clientCodegen).setDateLibrary(DartDioClientOptionsProvider.DATE_LIBRARY);
|
||||
verify(clientCodegen).setNullableFields(Boolean.parseBoolean(DartDioClientOptionsProvider.NULLABLE_FIELDS));
|
||||
verify(clientCodegen).setEnumUnknownDefaultCase(Boolean.parseBoolean(DartDioClientOptionsProvider.ENUM_UNKNOWN_DEFAULT_CASE_VALUE));
|
||||
}
|
||||
}
|
||||
@@ -1,479 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
* Copyright 2018 SmartBear Software
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen.dart.dio;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.DateSchema;
|
||||
import io.swagger.v3.oas.models.media.DateTimeSchema;
|
||||
import io.swagger.v3.oas.models.media.IntegerSchema;
|
||||
import io.swagger.v3.oas.models.media.MapSchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.media.StringSchema;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
import org.openapitools.codegen.CodegenProperty;
|
||||
import org.openapitools.codegen.DefaultCodegen;
|
||||
import org.openapitools.codegen.TestUtils;
|
||||
import org.openapitools.codegen.languages.DartDioClientCodegen;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@SuppressWarnings("static-method")
|
||||
public class DartDioModelTest {
|
||||
|
||||
@Test(description = "convert a simple php model")
|
||||
public void simpleModelTest() {
|
||||
final Schema model = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("id", new IntegerSchema())
|
||||
.addProperties("name", new StringSchema())
|
||||
.addProperties("createdAt", new DateTimeSchema())
|
||||
.addRequiredItem("id")
|
||||
.addRequiredItem("name");
|
||||
final DefaultCodegen codegen = new DartDioClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "a sample model");
|
||||
Assert.assertEquals(cm.vars.size(), 3);
|
||||
// {{imports}} is not used in template
|
||||
//Assert.assertEquals(cm.imports.size(), 1);
|
||||
|
||||
final CodegenProperty property1 = cm.vars.get(0);
|
||||
Assert.assertEquals(property1.baseName, "id");
|
||||
Assert.assertEquals(property1.dataType, "int");
|
||||
Assert.assertEquals(property1.name, "id");
|
||||
Assert.assertNull(property1.defaultValue);
|
||||
Assert.assertEquals(property1.baseType, "int");
|
||||
Assert.assertTrue(property1.required);
|
||||
Assert.assertTrue(property1.isPrimitiveType);
|
||||
Assert.assertFalse(property1.isContainer);
|
||||
|
||||
final CodegenProperty property2 = cm.vars.get(1);
|
||||
Assert.assertEquals(property2.baseName, "name");
|
||||
Assert.assertEquals(property2.dataType, "String");
|
||||
Assert.assertEquals(property2.name, "name");
|
||||
Assert.assertNull(property2.defaultValue);
|
||||
Assert.assertEquals(property2.baseType, "String");
|
||||
Assert.assertTrue(property2.required);
|
||||
Assert.assertTrue(property2.isPrimitiveType);
|
||||
Assert.assertFalse(property2.isContainer);
|
||||
|
||||
final CodegenProperty property3 = cm.vars.get(2);
|
||||
Assert.assertEquals(property3.baseName, "createdAt");
|
||||
Assert.assertEquals(property3.complexType, "DateTime");
|
||||
Assert.assertEquals(property3.dataType, "DateTime");
|
||||
Assert.assertEquals(property3.name, "createdAt");
|
||||
Assert.assertNull(property3.defaultValue);
|
||||
Assert.assertEquals(property3.baseType, "DateTime");
|
||||
Assert.assertFalse(property3.required);
|
||||
Assert.assertFalse(property3.isContainer);
|
||||
}
|
||||
|
||||
@Test(description = "convert a simple dart-dit model with datelibrary")
|
||||
public void simpleModelWithTimeMachineTest() {
|
||||
final Schema model = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("id", new IntegerSchema())
|
||||
.addProperties("name", new StringSchema())
|
||||
.addProperties("createdAt", new DateTimeSchema())
|
||||
.addProperties("birthDate", new DateSchema())
|
||||
.addRequiredItem("id")
|
||||
.addRequiredItem("name");
|
||||
|
||||
final DartDioClientCodegen codegen = new DartDioClientCodegen();
|
||||
codegen.additionalProperties().put(DartDioClientCodegen.DATE_LIBRARY, "timemachine");
|
||||
codegen.setDateLibrary("timemachine");
|
||||
codegen.processOpts();
|
||||
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "a sample model");
|
||||
Assert.assertEquals(cm.vars.size(), 4);
|
||||
// {{imports}} is not used in template
|
||||
//Assert.assertEquals(cm.imports.size(), 1);
|
||||
|
||||
final CodegenProperty property1 = cm.vars.get(0);
|
||||
Assert.assertEquals(property1.baseName, "id");
|
||||
Assert.assertEquals(property1.dataType, "int");
|
||||
Assert.assertEquals(property1.name, "id");
|
||||
Assert.assertNull(property1.defaultValue);
|
||||
Assert.assertEquals(property1.baseType, "int");
|
||||
Assert.assertTrue(property1.required);
|
||||
Assert.assertTrue(property1.isPrimitiveType);
|
||||
Assert.assertFalse(property1.isContainer);
|
||||
|
||||
final CodegenProperty property2 = cm.vars.get(1);
|
||||
Assert.assertEquals(property2.baseName, "name");
|
||||
Assert.assertEquals(property2.dataType, "String");
|
||||
Assert.assertEquals(property2.name, "name");
|
||||
Assert.assertNull(property2.defaultValue);
|
||||
Assert.assertEquals(property2.baseType, "String");
|
||||
Assert.assertTrue(property2.required);
|
||||
Assert.assertTrue(property2.isPrimitiveType);
|
||||
Assert.assertFalse(property2.isContainer);
|
||||
|
||||
final CodegenProperty property3 = cm.vars.get(2);
|
||||
Assert.assertEquals(property3.baseName, "createdAt");
|
||||
Assert.assertEquals(property3.complexType, "OffsetDateTime");
|
||||
Assert.assertEquals(property3.dataType, "OffsetDateTime");
|
||||
Assert.assertEquals(property3.name, "createdAt");
|
||||
Assert.assertNull(property3.defaultValue);
|
||||
Assert.assertEquals(property3.baseType, "OffsetDateTime");
|
||||
Assert.assertFalse(property3.required);
|
||||
Assert.assertFalse(property3.isContainer);
|
||||
|
||||
final CodegenProperty property4 = cm.vars.get(3);
|
||||
Assert.assertEquals(property4.baseName, "birthDate");
|
||||
Assert.assertEquals(property4.complexType, "OffsetDate");
|
||||
Assert.assertEquals(property4.dataType, "OffsetDate");
|
||||
Assert.assertEquals(property4.name, "birthDate");
|
||||
Assert.assertNull(property4.defaultValue);
|
||||
Assert.assertEquals(property4.baseType, "OffsetDate");
|
||||
Assert.assertFalse(property4.required);
|
||||
Assert.assertFalse(property4.isContainer);
|
||||
}
|
||||
|
||||
@Test(description = "convert a model with list property")
|
||||
public void listPropertyTest() {
|
||||
final Schema model = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("id", new IntegerSchema())
|
||||
.addProperties("urls", new ArraySchema()
|
||||
.items(new StringSchema()))
|
||||
.addRequiredItem("id");
|
||||
final DefaultCodegen codegen = new DartDioClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "a sample model");
|
||||
Assert.assertEquals(cm.vars.size(), 2);
|
||||
|
||||
final CodegenProperty property1 = cm.vars.get(0);
|
||||
Assert.assertEquals(property1.baseName, "id");
|
||||
Assert.assertEquals(property1.dataType, "int");
|
||||
Assert.assertEquals(property1.name, "id");
|
||||
Assert.assertNull(property1.defaultValue);
|
||||
Assert.assertEquals(property1.baseType, "int");
|
||||
Assert.assertTrue(property1.required);
|
||||
Assert.assertTrue(property1.isPrimitiveType);
|
||||
Assert.assertFalse(property1.isContainer);
|
||||
|
||||
final CodegenProperty property2 = cm.vars.get(1);
|
||||
Assert.assertEquals(property2.baseName, "urls");
|
||||
Assert.assertEquals(property2.dataType, "BuiltList<String>");
|
||||
Assert.assertEquals(property2.name, "urls");
|
||||
Assert.assertEquals(property2.baseType, "BuiltList");
|
||||
Assert.assertEquals(property2.containerType, "array");
|
||||
Assert.assertFalse(property2.required);
|
||||
Assert.assertTrue(property2.isPrimitiveType);
|
||||
Assert.assertTrue(property2.isContainer);
|
||||
}
|
||||
|
||||
@Test(description = "convert a model with set property")
|
||||
public void setPropertyTest() {
|
||||
final Schema model = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("id", new IntegerSchema())
|
||||
.addProperties("urls", new ArraySchema().items(new StringSchema()).uniqueItems(true))
|
||||
.addRequiredItem("id");
|
||||
final DefaultCodegen codegen = new DartDioClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "a sample model");
|
||||
Assert.assertEquals(cm.vars.size(), 2);
|
||||
|
||||
final CodegenProperty property1 = cm.vars.get(0);
|
||||
Assert.assertEquals(property1.baseName, "id");
|
||||
Assert.assertEquals(property1.dataType, "int");
|
||||
Assert.assertEquals(property1.name, "id");
|
||||
Assert.assertNull(property1.defaultValue);
|
||||
Assert.assertEquals(property1.baseType, "int");
|
||||
Assert.assertTrue(property1.required);
|
||||
Assert.assertTrue(property1.isPrimitiveType);
|
||||
Assert.assertFalse(property1.isContainer);
|
||||
|
||||
final CodegenProperty property2 = cm.vars.get(1);
|
||||
Assert.assertEquals(property2.baseName, "urls");
|
||||
Assert.assertEquals(property2.dataType, "BuiltSet<String>");
|
||||
Assert.assertEquals(property2.name, "urls");
|
||||
Assert.assertEquals(property2.baseType, "BuiltSet");
|
||||
Assert.assertEquals(property2.containerType, "set");
|
||||
Assert.assertFalse(property2.required);
|
||||
Assert.assertTrue(property2.isPrimitiveType);
|
||||
Assert.assertTrue(property2.isContainer);
|
||||
}
|
||||
|
||||
@Test(description = "convert a model with a map property")
|
||||
public void mapPropertyTest() {
|
||||
final Schema model = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("translations", new MapSchema()
|
||||
.additionalProperties(new StringSchema()))
|
||||
.addRequiredItem("id");
|
||||
final DefaultCodegen codegen = new DartDioClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "a sample model");
|
||||
Assert.assertEquals(cm.vars.size(), 1);
|
||||
|
||||
final CodegenProperty property1 = cm.vars.get(0);
|
||||
Assert.assertEquals(property1.baseName, "translations");
|
||||
Assert.assertEquals(property1.dataType, "BuiltMap<String, String>");
|
||||
Assert.assertEquals(property1.name, "translations");
|
||||
Assert.assertEquals(property1.baseType, "BuiltMap");
|
||||
Assert.assertEquals(property1.containerType, "map");
|
||||
Assert.assertFalse(property1.required);
|
||||
Assert.assertTrue(property1.isContainer);
|
||||
Assert.assertTrue(property1.isPrimitiveType);
|
||||
}
|
||||
|
||||
@Test(description = "convert a model with complex property")
|
||||
public void complexPropertyTest() {
|
||||
final Schema model = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("children", new Schema().$ref("#/definitions/Children"));
|
||||
final DefaultCodegen codegen = new DartDioClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "a sample model");
|
||||
Assert.assertEquals(cm.vars.size(), 1);
|
||||
|
||||
final CodegenProperty property1 = cm.vars.get(0);
|
||||
Assert.assertEquals(property1.baseName, "children");
|
||||
Assert.assertEquals(property1.dataType, "Children");
|
||||
Assert.assertEquals(property1.name, "children");
|
||||
Assert.assertEquals(property1.baseType, "Children");
|
||||
Assert.assertFalse(property1.required);
|
||||
Assert.assertFalse(property1.isContainer);
|
||||
}
|
||||
|
||||
@Test(description = "convert a model with complex list property")
|
||||
public void complexListProperty() {
|
||||
final Schema model = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("children", new ArraySchema()
|
||||
.items(new Schema().$ref("#/definitions/Children")));
|
||||
final DefaultCodegen codegen = new DartDioClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "a sample model");
|
||||
Assert.assertEquals(cm.vars.size(), 1);
|
||||
|
||||
final CodegenProperty property1 = cm.vars.get(0);
|
||||
Assert.assertEquals(property1.baseName, "children");
|
||||
Assert.assertEquals(property1.dataType, "BuiltList<Children>");
|
||||
Assert.assertEquals(property1.name, "children");
|
||||
Assert.assertEquals(property1.baseType, "BuiltList");
|
||||
Assert.assertEquals(property1.containerType, "array");
|
||||
Assert.assertFalse(property1.required);
|
||||
Assert.assertTrue(property1.isContainer);
|
||||
}
|
||||
|
||||
@Test(description = "convert a model with complex map property")
|
||||
public void complexMapSchema() {
|
||||
final Schema model = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("children", new MapSchema()
|
||||
.additionalProperties(new Schema().$ref("#/definitions/Children")));
|
||||
final DefaultCodegen codegen = new DartDioClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "a sample model");
|
||||
Assert.assertEquals(cm.vars.size(), 1);
|
||||
// {{imports}} is not used in template
|
||||
//Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("Children")).size(), 1);
|
||||
|
||||
final CodegenProperty property1 = cm.vars.get(0);
|
||||
Assert.assertEquals(property1.baseName, "children");
|
||||
Assert.assertEquals(property1.complexType, "Children");
|
||||
Assert.assertEquals(property1.dataType, "BuiltMap<String, Children>");
|
||||
Assert.assertEquals(property1.name, "children");
|
||||
Assert.assertEquals(property1.baseType, "BuiltMap");
|
||||
Assert.assertEquals(property1.containerType, "map");
|
||||
Assert.assertFalse(property1.required);
|
||||
Assert.assertTrue(property1.isContainer);
|
||||
}
|
||||
|
||||
@Test(description = "convert an array model")
|
||||
public void arrayModelTest() {
|
||||
final Schema model = new ArraySchema()
|
||||
.items(new Schema().$ref("#/definitions/Children"))
|
||||
.description("an array model");
|
||||
final DefaultCodegen codegen = new DartDioClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(model.getDescription(), "an array model");
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertTrue(cm.isArray);
|
||||
Assert.assertEquals(cm.description, "an array model");
|
||||
Assert.assertEquals(cm.vars.size(), 0);
|
||||
}
|
||||
|
||||
@Test(description = "convert a map model")
|
||||
public void mapModelTest() {
|
||||
final Schema model = new Schema()
|
||||
.description("a map model")
|
||||
.additionalProperties(new Schema().$ref("#/definitions/Children"));
|
||||
final DefaultCodegen codegen = new DartDioClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "a map model");
|
||||
Assert.assertEquals(cm.vars.size(), 0);
|
||||
}
|
||||
|
||||
@DataProvider(name = "modelNames")
|
||||
public static Object[][] modelNames() {
|
||||
return new Object[][] {
|
||||
{"EnumClass", "TestModelEnumClass"},
|
||||
{"JsonObject", "TestModelJsonObject"}
|
||||
};
|
||||
}
|
||||
|
||||
@Test(dataProvider = "modelNames", description = "correctly prefix reserved model names")
|
||||
public void modelNameTest(String name, String expectedName) {
|
||||
OpenAPI openAPI = TestUtils.createOpenAPI();
|
||||
final Schema model = new Schema();
|
||||
final DartDioClientCodegen codegen = new DartDioClientCodegen();
|
||||
codegen.setOpenAPI(openAPI);
|
||||
codegen.typeMapping().put("EnumClass", "TestModelEnumClass");
|
||||
codegen.typeMapping().put("JsonObject", "TestModelJsonObject");
|
||||
final CodegenModel cm = codegen.fromModel(name, model);
|
||||
|
||||
Assert.assertEquals(cm.name, name);
|
||||
Assert.assertEquals(cm.classname, expectedName);
|
||||
}
|
||||
|
||||
@DataProvider(name = "modelNamesTimemachine")
|
||||
public static Object[][] modelNamesTimemachine() {
|
||||
return new Object[][] {
|
||||
{"EnumClass", "TestModelEnumClass"},
|
||||
{"JsonObject", "TestModelJsonObject"},
|
||||
{"OffsetDate", "TestModelOffsetDate"},
|
||||
};
|
||||
}
|
||||
|
||||
@Test(dataProvider = "modelNamesTimemachine", description = "correctly prefix reserved model names")
|
||||
public void modelNameTestTimemachine(String name, String expectedName) {
|
||||
OpenAPI openAPI = TestUtils.createOpenAPI();
|
||||
final Schema model = new Schema();
|
||||
final DartDioClientCodegen codegen = new DartDioClientCodegen();
|
||||
codegen.setDateLibrary("timemachine");
|
||||
codegen.processOpts();
|
||||
codegen.typeMapping().put("EnumClass", "TestModelEnumClass");
|
||||
codegen.typeMapping().put("JsonObject", "TestModelJsonObject");
|
||||
codegen.typeMapping().put("OffsetDate", "TestModelOffsetDate");
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel cm = codegen.fromModel(name, model);
|
||||
|
||||
Assert.assertEquals(cm.name, name);
|
||||
Assert.assertEquals(cm.classname, expectedName);
|
||||
}
|
||||
|
||||
@Test(description = "correctly generate collection default values")
|
||||
public void collectionDefaultValues() {
|
||||
final ArraySchema array = new ArraySchema();
|
||||
array.setDefault("[]");
|
||||
final Schema model = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("arrayNoDefault", new ArraySchema())
|
||||
.addProperties("arrayEmptyDefault", array)
|
||||
.addProperties("mapNoDefault", new MapSchema());
|
||||
final DefaultCodegen codegen = new DartDioClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
final CodegenProperty arrayNoDefault = cm.vars.get(0);
|
||||
Assert.assertEquals(arrayNoDefault.name, "arrayNoDefault");
|
||||
Assert.assertNull(arrayNoDefault.defaultValue);
|
||||
|
||||
final CodegenProperty arrayEmptyDefault = cm.vars.get(1);
|
||||
Assert.assertEquals(arrayEmptyDefault.name, "arrayEmptyDefault");
|
||||
Assert.assertEquals(arrayEmptyDefault.defaultValue, "ListBuilder()");
|
||||
|
||||
final CodegenProperty mapNoDefault = cm.vars.get(2);
|
||||
Assert.assertEquals(mapNoDefault.name, "mapNoDefault");
|
||||
Assert.assertNull(mapNoDefault.defaultValue);
|
||||
}
|
||||
|
||||
@Test(description = "correctly generate date/datetime default values, currently null")
|
||||
public void dateDefaultValues() {
|
||||
final DateSchema date = new DateSchema();
|
||||
date.setDefault("2021-01-01");
|
||||
final DateTimeSchema dateTime = new DateTimeSchema();
|
||||
dateTime.setDefault("2021-01-01T14:00:00Z");
|
||||
final Schema model = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("date", date)
|
||||
.addProperties("dateTime", dateTime)
|
||||
.addProperties("mapNoDefault", new MapSchema());
|
||||
final DefaultCodegen codegen = new DartDioClientCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
final CodegenProperty dateDefault = cm.vars.get(0);
|
||||
Assert.assertEquals(dateDefault.name, "date");
|
||||
Assert.assertNull(dateDefault.defaultValue);
|
||||
|
||||
final CodegenProperty dateTimeDefault = cm.vars.get(1);
|
||||
Assert.assertEquals(dateTimeDefault.name, "dateTime");
|
||||
Assert.assertNull(dateTimeDefault.defaultValue);
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.openapitools.codegen.dart.dio;
|
||||
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.languages.DartDioClientCodegen;
|
||||
import org.openapitools.codegen.languages.DartDioNextClientCodegen;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -25,7 +24,6 @@ import org.testng.annotations.Test;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -44,7 +42,7 @@ public class DartDioNextClientCodegenTest {
|
||||
|
||||
@Test
|
||||
public void testSettersForConfigValues() throws Exception {
|
||||
final DartDioClientCodegen codegen = new DartDioClientCodegen();
|
||||
final DartDioNextClientCodegen codegen = new DartDioNextClientCodegen();
|
||||
codegen.setHideGenerationTimestamp(false);
|
||||
codegen.processOpts();
|
||||
|
||||
@@ -54,7 +52,7 @@ public class DartDioNextClientCodegenTest {
|
||||
|
||||
@Test
|
||||
public void testAdditionalPropertiesPutForConfigValues() throws Exception {
|
||||
final DartDioClientCodegen codegen = new DartDioClientCodegen();
|
||||
final DartDioNextClientCodegen codegen = new DartDioNextClientCodegen();
|
||||
codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false);
|
||||
codegen.processOpts();
|
||||
|
||||
@@ -63,10 +61,10 @@ public class DartDioNextClientCodegenTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testKeywords() throws Exception {
|
||||
final DartDioClientCodegen codegen = new DartDioClientCodegen();
|
||||
public void testKeywords() {
|
||||
final DartDioNextClientCodegen codegen = new DartDioNextClientCodegen();
|
||||
|
||||
List<String> reservedWordsList = new ArrayList<String>();
|
||||
List<String> reservedWordsList = new ArrayList<>();
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("src/main/resources/dart/dart-keywords.txt"), StandardCharsets.UTF_8));
|
||||
while(reader.ready()) { reservedWordsList.add(reader.readLine()); }
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
* Copyright 2018 SmartBear Software
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen.options;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.languages.DartDioClientCodegen;
|
||||
|
||||
public class DartDioClientOptionsProvider implements OptionsProvider {
|
||||
public static final String SORT_PARAMS_VALUE = "true";
|
||||
public static final String SORT_MODEL_PROPERTIES_VALUE = "false";
|
||||
public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true";
|
||||
public static final String PUB_LIBRARY_VALUE = "openapi.api";
|
||||
public static final String PUB_NAME_VALUE = "openapi";
|
||||
public static final String PUB_VERSION_VALUE = "1.0.0-SNAPSHOT";
|
||||
public static final String PUB_DESCRIPTION_VALUE = "OpenAPI API client dart-dio";
|
||||
public static final String SOURCE_FOLDER_VALUE = "src";
|
||||
public static final String USE_ENUM_EXTENSION = "true";
|
||||
public static final String ALLOW_UNICODE_IDENTIFIERS_VALUE = "false";
|
||||
public static final String PREPEND_FORM_OR_BODY_PARAMETERS_VALUE = "true";
|
||||
public static final String DATE_LIBRARY = "core";
|
||||
public static final String NULLABLE_FIELDS = "true";
|
||||
public static final String PUB_AUTHOR_VALUE = "Author";
|
||||
public static final String PUB_AUTHOR_EMAIL_VALUE = "author@homepage";
|
||||
public static final String PUB_HOMEPAGE_VALUE = "Homepage";
|
||||
public static final String ENUM_UNKNOWN_DEFAULT_CASE_VALUE = "false";
|
||||
|
||||
@Override
|
||||
public String getLanguage() {
|
||||
return "dart-dio";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> createOptions() {
|
||||
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>();
|
||||
return builder.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE)
|
||||
.put(CodegenConstants.SORT_MODEL_PROPERTIES_BY_REQUIRED_FLAG, SORT_MODEL_PROPERTIES_VALUE)
|
||||
.put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE)
|
||||
.put(DartDioClientCodegen.PUB_LIBRARY, PUB_LIBRARY_VALUE)
|
||||
.put(DartDioClientCodegen.PUB_NAME, PUB_NAME_VALUE)
|
||||
.put(DartDioClientCodegen.PUB_VERSION, PUB_VERSION_VALUE)
|
||||
.put(DartDioClientCodegen.PUB_DESCRIPTION, PUB_DESCRIPTION_VALUE)
|
||||
.put(DartDioClientCodegen.PUB_AUTHOR, PUB_AUTHOR_VALUE)
|
||||
.put(DartDioClientCodegen.PUB_AUTHOR_EMAIL, PUB_AUTHOR_EMAIL_VALUE)
|
||||
.put(DartDioClientCodegen.PUB_HOMEPAGE, PUB_HOMEPAGE_VALUE)
|
||||
.put(CodegenConstants.SOURCE_FOLDER, SOURCE_FOLDER_VALUE)
|
||||
.put(DartDioClientCodegen.USE_ENUM_EXTENSION, USE_ENUM_EXTENSION)
|
||||
.put(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS, ALLOW_UNICODE_IDENTIFIERS_VALUE)
|
||||
.put(CodegenConstants.PREPEND_FORM_OR_BODY_PARAMETERS, PREPEND_FORM_OR_BODY_PARAMETERS_VALUE)
|
||||
.put(DartDioClientCodegen.DATE_LIBRARY, DATE_LIBRARY)
|
||||
.put(DartDioClientCodegen.NULLABLE_FIELDS, NULLABLE_FIELDS)
|
||||
.put(CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR, "true")
|
||||
.put(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT, "true")
|
||||
.put(CodegenConstants.ENUM_UNKNOWN_DEFAULT_CASE, ENUM_UNKNOWN_DEFAULT_CASE_VALUE)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isServer() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
17
pom.xml
17
pom.xml
@@ -1311,11 +1311,11 @@
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>samples.dart-2.13</id>
|
||||
<id>samples.dart</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>samples.dart-2.13</value>
|
||||
<value>samples.dart</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
@@ -1323,19 +1323,6 @@
|
||||
<module>samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>samples.dart-2.10</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>samples.dart-2.10</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>samples/openapi3/client/petstore/dart-dio/petstore_client_lib</module>
|
||||
<module>samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>samples.ios</id>
|
||||
<activation>
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
# See https://dart.dev/guides/libraries/private-files
|
||||
|
||||
# Files and directories created by pub
|
||||
.dart_tool/
|
||||
.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
|
||||
|
||||
# Don’t commit files and directories created by other development environments.
|
||||
# For example, if your development environment creates any of the following files,
|
||||
# consider putting them in a global ignore file:
|
||||
|
||||
# IntelliJ
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# Mac
|
||||
.DS_Store
|
||||
@@ -1,23 +0,0 @@
|
||||
# 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
|
||||
@@ -1,29 +0,0 @@
|
||||
.gitignore
|
||||
README.md
|
||||
analysis_options.yaml
|
||||
doc/ApiResponse.md
|
||||
doc/Category.md
|
||||
doc/Order.md
|
||||
doc/Pet.md
|
||||
doc/PetApi.md
|
||||
doc/StoreApi.md
|
||||
doc/Tag.md
|
||||
doc/User.md
|
||||
doc/UserApi.md
|
||||
lib/api.dart
|
||||
lib/api/pet_api.dart
|
||||
lib/api/store_api.dart
|
||||
lib/api/user_api.dart
|
||||
lib/api_util.dart
|
||||
lib/auth/api_key_auth.dart
|
||||
lib/auth/auth.dart
|
||||
lib/auth/basic_auth.dart
|
||||
lib/auth/oauth.dart
|
||||
lib/model/api_response.dart
|
||||
lib/model/category.dart
|
||||
lib/model/order.dart
|
||||
lib/model/pet.dart
|
||||
lib/model/tag.dart
|
||||
lib/model/user.dart
|
||||
lib/serializers.dart
|
||||
pubspec.yaml
|
||||
@@ -1 +0,0 @@
|
||||
6.0.0-SNAPSHOT
|
||||
@@ -1,115 +0,0 @@
|
||||
# openapi
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
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.DartDioClientCodegen
|
||||
|
||||
## Requirements
|
||||
|
||||
Dart 2.7.0 or later OR Flutter 1.12 or later
|
||||
|
||||
## Installation & Usage
|
||||
|
||||
### Github
|
||||
If this Dart package is published to Github, please include the following in pubspec.yaml
|
||||
```
|
||||
name: openapi
|
||||
version: 1.0.0
|
||||
description: OpenAPI API client
|
||||
dependencies:
|
||||
openapi:
|
||||
git: https://github.com/GIT_USER_ID/GIT_REPO_ID.git
|
||||
version: 'any'
|
||||
```
|
||||
|
||||
### Local
|
||||
To use the package in your local drive, please include the following in pubspec.yaml
|
||||
```
|
||||
dependencies:
|
||||
openapi:
|
||||
path: /path/to/openapi
|
||||
```
|
||||
|
||||
## Getting Started
|
||||
|
||||
Please follow the [installation procedure](#installation--usage) and then run the following:
|
||||
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
|
||||
final api = PetApi();
|
||||
final pet = Pet(); // Pet | Pet object that needs to be added to the store
|
||||
|
||||
try {
|
||||
final response = await api.addPet(pet);
|
||||
print(response);
|
||||
} catch (e) {
|
||||
print("Exception when calling PetApi->addPet: $e\n");
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Documentation for API Endpoints
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
*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
|
||||
*StoreApi* | [**deleteOrder**](doc/StoreApi.md#deleteorder) | **DELETE** /store/order/{orderId} | 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/{orderId} | 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
|
||||
|
||||
- [ApiResponse](doc/ApiResponse.md)
|
||||
- [Category](doc/Category.md)
|
||||
- [Order](doc/Order.md)
|
||||
- [Pet](doc/Pet.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
|
||||
|
||||
## 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
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
analyzer:
|
||||
language:
|
||||
strict-inference: true
|
||||
strict-raw-types: true
|
||||
strong-mode:
|
||||
implicit-dynamic: false
|
||||
implicit-casts: false
|
||||
exclude:
|
||||
- test/*.dart
|
||||
@@ -1,17 +0,0 @@
|
||||
# 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)
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
# openapi.model.Category
|
||||
|
||||
## 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)
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
# 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)
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
# 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** | **BuiltList<String>** | |
|
||||
**tags** | [**BuiltList<Tag>**](Tag.md) | | [optional]
|
||||
**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)
|
||||
|
||||
|
||||
@@ -1,391 +0,0 @@
|
||||
# openapi.api.PetApi
|
||||
|
||||
## Load the API package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io/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
|
||||
|
||||
|
||||
# **addPet**
|
||||
> Pet 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';
|
||||
|
||||
var api_instance = new PetApi();
|
||||
var pet = new Pet(); // Pet | Pet object that needs to be added to the store
|
||||
|
||||
try {
|
||||
var result = api_instance.addPet(pet);
|
||||
print(result);
|
||||
} 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
|
||||
|
||||
[**Pet**](Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json, application/xml
|
||||
- **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)
|
||||
|
||||
# **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';
|
||||
|
||||
var api_instance = new PetApi();
|
||||
var petId = 789; // int | Pet id to delete
|
||||
var 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**
|
||||
> BuiltList<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';
|
||||
|
||||
var api_instance = new PetApi();
|
||||
var status = []; // BuiltList<String> | Status values that need to be considered for filter
|
||||
|
||||
try {
|
||||
var result = api_instance.findPetsByStatus(status);
|
||||
print(result);
|
||||
} catch (e) {
|
||||
print('Exception when calling PetApi->findPetsByStatus: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**status** | [**BuiltList<String>**](String.md)| Status values that need to be considered for filter |
|
||||
|
||||
### Return type
|
||||
|
||||
[**BuiltList<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**
|
||||
> BuiltList<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';
|
||||
|
||||
var api_instance = new PetApi();
|
||||
var tags = []; // BuiltList<String> | Tags to filter by
|
||||
|
||||
try {
|
||||
var result = api_instance.findPetsByTags(tags);
|
||||
print(result);
|
||||
} catch (e) {
|
||||
print('Exception when calling PetApi->findPetsByTags: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**tags** | [**BuiltList<String>**](String.md)| Tags to filter by |
|
||||
|
||||
### Return type
|
||||
|
||||
[**BuiltList<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';
|
||||
|
||||
var api_instance = new PetApi();
|
||||
var petId = 789; // int | ID of pet to return
|
||||
|
||||
try {
|
||||
var 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**
|
||||
> Pet 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';
|
||||
|
||||
var api_instance = new PetApi();
|
||||
var pet = new Pet(); // Pet | Pet object that needs to be added to the store
|
||||
|
||||
try {
|
||||
var result = api_instance.updatePet(pet);
|
||||
print(result);
|
||||
} 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
|
||||
|
||||
[**Pet**](Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json, application/xml
|
||||
- **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)
|
||||
|
||||
# **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';
|
||||
|
||||
var api_instance = new PetApi();
|
||||
var petId = 789; // int | ID of pet that needs to be updated
|
||||
var name = name_example; // String | Updated name of the pet
|
||||
var 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';
|
||||
|
||||
var api_instance = new PetApi();
|
||||
var petId = 789; // int | ID of pet to update
|
||||
var additionalMetadata = additionalMetadata_example; // String | Additional data to pass to server
|
||||
var file = BINARY_DATA_HERE; // Uint8List | file to upload
|
||||
|
||||
try {
|
||||
var 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** | **Uint8List**| 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)
|
||||
|
||||
@@ -1,188 +0,0 @@
|
||||
# openapi.api.StoreApi
|
||||
|
||||
## Load the API package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**deleteOrder**](StoreApi.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
|
||||
[**getInventory**](StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status
|
||||
[**getOrderById**](StoreApi.md#getorderbyid) | **GET** /store/order/{orderId} | 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';
|
||||
|
||||
var api_instance = new StoreApi();
|
||||
var 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**
|
||||
> BuiltMap<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';
|
||||
|
||||
var api_instance = new StoreApi();
|
||||
|
||||
try {
|
||||
var 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
|
||||
|
||||
**BuiltMap<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';
|
||||
|
||||
var api_instance = new StoreApi();
|
||||
var orderId = 789; // int | ID of pet that needs to be fetched
|
||||
|
||||
try {
|
||||
var 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';
|
||||
|
||||
var api_instance = new StoreApi();
|
||||
var order = new Order(); // Order | order placed for purchasing the pet
|
||||
|
||||
try {
|
||||
var 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)
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
# 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)
|
||||
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
# 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)
|
||||
|
||||
|
||||
@@ -1,383 +0,0 @@
|
||||
# openapi.api.UserApi
|
||||
|
||||
## Load the API package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io/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';
|
||||
// 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';
|
||||
|
||||
var api_instance = new UserApi();
|
||||
var user = new 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
|
||||
|
||||
[api_key](../README.md#api_key)
|
||||
|
||||
### 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';
|
||||
// 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';
|
||||
|
||||
var api_instance = new UserApi();
|
||||
var user = [new BuiltList<User>()]; // BuiltList<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** | [**BuiltList<User>**](User.md)| List of user object |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[api_key](../README.md#api_key)
|
||||
|
||||
### 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';
|
||||
// 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';
|
||||
|
||||
var api_instance = new UserApi();
|
||||
var user = [new BuiltList<User>()]; // BuiltList<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** | [**BuiltList<User>**](User.md)| List of user object |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[api_key](../README.md#api_key)
|
||||
|
||||
### 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';
|
||||
// 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';
|
||||
|
||||
var api_instance = new UserApi();
|
||||
var 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
|
||||
|
||||
[api_key](../README.md#api_key)
|
||||
|
||||
### 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';
|
||||
|
||||
var api_instance = new UserApi();
|
||||
var username = username_example; // String | The name that needs to be fetched. Use user1 for testing.
|
||||
|
||||
try {
|
||||
var 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';
|
||||
|
||||
var api_instance = new UserApi();
|
||||
var username = username_example; // String | The user name for login
|
||||
var password = password_example; // String | The password for login in clear text
|
||||
|
||||
try {
|
||||
var 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';
|
||||
// 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';
|
||||
|
||||
var api_instance = new 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
|
||||
|
||||
[api_key](../README.md#api_key)
|
||||
|
||||
### 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';
|
||||
// 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';
|
||||
|
||||
var api_instance = new UserApi();
|
||||
var username = username_example; // String | name that need to be deleted
|
||||
var user = new 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
|
||||
|
||||
[api_key](../README.md#api_key)
|
||||
|
||||
### 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)
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.7
|
||||
|
||||
// ignore_for_file: unused_import
|
||||
|
||||
library openapi.api;
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:built_value/serializer.dart';
|
||||
import 'package:openapi/serializers.dart';
|
||||
import 'package:openapi/auth/api_key_auth.dart';
|
||||
import 'package:openapi/auth/basic_auth.dart';
|
||||
import 'package:openapi/auth/oauth.dart';
|
||||
import 'package:openapi/api/pet_api.dart';
|
||||
import 'package:openapi/api/store_api.dart';
|
||||
import 'package:openapi/api/user_api.dart';
|
||||
|
||||
|
||||
final _defaultInterceptors = [
|
||||
OAuthInterceptor(),
|
||||
BasicAuthInterceptor(),
|
||||
ApiKeyAuthInterceptor(),
|
||||
];
|
||||
|
||||
class Openapi {
|
||||
|
||||
static const String basePath = r'http://petstore.swagger.io/v2';
|
||||
|
||||
final Dio dio;
|
||||
|
||||
final Serializers serializers;
|
||||
|
||||
Openapi({
|
||||
Dio dio,
|
||||
Serializers serializers,
|
||||
String basePathOverride,
|
||||
List<Interceptor> interceptors,
|
||||
}) : this.serializers = serializers ?? standardSerializers,
|
||||
this.dio = dio ??
|
||||
Dio(BaseOptions(
|
||||
baseUrl: basePathOverride ?? basePath,
|
||||
connectTimeout: 5000,
|
||||
receiveTimeout: 3000,
|
||||
)) {
|
||||
if (interceptors == null) {
|
||||
this.dio.interceptors.addAll(_defaultInterceptors);
|
||||
} else {
|
||||
this.dio.interceptors.addAll(interceptors);
|
||||
}
|
||||
}
|
||||
|
||||
void setOAuthToken(String name, String token) {
|
||||
(this.dio.interceptors.firstWhere((element) => element is OAuthInterceptor, orElse: null) as OAuthInterceptor)?.tokens[name] = token;
|
||||
}
|
||||
|
||||
void setBasicAuth(String name, String username, String password) {
|
||||
(this.dio.interceptors.firstWhere((element) => element is BasicAuthInterceptor, orElse: null) as BasicAuthInterceptor)?.authInfo[name] = BasicAuthInfo(username, password);
|
||||
}
|
||||
|
||||
void setApiKey(String name, String apiKey) {
|
||||
(this.dio.interceptors.firstWhere((element) => element is ApiKeyAuthInterceptor, orElse: null) as ApiKeyAuthInterceptor)?.apiKeys[name] = apiKey;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get PetApi instance, base route and serializer can be overridden by a given but be careful,
|
||||
* by doing that all interceptors will not be executed
|
||||
*/
|
||||
PetApi getPetApi() {
|
||||
return PetApi(dio, serializers);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get StoreApi instance, base route and serializer can be overridden by a given but be careful,
|
||||
* by doing that all interceptors will not be executed
|
||||
*/
|
||||
StoreApi getStoreApi() {
|
||||
return StoreApi(dio, serializers);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get UserApi instance, base route and serializer can be overridden by a given but be careful,
|
||||
* by doing that all interceptors will not be executed
|
||||
*/
|
||||
UserApi getUserApi() {
|
||||
return UserApi(dio, serializers);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,506 +0,0 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.7
|
||||
|
||||
// ignore_for_file: unused_import
|
||||
|
||||
import 'dart:async';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:built_value/serializer.dart';
|
||||
|
||||
import 'dart:typed_data';
|
||||
import 'package:built_collection/built_collection.dart';
|
||||
import 'package:openapi/api_util.dart';
|
||||
import 'package:openapi/model/api_response.dart';
|
||||
import 'package:openapi/model/pet.dart';
|
||||
|
||||
class PetApi {
|
||||
|
||||
final Dio _dio;
|
||||
|
||||
final Serializers _serializers;
|
||||
|
||||
const PetApi(this._dio, this._serializers);
|
||||
|
||||
/// Add a new pet to the store
|
||||
///
|
||||
///
|
||||
Future<Response<Pet>> addPet(
|
||||
Pet pet, {
|
||||
CancelToken cancelToken,
|
||||
Map<String, dynamic> headers,
|
||||
Map<String, dynamic> extra,
|
||||
ValidateStatus validateStatus,
|
||||
ProgressCallback onSendProgress,
|
||||
ProgressCallback onReceiveProgress,
|
||||
}) async {
|
||||
final _request = RequestOptions(
|
||||
path: r'/pet',
|
||||
method: 'POST',
|
||||
headers: <String, dynamic>{
|
||||
...?headers,
|
||||
},
|
||||
extra: <String, dynamic>{
|
||||
'secure': <Map<String, String>>[
|
||||
{
|
||||
'type': 'oauth2',
|
||||
'name': 'petstore_auth',
|
||||
},
|
||||
],
|
||||
...?extra,
|
||||
},
|
||||
validateStatus: validateStatus,
|
||||
contentType: 'application/json',
|
||||
cancelToken: cancelToken,
|
||||
onSendProgress: onSendProgress,
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
);
|
||||
|
||||
dynamic _bodyData;
|
||||
|
||||
const _type = FullType(Pet);
|
||||
_bodyData = _serializers.serialize(pet, specifiedType: _type);
|
||||
|
||||
final _response = await _dio.request<dynamic>(
|
||||
_request.path,
|
||||
data: _bodyData,
|
||||
options: _request,
|
||||
);
|
||||
|
||||
const _responseType = FullType(Pet);
|
||||
final _responseData = _serializers.deserialize(
|
||||
_response.data,
|
||||
specifiedType: _responseType,
|
||||
) as Pet;
|
||||
|
||||
return Response<Pet>(
|
||||
data: _responseData,
|
||||
headers: _response.headers,
|
||||
isRedirect: _response.isRedirect,
|
||||
request: _response.request,
|
||||
redirects: _response.redirects,
|
||||
statusCode: _response.statusCode,
|
||||
statusMessage: _response.statusMessage,
|
||||
extra: _response.extra,
|
||||
);
|
||||
}
|
||||
|
||||
/// Deletes a pet
|
||||
///
|
||||
///
|
||||
Future<Response<void>> deletePet(
|
||||
int petId, {
|
||||
String apiKey,
|
||||
CancelToken cancelToken,
|
||||
Map<String, dynamic> headers,
|
||||
Map<String, dynamic> extra,
|
||||
ValidateStatus validateStatus,
|
||||
ProgressCallback onSendProgress,
|
||||
ProgressCallback onReceiveProgress,
|
||||
}) async {
|
||||
final _request = RequestOptions(
|
||||
path: r'/pet/{petId}'.replaceAll('{' r'petId' '}', petId.toString()),
|
||||
method: 'DELETE',
|
||||
headers: <String, dynamic>{
|
||||
if (apiKey != null) r'api_key': apiKey,
|
||||
...?headers,
|
||||
},
|
||||
extra: <String, dynamic>{
|
||||
'secure': <Map<String, String>>[
|
||||
{
|
||||
'type': 'oauth2',
|
||||
'name': 'petstore_auth',
|
||||
},
|
||||
],
|
||||
...?extra,
|
||||
},
|
||||
validateStatus: validateStatus,
|
||||
contentType: 'application/json',
|
||||
cancelToken: cancelToken,
|
||||
onSendProgress: onSendProgress,
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
);
|
||||
|
||||
dynamic _bodyData;
|
||||
|
||||
final _response = await _dio.request<dynamic>(
|
||||
_request.path,
|
||||
data: _bodyData,
|
||||
options: _request,
|
||||
);
|
||||
|
||||
return _response;
|
||||
}
|
||||
|
||||
/// Finds Pets by status
|
||||
///
|
||||
/// Multiple status values can be provided with comma separated strings
|
||||
Future<Response<BuiltList<Pet>>> findPetsByStatus(
|
||||
BuiltList<String> status, {
|
||||
CancelToken cancelToken,
|
||||
Map<String, dynamic> headers,
|
||||
Map<String, dynamic> extra,
|
||||
ValidateStatus validateStatus,
|
||||
ProgressCallback onSendProgress,
|
||||
ProgressCallback onReceiveProgress,
|
||||
}) async {
|
||||
final _request = RequestOptions(
|
||||
path: r'/pet/findByStatus',
|
||||
method: 'GET',
|
||||
headers: <String, dynamic>{
|
||||
...?headers,
|
||||
},
|
||||
queryParameters: <String, dynamic>{
|
||||
r'status': status,
|
||||
},
|
||||
extra: <String, dynamic>{
|
||||
'secure': <Map<String, String>>[
|
||||
{
|
||||
'type': 'oauth2',
|
||||
'name': 'petstore_auth',
|
||||
},
|
||||
],
|
||||
...?extra,
|
||||
},
|
||||
validateStatus: validateStatus,
|
||||
contentType: 'application/json',
|
||||
cancelToken: cancelToken,
|
||||
onSendProgress: onSendProgress,
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
);
|
||||
|
||||
dynamic _bodyData;
|
||||
|
||||
final _response = await _dio.request<dynamic>(
|
||||
_request.path,
|
||||
data: _bodyData,
|
||||
options: _request,
|
||||
);
|
||||
|
||||
const _responseType = FullType(BuiltList, [FullType(Pet)]);
|
||||
final BuiltList<Pet> _responseData = _serializers.deserialize(
|
||||
_response.data,
|
||||
specifiedType: _responseType,
|
||||
) as BuiltList<Pet>;
|
||||
|
||||
return Response<BuiltList<Pet>>(
|
||||
data: _responseData,
|
||||
headers: _response.headers,
|
||||
isRedirect: _response.isRedirect,
|
||||
request: _response.request,
|
||||
redirects: _response.redirects,
|
||||
statusCode: _response.statusCode,
|
||||
statusMessage: _response.statusMessage,
|
||||
extra: _response.extra,
|
||||
);
|
||||
}
|
||||
|
||||
/// Finds Pets by tags
|
||||
///
|
||||
/// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
Future<Response<BuiltList<Pet>>> findPetsByTags(
|
||||
BuiltList<String> tags, {
|
||||
CancelToken cancelToken,
|
||||
Map<String, dynamic> headers,
|
||||
Map<String, dynamic> extra,
|
||||
ValidateStatus validateStatus,
|
||||
ProgressCallback onSendProgress,
|
||||
ProgressCallback onReceiveProgress,
|
||||
}) async {
|
||||
final _request = RequestOptions(
|
||||
path: r'/pet/findByTags',
|
||||
method: 'GET',
|
||||
headers: <String, dynamic>{
|
||||
...?headers,
|
||||
},
|
||||
queryParameters: <String, dynamic>{
|
||||
r'tags': tags,
|
||||
},
|
||||
extra: <String, dynamic>{
|
||||
'secure': <Map<String, String>>[
|
||||
{
|
||||
'type': 'oauth2',
|
||||
'name': 'petstore_auth',
|
||||
},
|
||||
],
|
||||
...?extra,
|
||||
},
|
||||
validateStatus: validateStatus,
|
||||
contentType: 'application/json',
|
||||
cancelToken: cancelToken,
|
||||
onSendProgress: onSendProgress,
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
);
|
||||
|
||||
dynamic _bodyData;
|
||||
|
||||
final _response = await _dio.request<dynamic>(
|
||||
_request.path,
|
||||
data: _bodyData,
|
||||
options: _request,
|
||||
);
|
||||
|
||||
const _responseType = FullType(BuiltList, [FullType(Pet)]);
|
||||
final BuiltList<Pet> _responseData = _serializers.deserialize(
|
||||
_response.data,
|
||||
specifiedType: _responseType,
|
||||
) as BuiltList<Pet>;
|
||||
|
||||
return Response<BuiltList<Pet>>(
|
||||
data: _responseData,
|
||||
headers: _response.headers,
|
||||
isRedirect: _response.isRedirect,
|
||||
request: _response.request,
|
||||
redirects: _response.redirects,
|
||||
statusCode: _response.statusCode,
|
||||
statusMessage: _response.statusMessage,
|
||||
extra: _response.extra,
|
||||
);
|
||||
}
|
||||
|
||||
/// Find pet by ID
|
||||
///
|
||||
/// Returns a single pet
|
||||
Future<Response<Pet>> getPetById(
|
||||
int petId, {
|
||||
CancelToken cancelToken,
|
||||
Map<String, dynamic> headers,
|
||||
Map<String, dynamic> extra,
|
||||
ValidateStatus validateStatus,
|
||||
ProgressCallback onSendProgress,
|
||||
ProgressCallback onReceiveProgress,
|
||||
}) async {
|
||||
final _request = RequestOptions(
|
||||
path: r'/pet/{petId}'.replaceAll('{' r'petId' '}', petId.toString()),
|
||||
method: 'GET',
|
||||
headers: <String, dynamic>{
|
||||
...?headers,
|
||||
},
|
||||
extra: <String, dynamic>{
|
||||
'secure': <Map<String, String>>[
|
||||
{
|
||||
'type': 'apiKey',
|
||||
'name': 'api_key',
|
||||
'keyName': 'api_key',
|
||||
'where': 'header',
|
||||
},
|
||||
],
|
||||
...?extra,
|
||||
},
|
||||
validateStatus: validateStatus,
|
||||
contentType: 'application/json',
|
||||
cancelToken: cancelToken,
|
||||
onSendProgress: onSendProgress,
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
);
|
||||
|
||||
dynamic _bodyData;
|
||||
|
||||
final _response = await _dio.request<dynamic>(
|
||||
_request.path,
|
||||
data: _bodyData,
|
||||
options: _request,
|
||||
);
|
||||
|
||||
const _responseType = FullType(Pet);
|
||||
final _responseData = _serializers.deserialize(
|
||||
_response.data,
|
||||
specifiedType: _responseType,
|
||||
) as Pet;
|
||||
|
||||
return Response<Pet>(
|
||||
data: _responseData,
|
||||
headers: _response.headers,
|
||||
isRedirect: _response.isRedirect,
|
||||
request: _response.request,
|
||||
redirects: _response.redirects,
|
||||
statusCode: _response.statusCode,
|
||||
statusMessage: _response.statusMessage,
|
||||
extra: _response.extra,
|
||||
);
|
||||
}
|
||||
|
||||
/// Update an existing pet
|
||||
///
|
||||
///
|
||||
Future<Response<Pet>> updatePet(
|
||||
Pet pet, {
|
||||
CancelToken cancelToken,
|
||||
Map<String, dynamic> headers,
|
||||
Map<String, dynamic> extra,
|
||||
ValidateStatus validateStatus,
|
||||
ProgressCallback onSendProgress,
|
||||
ProgressCallback onReceiveProgress,
|
||||
}) async {
|
||||
final _request = RequestOptions(
|
||||
path: r'/pet',
|
||||
method: 'PUT',
|
||||
headers: <String, dynamic>{
|
||||
...?headers,
|
||||
},
|
||||
extra: <String, dynamic>{
|
||||
'secure': <Map<String, String>>[
|
||||
{
|
||||
'type': 'oauth2',
|
||||
'name': 'petstore_auth',
|
||||
},
|
||||
],
|
||||
...?extra,
|
||||
},
|
||||
validateStatus: validateStatus,
|
||||
contentType: 'application/json',
|
||||
cancelToken: cancelToken,
|
||||
onSendProgress: onSendProgress,
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
);
|
||||
|
||||
dynamic _bodyData;
|
||||
|
||||
const _type = FullType(Pet);
|
||||
_bodyData = _serializers.serialize(pet, specifiedType: _type);
|
||||
|
||||
final _response = await _dio.request<dynamic>(
|
||||
_request.path,
|
||||
data: _bodyData,
|
||||
options: _request,
|
||||
);
|
||||
|
||||
const _responseType = FullType(Pet);
|
||||
final _responseData = _serializers.deserialize(
|
||||
_response.data,
|
||||
specifiedType: _responseType,
|
||||
) as Pet;
|
||||
|
||||
return Response<Pet>(
|
||||
data: _responseData,
|
||||
headers: _response.headers,
|
||||
isRedirect: _response.isRedirect,
|
||||
request: _response.request,
|
||||
redirects: _response.redirects,
|
||||
statusCode: _response.statusCode,
|
||||
statusMessage: _response.statusMessage,
|
||||
extra: _response.extra,
|
||||
);
|
||||
}
|
||||
|
||||
/// Updates a pet in the store with form data
|
||||
///
|
||||
///
|
||||
Future<Response<void>> updatePetWithForm(
|
||||
int petId, {
|
||||
String name,
|
||||
String status,
|
||||
CancelToken cancelToken,
|
||||
Map<String, dynamic> headers,
|
||||
Map<String, dynamic> extra,
|
||||
ValidateStatus validateStatus,
|
||||
ProgressCallback onSendProgress,
|
||||
ProgressCallback onReceiveProgress,
|
||||
}) async {
|
||||
final _request = RequestOptions(
|
||||
path: r'/pet/{petId}'.replaceAll('{' r'petId' '}', petId.toString()),
|
||||
method: 'POST',
|
||||
headers: <String, dynamic>{
|
||||
...?headers,
|
||||
},
|
||||
extra: <String, dynamic>{
|
||||
'secure': <Map<String, String>>[
|
||||
{
|
||||
'type': 'oauth2',
|
||||
'name': 'petstore_auth',
|
||||
},
|
||||
],
|
||||
...?extra,
|
||||
},
|
||||
validateStatus: validateStatus,
|
||||
contentType: 'application/x-www-form-urlencoded',
|
||||
cancelToken: cancelToken,
|
||||
onSendProgress: onSendProgress,
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
);
|
||||
|
||||
dynamic _bodyData;
|
||||
|
||||
_bodyData = <String, dynamic>{
|
||||
if (name != null) r'name': encodeFormParameter(_serializers, name, const FullType(String)),
|
||||
if (status != null) r'status': encodeFormParameter(_serializers, status, const FullType(String)),
|
||||
};
|
||||
|
||||
final _response = await _dio.request<dynamic>(
|
||||
_request.path,
|
||||
data: _bodyData,
|
||||
options: _request,
|
||||
);
|
||||
|
||||
return _response;
|
||||
}
|
||||
|
||||
/// uploads an image
|
||||
///
|
||||
///
|
||||
Future<Response<ApiResponse>> uploadFile(
|
||||
int petId, {
|
||||
String additionalMetadata,
|
||||
Uint8List file,
|
||||
CancelToken cancelToken,
|
||||
Map<String, dynamic> headers,
|
||||
Map<String, dynamic> extra,
|
||||
ValidateStatus validateStatus,
|
||||
ProgressCallback onSendProgress,
|
||||
ProgressCallback onReceiveProgress,
|
||||
}) async {
|
||||
final _request = RequestOptions(
|
||||
path: r'/pet/{petId}/uploadImage'.replaceAll('{' r'petId' '}', petId.toString()),
|
||||
method: 'POST',
|
||||
headers: <String, dynamic>{
|
||||
...?headers,
|
||||
},
|
||||
extra: <String, dynamic>{
|
||||
'secure': <Map<String, String>>[
|
||||
{
|
||||
'type': 'oauth2',
|
||||
'name': 'petstore_auth',
|
||||
},
|
||||
],
|
||||
...?extra,
|
||||
},
|
||||
validateStatus: validateStatus,
|
||||
contentType: 'multipart/form-data',
|
||||
cancelToken: cancelToken,
|
||||
onSendProgress: onSendProgress,
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
);
|
||||
|
||||
dynamic _bodyData;
|
||||
|
||||
_bodyData = FormData.fromMap(<String, dynamic>{
|
||||
if (additionalMetadata != null) r'additionalMetadata': encodeFormParameter(_serializers, additionalMetadata, const FullType(String)),
|
||||
if (file != null) r'file': MultipartFile.fromBytes(file, filename: r'file'),
|
||||
});
|
||||
|
||||
final _response = await _dio.request<dynamic>(
|
||||
_request.path,
|
||||
data: _bodyData,
|
||||
options: _request,
|
||||
);
|
||||
|
||||
const _responseType = FullType(ApiResponse);
|
||||
final _responseData = _serializers.deserialize(
|
||||
_response.data,
|
||||
specifiedType: _responseType,
|
||||
) as ApiResponse;
|
||||
|
||||
return Response<ApiResponse>(
|
||||
data: _responseData,
|
||||
headers: _response.headers,
|
||||
isRedirect: _response.isRedirect,
|
||||
request: _response.request,
|
||||
redirects: _response.redirects,
|
||||
statusCode: _response.statusCode,
|
||||
statusMessage: _response.statusMessage,
|
||||
extra: _response.extra,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,237 +0,0 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.7
|
||||
|
||||
// ignore_for_file: unused_import
|
||||
|
||||
import 'dart:async';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:built_value/serializer.dart';
|
||||
|
||||
import 'package:built_collection/built_collection.dart';
|
||||
import 'package:openapi/model/order.dart';
|
||||
|
||||
class StoreApi {
|
||||
|
||||
final Dio _dio;
|
||||
|
||||
final Serializers _serializers;
|
||||
|
||||
const StoreApi(this._dio, this._serializers);
|
||||
|
||||
/// Delete purchase order by ID
|
||||
///
|
||||
/// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
Future<Response<void>> deleteOrder(
|
||||
String orderId, {
|
||||
CancelToken cancelToken,
|
||||
Map<String, dynamic> headers,
|
||||
Map<String, dynamic> extra,
|
||||
ValidateStatus validateStatus,
|
||||
ProgressCallback onSendProgress,
|
||||
ProgressCallback onReceiveProgress,
|
||||
}) async {
|
||||
final _request = RequestOptions(
|
||||
path: r'/store/order/{orderId}'.replaceAll('{' r'orderId' '}', orderId.toString()),
|
||||
method: 'DELETE',
|
||||
headers: <String, dynamic>{
|
||||
...?headers,
|
||||
},
|
||||
extra: <String, dynamic>{
|
||||
'secure': <Map<String, String>>[],
|
||||
...?extra,
|
||||
},
|
||||
validateStatus: validateStatus,
|
||||
contentType: 'application/json',
|
||||
cancelToken: cancelToken,
|
||||
onSendProgress: onSendProgress,
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
);
|
||||
|
||||
dynamic _bodyData;
|
||||
|
||||
final _response = await _dio.request<dynamic>(
|
||||
_request.path,
|
||||
data: _bodyData,
|
||||
options: _request,
|
||||
);
|
||||
|
||||
return _response;
|
||||
}
|
||||
|
||||
/// Returns pet inventories by status
|
||||
///
|
||||
/// Returns a map of status codes to quantities
|
||||
Future<Response<BuiltMap<String, int>>> getInventory({
|
||||
CancelToken cancelToken,
|
||||
Map<String, dynamic> headers,
|
||||
Map<String, dynamic> extra,
|
||||
ValidateStatus validateStatus,
|
||||
ProgressCallback onSendProgress,
|
||||
ProgressCallback onReceiveProgress,
|
||||
}) async {
|
||||
final _request = RequestOptions(
|
||||
path: r'/store/inventory',
|
||||
method: 'GET',
|
||||
headers: <String, dynamic>{
|
||||
...?headers,
|
||||
},
|
||||
extra: <String, dynamic>{
|
||||
'secure': <Map<String, String>>[
|
||||
{
|
||||
'type': 'apiKey',
|
||||
'name': 'api_key',
|
||||
'keyName': 'api_key',
|
||||
'where': 'header',
|
||||
},
|
||||
],
|
||||
...?extra,
|
||||
},
|
||||
validateStatus: validateStatus,
|
||||
contentType: 'application/json',
|
||||
cancelToken: cancelToken,
|
||||
onSendProgress: onSendProgress,
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
);
|
||||
|
||||
dynamic _bodyData;
|
||||
|
||||
final _response = await _dio.request<dynamic>(
|
||||
_request.path,
|
||||
data: _bodyData,
|
||||
options: _request,
|
||||
);
|
||||
|
||||
const _responseType = FullType(BuiltMap, [FullType(String), FullType(int)]);
|
||||
final BuiltMap<String, int> _responseData = _serializers.deserialize(
|
||||
_response.data,
|
||||
specifiedType: _responseType,
|
||||
) as BuiltMap<String, int>;
|
||||
|
||||
return Response<BuiltMap<String, int>>(
|
||||
data: _responseData,
|
||||
headers: _response.headers,
|
||||
isRedirect: _response.isRedirect,
|
||||
request: _response.request,
|
||||
redirects: _response.redirects,
|
||||
statusCode: _response.statusCode,
|
||||
statusMessage: _response.statusMessage,
|
||||
extra: _response.extra,
|
||||
);
|
||||
}
|
||||
|
||||
/// Find purchase order by ID
|
||||
///
|
||||
/// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
Future<Response<Order>> getOrderById(
|
||||
int orderId, {
|
||||
CancelToken cancelToken,
|
||||
Map<String, dynamic> headers,
|
||||
Map<String, dynamic> extra,
|
||||
ValidateStatus validateStatus,
|
||||
ProgressCallback onSendProgress,
|
||||
ProgressCallback onReceiveProgress,
|
||||
}) async {
|
||||
final _request = RequestOptions(
|
||||
path: r'/store/order/{orderId}'.replaceAll('{' r'orderId' '}', orderId.toString()),
|
||||
method: 'GET',
|
||||
headers: <String, dynamic>{
|
||||
...?headers,
|
||||
},
|
||||
extra: <String, dynamic>{
|
||||
'secure': <Map<String, String>>[],
|
||||
...?extra,
|
||||
},
|
||||
validateStatus: validateStatus,
|
||||
contentType: 'application/json',
|
||||
cancelToken: cancelToken,
|
||||
onSendProgress: onSendProgress,
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
);
|
||||
|
||||
dynamic _bodyData;
|
||||
|
||||
final _response = await _dio.request<dynamic>(
|
||||
_request.path,
|
||||
data: _bodyData,
|
||||
options: _request,
|
||||
);
|
||||
|
||||
const _responseType = FullType(Order);
|
||||
final _responseData = _serializers.deserialize(
|
||||
_response.data,
|
||||
specifiedType: _responseType,
|
||||
) as Order;
|
||||
|
||||
return Response<Order>(
|
||||
data: _responseData,
|
||||
headers: _response.headers,
|
||||
isRedirect: _response.isRedirect,
|
||||
request: _response.request,
|
||||
redirects: _response.redirects,
|
||||
statusCode: _response.statusCode,
|
||||
statusMessage: _response.statusMessage,
|
||||
extra: _response.extra,
|
||||
);
|
||||
}
|
||||
|
||||
/// Place an order for a pet
|
||||
///
|
||||
///
|
||||
Future<Response<Order>> placeOrder(
|
||||
Order order, {
|
||||
CancelToken cancelToken,
|
||||
Map<String, dynamic> headers,
|
||||
Map<String, dynamic> extra,
|
||||
ValidateStatus validateStatus,
|
||||
ProgressCallback onSendProgress,
|
||||
ProgressCallback onReceiveProgress,
|
||||
}) async {
|
||||
final _request = RequestOptions(
|
||||
path: r'/store/order',
|
||||
method: 'POST',
|
||||
headers: <String, dynamic>{
|
||||
...?headers,
|
||||
},
|
||||
extra: <String, dynamic>{
|
||||
'secure': <Map<String, String>>[],
|
||||
...?extra,
|
||||
},
|
||||
validateStatus: validateStatus,
|
||||
contentType: 'application/json',
|
||||
cancelToken: cancelToken,
|
||||
onSendProgress: onSendProgress,
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
);
|
||||
|
||||
dynamic _bodyData;
|
||||
|
||||
const _type = FullType(Order);
|
||||
_bodyData = _serializers.serialize(order, specifiedType: _type);
|
||||
|
||||
final _response = await _dio.request<dynamic>(
|
||||
_request.path,
|
||||
data: _bodyData,
|
||||
options: _request,
|
||||
);
|
||||
|
||||
const _responseType = FullType(Order);
|
||||
final _responseData = _serializers.deserialize(
|
||||
_response.data,
|
||||
specifiedType: _responseType,
|
||||
) as Order;
|
||||
|
||||
return Response<Order>(
|
||||
data: _responseData,
|
||||
headers: _response.headers,
|
||||
isRedirect: _response.isRedirect,
|
||||
request: _response.request,
|
||||
redirects: _response.redirects,
|
||||
statusCode: _response.statusCode,
|
||||
statusMessage: _response.statusMessage,
|
||||
extra: _response.extra,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,428 +0,0 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.7
|
||||
|
||||
// ignore_for_file: unused_import
|
||||
|
||||
import 'dart:async';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:built_value/serializer.dart';
|
||||
|
||||
import 'package:built_collection/built_collection.dart';
|
||||
import 'package:openapi/model/user.dart';
|
||||
|
||||
class UserApi {
|
||||
|
||||
final Dio _dio;
|
||||
|
||||
final Serializers _serializers;
|
||||
|
||||
const UserApi(this._dio, this._serializers);
|
||||
|
||||
/// Create user
|
||||
///
|
||||
/// This can only be done by the logged in user.
|
||||
Future<Response<void>> createUser(
|
||||
User user, {
|
||||
CancelToken cancelToken,
|
||||
Map<String, dynamic> headers,
|
||||
Map<String, dynamic> extra,
|
||||
ValidateStatus validateStatus,
|
||||
ProgressCallback onSendProgress,
|
||||
ProgressCallback onReceiveProgress,
|
||||
}) async {
|
||||
final _request = RequestOptions(
|
||||
path: r'/user',
|
||||
method: 'POST',
|
||||
headers: <String, dynamic>{
|
||||
...?headers,
|
||||
},
|
||||
extra: <String, dynamic>{
|
||||
'secure': <Map<String, String>>[
|
||||
{
|
||||
'type': 'apiKey',
|
||||
'name': 'api_key',
|
||||
'keyName': 'api_key',
|
||||
'where': 'header',
|
||||
},
|
||||
],
|
||||
...?extra,
|
||||
},
|
||||
validateStatus: validateStatus,
|
||||
contentType: 'application/json',
|
||||
cancelToken: cancelToken,
|
||||
onSendProgress: onSendProgress,
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
);
|
||||
|
||||
dynamic _bodyData;
|
||||
|
||||
const _type = FullType(User);
|
||||
_bodyData = _serializers.serialize(user, specifiedType: _type);
|
||||
|
||||
final _response = await _dio.request<dynamic>(
|
||||
_request.path,
|
||||
data: _bodyData,
|
||||
options: _request,
|
||||
);
|
||||
|
||||
return _response;
|
||||
}
|
||||
|
||||
/// Creates list of users with given input array
|
||||
///
|
||||
///
|
||||
Future<Response<void>> createUsersWithArrayInput(
|
||||
BuiltList<User> user, {
|
||||
CancelToken cancelToken,
|
||||
Map<String, dynamic> headers,
|
||||
Map<String, dynamic> extra,
|
||||
ValidateStatus validateStatus,
|
||||
ProgressCallback onSendProgress,
|
||||
ProgressCallback onReceiveProgress,
|
||||
}) async {
|
||||
final _request = RequestOptions(
|
||||
path: r'/user/createWithArray',
|
||||
method: 'POST',
|
||||
headers: <String, dynamic>{
|
||||
...?headers,
|
||||
},
|
||||
extra: <String, dynamic>{
|
||||
'secure': <Map<String, String>>[
|
||||
{
|
||||
'type': 'apiKey',
|
||||
'name': 'api_key',
|
||||
'keyName': 'api_key',
|
||||
'where': 'header',
|
||||
},
|
||||
],
|
||||
...?extra,
|
||||
},
|
||||
validateStatus: validateStatus,
|
||||
contentType: 'application/json',
|
||||
cancelToken: cancelToken,
|
||||
onSendProgress: onSendProgress,
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
);
|
||||
|
||||
dynamic _bodyData;
|
||||
|
||||
const _type = FullType(BuiltList, [FullType(User)]);
|
||||
_bodyData = _serializers.serialize(user, specifiedType: _type);
|
||||
|
||||
final _response = await _dio.request<dynamic>(
|
||||
_request.path,
|
||||
data: _bodyData,
|
||||
options: _request,
|
||||
);
|
||||
|
||||
return _response;
|
||||
}
|
||||
|
||||
/// Creates list of users with given input array
|
||||
///
|
||||
///
|
||||
Future<Response<void>> createUsersWithListInput(
|
||||
BuiltList<User> user, {
|
||||
CancelToken cancelToken,
|
||||
Map<String, dynamic> headers,
|
||||
Map<String, dynamic> extra,
|
||||
ValidateStatus validateStatus,
|
||||
ProgressCallback onSendProgress,
|
||||
ProgressCallback onReceiveProgress,
|
||||
}) async {
|
||||
final _request = RequestOptions(
|
||||
path: r'/user/createWithList',
|
||||
method: 'POST',
|
||||
headers: <String, dynamic>{
|
||||
...?headers,
|
||||
},
|
||||
extra: <String, dynamic>{
|
||||
'secure': <Map<String, String>>[
|
||||
{
|
||||
'type': 'apiKey',
|
||||
'name': 'api_key',
|
||||
'keyName': 'api_key',
|
||||
'where': 'header',
|
||||
},
|
||||
],
|
||||
...?extra,
|
||||
},
|
||||
validateStatus: validateStatus,
|
||||
contentType: 'application/json',
|
||||
cancelToken: cancelToken,
|
||||
onSendProgress: onSendProgress,
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
);
|
||||
|
||||
dynamic _bodyData;
|
||||
|
||||
const _type = FullType(BuiltList, [FullType(User)]);
|
||||
_bodyData = _serializers.serialize(user, specifiedType: _type);
|
||||
|
||||
final _response = await _dio.request<dynamic>(
|
||||
_request.path,
|
||||
data: _bodyData,
|
||||
options: _request,
|
||||
);
|
||||
|
||||
return _response;
|
||||
}
|
||||
|
||||
/// Delete user
|
||||
///
|
||||
/// This can only be done by the logged in user.
|
||||
Future<Response<void>> deleteUser(
|
||||
String username, {
|
||||
CancelToken cancelToken,
|
||||
Map<String, dynamic> headers,
|
||||
Map<String, dynamic> extra,
|
||||
ValidateStatus validateStatus,
|
||||
ProgressCallback onSendProgress,
|
||||
ProgressCallback onReceiveProgress,
|
||||
}) async {
|
||||
final _request = RequestOptions(
|
||||
path: r'/user/{username}'.replaceAll('{' r'username' '}', username.toString()),
|
||||
method: 'DELETE',
|
||||
headers: <String, dynamic>{
|
||||
...?headers,
|
||||
},
|
||||
extra: <String, dynamic>{
|
||||
'secure': <Map<String, String>>[
|
||||
{
|
||||
'type': 'apiKey',
|
||||
'name': 'api_key',
|
||||
'keyName': 'api_key',
|
||||
'where': 'header',
|
||||
},
|
||||
],
|
||||
...?extra,
|
||||
},
|
||||
validateStatus: validateStatus,
|
||||
contentType: 'application/json',
|
||||
cancelToken: cancelToken,
|
||||
onSendProgress: onSendProgress,
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
);
|
||||
|
||||
dynamic _bodyData;
|
||||
|
||||
final _response = await _dio.request<dynamic>(
|
||||
_request.path,
|
||||
data: _bodyData,
|
||||
options: _request,
|
||||
);
|
||||
|
||||
return _response;
|
||||
}
|
||||
|
||||
/// Get user by user name
|
||||
///
|
||||
///
|
||||
Future<Response<User>> getUserByName(
|
||||
String username, {
|
||||
CancelToken cancelToken,
|
||||
Map<String, dynamic> headers,
|
||||
Map<String, dynamic> extra,
|
||||
ValidateStatus validateStatus,
|
||||
ProgressCallback onSendProgress,
|
||||
ProgressCallback onReceiveProgress,
|
||||
}) async {
|
||||
final _request = RequestOptions(
|
||||
path: r'/user/{username}'.replaceAll('{' r'username' '}', username.toString()),
|
||||
method: 'GET',
|
||||
headers: <String, dynamic>{
|
||||
...?headers,
|
||||
},
|
||||
extra: <String, dynamic>{
|
||||
'secure': <Map<String, String>>[],
|
||||
...?extra,
|
||||
},
|
||||
validateStatus: validateStatus,
|
||||
contentType: 'application/json',
|
||||
cancelToken: cancelToken,
|
||||
onSendProgress: onSendProgress,
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
);
|
||||
|
||||
dynamic _bodyData;
|
||||
|
||||
final _response = await _dio.request<dynamic>(
|
||||
_request.path,
|
||||
data: _bodyData,
|
||||
options: _request,
|
||||
);
|
||||
|
||||
const _responseType = FullType(User);
|
||||
final _responseData = _serializers.deserialize(
|
||||
_response.data,
|
||||
specifiedType: _responseType,
|
||||
) as User;
|
||||
|
||||
return Response<User>(
|
||||
data: _responseData,
|
||||
headers: _response.headers,
|
||||
isRedirect: _response.isRedirect,
|
||||
request: _response.request,
|
||||
redirects: _response.redirects,
|
||||
statusCode: _response.statusCode,
|
||||
statusMessage: _response.statusMessage,
|
||||
extra: _response.extra,
|
||||
);
|
||||
}
|
||||
|
||||
/// Logs user into the system
|
||||
///
|
||||
///
|
||||
Future<Response<String>> loginUser(
|
||||
String username,
|
||||
String password, {
|
||||
CancelToken cancelToken,
|
||||
Map<String, dynamic> headers,
|
||||
Map<String, dynamic> extra,
|
||||
ValidateStatus validateStatus,
|
||||
ProgressCallback onSendProgress,
|
||||
ProgressCallback onReceiveProgress,
|
||||
}) async {
|
||||
final _request = RequestOptions(
|
||||
path: r'/user/login',
|
||||
method: 'GET',
|
||||
headers: <String, dynamic>{
|
||||
...?headers,
|
||||
},
|
||||
queryParameters: <String, dynamic>{
|
||||
r'username': username,
|
||||
r'password': password,
|
||||
},
|
||||
extra: <String, dynamic>{
|
||||
'secure': <Map<String, String>>[],
|
||||
...?extra,
|
||||
},
|
||||
validateStatus: validateStatus,
|
||||
contentType: 'application/json',
|
||||
cancelToken: cancelToken,
|
||||
onSendProgress: onSendProgress,
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
);
|
||||
|
||||
dynamic _bodyData;
|
||||
|
||||
final _response = await _dio.request<dynamic>(
|
||||
_request.path,
|
||||
data: _bodyData,
|
||||
options: _request,
|
||||
);
|
||||
|
||||
final String _responseData = _response.data as String;
|
||||
|
||||
return Response<String>(
|
||||
data: _responseData,
|
||||
headers: _response.headers,
|
||||
isRedirect: _response.isRedirect,
|
||||
request: _response.request,
|
||||
redirects: _response.redirects,
|
||||
statusCode: _response.statusCode,
|
||||
statusMessage: _response.statusMessage,
|
||||
extra: _response.extra,
|
||||
);
|
||||
}
|
||||
|
||||
/// Logs out current logged in user session
|
||||
///
|
||||
///
|
||||
Future<Response<void>> logoutUser({
|
||||
CancelToken cancelToken,
|
||||
Map<String, dynamic> headers,
|
||||
Map<String, dynamic> extra,
|
||||
ValidateStatus validateStatus,
|
||||
ProgressCallback onSendProgress,
|
||||
ProgressCallback onReceiveProgress,
|
||||
}) async {
|
||||
final _request = RequestOptions(
|
||||
path: r'/user/logout',
|
||||
method: 'GET',
|
||||
headers: <String, dynamic>{
|
||||
...?headers,
|
||||
},
|
||||
extra: <String, dynamic>{
|
||||
'secure': <Map<String, String>>[
|
||||
{
|
||||
'type': 'apiKey',
|
||||
'name': 'api_key',
|
||||
'keyName': 'api_key',
|
||||
'where': 'header',
|
||||
},
|
||||
],
|
||||
...?extra,
|
||||
},
|
||||
validateStatus: validateStatus,
|
||||
contentType: 'application/json',
|
||||
cancelToken: cancelToken,
|
||||
onSendProgress: onSendProgress,
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
);
|
||||
|
||||
dynamic _bodyData;
|
||||
|
||||
final _response = await _dio.request<dynamic>(
|
||||
_request.path,
|
||||
data: _bodyData,
|
||||
options: _request,
|
||||
);
|
||||
|
||||
return _response;
|
||||
}
|
||||
|
||||
/// Updated user
|
||||
///
|
||||
/// This can only be done by the logged in user.
|
||||
Future<Response<void>> updateUser(
|
||||
String username,
|
||||
User user, {
|
||||
CancelToken cancelToken,
|
||||
Map<String, dynamic> headers,
|
||||
Map<String, dynamic> extra,
|
||||
ValidateStatus validateStatus,
|
||||
ProgressCallback onSendProgress,
|
||||
ProgressCallback onReceiveProgress,
|
||||
}) async {
|
||||
final _request = RequestOptions(
|
||||
path: r'/user/{username}'.replaceAll('{' r'username' '}', username.toString()),
|
||||
method: 'PUT',
|
||||
headers: <String, dynamic>{
|
||||
...?headers,
|
||||
},
|
||||
extra: <String, dynamic>{
|
||||
'secure': <Map<String, String>>[
|
||||
{
|
||||
'type': 'apiKey',
|
||||
'name': 'api_key',
|
||||
'keyName': 'api_key',
|
||||
'where': 'header',
|
||||
},
|
||||
],
|
||||
...?extra,
|
||||
},
|
||||
validateStatus: validateStatus,
|
||||
contentType: 'application/json',
|
||||
cancelToken: cancelToken,
|
||||
onSendProgress: onSendProgress,
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
);
|
||||
|
||||
dynamic _bodyData;
|
||||
|
||||
const _type = FullType(User);
|
||||
_bodyData = _serializers.serialize(user, specifiedType: _type);
|
||||
|
||||
final _response = await _dio.request<dynamic>(
|
||||
_request.path,
|
||||
data: _bodyData,
|
||||
options: _request,
|
||||
);
|
||||
|
||||
return _response;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.7
|
||||
|
||||
// ignore_for_file: unused_import
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:built_collection/built_collection.dart';
|
||||
import 'package:built_value/serializer.dart';
|
||||
|
||||
/// Format the given form parameter object into something that Dio can handle.
|
||||
/// Returns primitive or String.
|
||||
/// Returns List/Map if the value is BuildList/BuiltMap.
|
||||
dynamic encodeFormParameter(Serializers serializers, dynamic value, FullType type) {
|
||||
if (value == null) {
|
||||
return '';
|
||||
}
|
||||
if (value is String || value is num || value is bool) {
|
||||
return value;
|
||||
}
|
||||
final serialized = serializers.serialize(value, specifiedType: type);
|
||||
if (serialized is String) {
|
||||
return serialized;
|
||||
}
|
||||
if (value is BuiltList || value is BuiltMap) {
|
||||
return serialized;
|
||||
}
|
||||
return json.encode(serialized);
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.7
|
||||
|
||||
// ignore_for_file: unused_import
|
||||
|
||||
import 'dart:async';
|
||||
import 'package:openapi/auth/auth.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
class ApiKeyAuthInterceptor extends AuthInterceptor {
|
||||
Map<String, String> apiKeys = {};
|
||||
|
||||
@override
|
||||
Future<dynamic> onRequest(RequestOptions options) {
|
||||
final authInfo = getAuthInfo(options, 'apiKey');
|
||||
for (final info in authInfo) {
|
||||
final authName = info['name'] as String;
|
||||
final authKeyName = info['keyName'] as String;
|
||||
final authWhere = info['where'] as String;
|
||||
final apiKey = apiKeys[authName];
|
||||
if (apiKey != null) {
|
||||
if (authWhere == 'query') {
|
||||
options.queryParameters[authKeyName] = apiKey;
|
||||
} else {
|
||||
options.headers[authKeyName] = apiKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.onRequest(options);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.7
|
||||
|
||||
// ignore_for_file: unused_import
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
abstract class AuthInterceptor extends Interceptor {
|
||||
/// Get auth information on given route for the given type.
|
||||
/// Can return an empty list if type is not present on auth data or
|
||||
/// if route doesn't need authentication.
|
||||
List<Map<String, dynamic>> getAuthInfo(RequestOptions route, String type) {
|
||||
if (route.extra.containsKey('secure')) {
|
||||
final auth = route.extra['secure'] as List<Map<String, String>>;
|
||||
final results = <Map<String, dynamic>>[];
|
||||
for (final info in auth) {
|
||||
if (info['type'] == type) {
|
||||
results.add(info);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.7
|
||||
|
||||
// ignore_for_file: unused_import
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'package:openapi/auth/auth.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
class BasicAuthInfo {
|
||||
final String username;
|
||||
final String password;
|
||||
|
||||
const BasicAuthInfo(this.username, this.password);
|
||||
}
|
||||
|
||||
class BasicAuthInterceptor extends AuthInterceptor {
|
||||
Map<String, BasicAuthInfo> authInfo = {};
|
||||
|
||||
@override
|
||||
Future<dynamic> onRequest(RequestOptions options) {
|
||||
final metadataAuthInfo = getAuthInfo(options, 'basic');
|
||||
for (final info in metadataAuthInfo) {
|
||||
final authName = info['name'] as String;
|
||||
final basicAuthInfo = authInfo[authName];
|
||||
if (basicAuthInfo != null) {
|
||||
final basicAuth = 'Basic ' + base64Encode(utf8.encode('${basicAuthInfo.username}:${basicAuthInfo.password}'));
|
||||
options.headers['Authorization'] = basicAuth;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return super.onRequest(options);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.7
|
||||
|
||||
// ignore_for_file: unused_import
|
||||
|
||||
import 'dart:async';
|
||||
import 'package:openapi/auth/auth.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
class OAuthInterceptor extends AuthInterceptor {
|
||||
Map<String, String> tokens = {};
|
||||
|
||||
@override
|
||||
Future<dynamic> onRequest(RequestOptions options) {
|
||||
final authInfo = getAuthInfo(options, 'oauth');
|
||||
for (final info in authInfo) {
|
||||
final token = tokens[info['name']];
|
||||
if (token != null) {
|
||||
options.headers['Authorization'] = 'Bearer ${token}';
|
||||
break;
|
||||
}
|
||||
}
|
||||
return super.onRequest(options);
|
||||
}
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.7
|
||||
|
||||
// ignore_for_file: unused_import
|
||||
|
||||
import 'package:built_value/built_value.dart';
|
||||
import 'package:built_value/serializer.dart';
|
||||
|
||||
part 'api_response.g.dart';
|
||||
|
||||
abstract class ApiResponse implements Built<ApiResponse, ApiResponseBuilder> {
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: r'code')
|
||||
int get code;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: r'type')
|
||||
String get type;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: r'message')
|
||||
String get message;
|
||||
|
||||
ApiResponse._();
|
||||
|
||||
static void _initializeBuilder(ApiResponseBuilder b) => b;
|
||||
|
||||
factory ApiResponse([void updates(ApiResponseBuilder b)]) = _$ApiResponse;
|
||||
|
||||
@BuiltValueSerializer(custom: true)
|
||||
static Serializer<ApiResponse> get serializer => _$ApiResponseSerializer();
|
||||
}
|
||||
|
||||
class _$ApiResponseSerializer implements StructuredSerializer<ApiResponse> {
|
||||
|
||||
@override
|
||||
final Iterable<Type> types = const [ApiResponse, _$ApiResponse];
|
||||
@override
|
||||
final String wireName = r'ApiResponse';
|
||||
|
||||
@override
|
||||
Iterable<Object> serialize(Serializers serializers, ApiResponse object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = <Object>[];
|
||||
if (object.code != null) {
|
||||
result
|
||||
..add(r'code')
|
||||
..add(serializers.serialize(object.code,
|
||||
specifiedType: const FullType(int)));
|
||||
}
|
||||
if (object.type != null) {
|
||||
result
|
||||
..add(r'type')
|
||||
..add(serializers.serialize(object.type,
|
||||
specifiedType: const FullType(String)));
|
||||
}
|
||||
if (object.message != null) {
|
||||
result
|
||||
..add(r'message')
|
||||
..add(serializers.serialize(object.message,
|
||||
specifiedType: const FullType(String)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
ApiResponse deserialize(Serializers serializers, Iterable<Object> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = ApiResponseBuilder();
|
||||
|
||||
final iterator = serialized.iterator;
|
||||
while (iterator.moveNext()) {
|
||||
final key = iterator.current as String;
|
||||
iterator.moveNext();
|
||||
final dynamic value = iterator.current;
|
||||
switch (key) {
|
||||
case r'code':
|
||||
result.code = serializers.deserialize(value,
|
||||
specifiedType: const FullType(int)) as int;
|
||||
break;
|
||||
case r'type':
|
||||
result.type = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String;
|
||||
break;
|
||||
case r'message':
|
||||
result.message = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.7
|
||||
|
||||
// ignore_for_file: unused_import
|
||||
|
||||
import 'package:built_value/built_value.dart';
|
||||
import 'package:built_value/serializer.dart';
|
||||
|
||||
part 'category.g.dart';
|
||||
|
||||
abstract class Category implements Built<Category, CategoryBuilder> {
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: r'id')
|
||||
int get id;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: r'name')
|
||||
String get name;
|
||||
|
||||
Category._();
|
||||
|
||||
static void _initializeBuilder(CategoryBuilder b) => b;
|
||||
|
||||
factory Category([void updates(CategoryBuilder b)]) = _$Category;
|
||||
|
||||
@BuiltValueSerializer(custom: true)
|
||||
static Serializer<Category> get serializer => _$CategorySerializer();
|
||||
}
|
||||
|
||||
class _$CategorySerializer implements StructuredSerializer<Category> {
|
||||
|
||||
@override
|
||||
final Iterable<Type> types = const [Category, _$Category];
|
||||
@override
|
||||
final String wireName = r'Category';
|
||||
|
||||
@override
|
||||
Iterable<Object> serialize(Serializers serializers, Category object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = <Object>[];
|
||||
if (object.id != null) {
|
||||
result
|
||||
..add(r'id')
|
||||
..add(serializers.serialize(object.id,
|
||||
specifiedType: const FullType(int)));
|
||||
}
|
||||
if (object.name != null) {
|
||||
result
|
||||
..add(r'name')
|
||||
..add(serializers.serialize(object.name,
|
||||
specifiedType: const FullType(String)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
Category deserialize(Serializers serializers, Iterable<Object> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = CategoryBuilder();
|
||||
|
||||
final iterator = serialized.iterator;
|
||||
while (iterator.moveNext()) {
|
||||
final key = iterator.current as String;
|
||||
iterator.moveNext();
|
||||
final dynamic value = iterator.current;
|
||||
switch (key) {
|
||||
case r'id':
|
||||
result.id = serializers.deserialize(value,
|
||||
specifiedType: const FullType(int)) as int;
|
||||
break;
|
||||
case r'name':
|
||||
result.name = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.7
|
||||
|
||||
// ignore_for_file: unused_import
|
||||
|
||||
import 'package:built_collection/built_collection.dart';
|
||||
import 'package:built_value/built_value.dart';
|
||||
import 'package:built_value/serializer.dart';
|
||||
|
||||
part 'order.g.dart';
|
||||
|
||||
abstract class Order implements Built<Order, OrderBuilder> {
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: r'id')
|
||||
int get id;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: r'petId')
|
||||
int get petId;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: r'quantity')
|
||||
int get quantity;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: r'shipDate')
|
||||
DateTime get shipDate;
|
||||
|
||||
/// Order Status
|
||||
@nullable
|
||||
@BuiltValueField(wireName: r'status')
|
||||
OrderStatusEnum get status;
|
||||
// enum statusEnum { placed, approved, delivered, };
|
||||
|
||||
@BuiltValueField(wireName: r'complete')
|
||||
bool get complete;
|
||||
|
||||
Order._();
|
||||
|
||||
static void _initializeBuilder(OrderBuilder b) => b
|
||||
..complete = false;
|
||||
|
||||
factory Order([void updates(OrderBuilder b)]) = _$Order;
|
||||
|
||||
@BuiltValueSerializer(custom: true)
|
||||
static Serializer<Order> get serializer => _$OrderSerializer();
|
||||
}
|
||||
|
||||
class _$OrderSerializer implements StructuredSerializer<Order> {
|
||||
|
||||
@override
|
||||
final Iterable<Type> types = const [Order, _$Order];
|
||||
@override
|
||||
final String wireName = r'Order';
|
||||
|
||||
@override
|
||||
Iterable<Object> serialize(Serializers serializers, Order object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = <Object>[];
|
||||
if (object.id != null) {
|
||||
result
|
||||
..add(r'id')
|
||||
..add(serializers.serialize(object.id,
|
||||
specifiedType: const FullType(int)));
|
||||
}
|
||||
if (object.petId != null) {
|
||||
result
|
||||
..add(r'petId')
|
||||
..add(serializers.serialize(object.petId,
|
||||
specifiedType: const FullType(int)));
|
||||
}
|
||||
if (object.quantity != null) {
|
||||
result
|
||||
..add(r'quantity')
|
||||
..add(serializers.serialize(object.quantity,
|
||||
specifiedType: const FullType(int)));
|
||||
}
|
||||
if (object.shipDate != null) {
|
||||
result
|
||||
..add(r'shipDate')
|
||||
..add(serializers.serialize(object.shipDate,
|
||||
specifiedType: const FullType(DateTime)));
|
||||
}
|
||||
if (object.status != null) {
|
||||
result
|
||||
..add(r'status')
|
||||
..add(serializers.serialize(object.status,
|
||||
specifiedType: const FullType(OrderStatusEnum)));
|
||||
}
|
||||
if (object.complete != null) {
|
||||
result
|
||||
..add(r'complete')
|
||||
..add(serializers.serialize(object.complete,
|
||||
specifiedType: const FullType(bool)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
Order deserialize(Serializers serializers, Iterable<Object> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = OrderBuilder();
|
||||
|
||||
final iterator = serialized.iterator;
|
||||
while (iterator.moveNext()) {
|
||||
final key = iterator.current as String;
|
||||
iterator.moveNext();
|
||||
final dynamic value = iterator.current;
|
||||
switch (key) {
|
||||
case r'id':
|
||||
result.id = serializers.deserialize(value,
|
||||
specifiedType: const FullType(int)) as int;
|
||||
break;
|
||||
case r'petId':
|
||||
result.petId = serializers.deserialize(value,
|
||||
specifiedType: const FullType(int)) as int;
|
||||
break;
|
||||
case r'quantity':
|
||||
result.quantity = serializers.deserialize(value,
|
||||
specifiedType: const FullType(int)) as int;
|
||||
break;
|
||||
case r'shipDate':
|
||||
result.shipDate = serializers.deserialize(value,
|
||||
specifiedType: const FullType(DateTime)) as DateTime;
|
||||
break;
|
||||
case r'status':
|
||||
result.status = serializers.deserialize(value,
|
||||
specifiedType: const FullType(OrderStatusEnum)) as OrderStatusEnum;
|
||||
break;
|
||||
case r'complete':
|
||||
result.complete = serializers.deserialize(value,
|
||||
specifiedType: const FullType(bool)) as bool;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result.build();
|
||||
}
|
||||
}
|
||||
|
||||
class OrderStatusEnum extends EnumClass {
|
||||
|
||||
/// Order Status
|
||||
@BuiltValueEnumConst(wireName: r'placed')
|
||||
static const OrderStatusEnum placed = _$orderStatusEnum_placed;
|
||||
/// Order Status
|
||||
@BuiltValueEnumConst(wireName: r'approved')
|
||||
static const OrderStatusEnum approved = _$orderStatusEnum_approved;
|
||||
/// Order Status
|
||||
@BuiltValueEnumConst(wireName: r'delivered')
|
||||
static const OrderStatusEnum delivered = _$orderStatusEnum_delivered;
|
||||
/// Order Status
|
||||
@BuiltValueEnumConst(wireName: r'unknown_default_open_api', fallback: true)
|
||||
static const OrderStatusEnum unknownDefaultOpenApi = _$orderStatusEnum_unknownDefaultOpenApi;
|
||||
|
||||
static Serializer<OrderStatusEnum> get serializer => _$orderStatusEnumSerializer;
|
||||
|
||||
const OrderStatusEnum._(String name): super(name);
|
||||
|
||||
static BuiltSet<OrderStatusEnum> get values => _$orderStatusEnumValues;
|
||||
static OrderStatusEnum valueOf(String name) => _$orderStatusEnumValueOf(name);
|
||||
}
|
||||
|
||||
@@ -1,161 +0,0 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.7
|
||||
|
||||
// ignore_for_file: unused_import
|
||||
|
||||
import 'package:openapi/model/tag.dart';
|
||||
import 'package:built_collection/built_collection.dart';
|
||||
import 'package:openapi/model/category.dart';
|
||||
import 'package:built_value/built_value.dart';
|
||||
import 'package:built_value/serializer.dart';
|
||||
|
||||
part 'pet.g.dart';
|
||||
|
||||
abstract class Pet implements Built<Pet, PetBuilder> {
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: r'id')
|
||||
int get id;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: r'category')
|
||||
Category get category;
|
||||
|
||||
@BuiltValueField(wireName: r'name')
|
||||
String get name;
|
||||
|
||||
@BuiltValueField(wireName: r'photoUrls')
|
||||
BuiltList<String> get photoUrls;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: r'tags')
|
||||
BuiltList<Tag> get tags;
|
||||
|
||||
/// pet status in the store
|
||||
@nullable
|
||||
@BuiltValueField(wireName: r'status')
|
||||
PetStatusEnum get status;
|
||||
// enum statusEnum { available, pending, sold, };
|
||||
|
||||
Pet._();
|
||||
|
||||
static void _initializeBuilder(PetBuilder b) => b;
|
||||
|
||||
factory Pet([void updates(PetBuilder b)]) = _$Pet;
|
||||
|
||||
@BuiltValueSerializer(custom: true)
|
||||
static Serializer<Pet> get serializer => _$PetSerializer();
|
||||
}
|
||||
|
||||
class _$PetSerializer implements StructuredSerializer<Pet> {
|
||||
|
||||
@override
|
||||
final Iterable<Type> types = const [Pet, _$Pet];
|
||||
@override
|
||||
final String wireName = r'Pet';
|
||||
|
||||
@override
|
||||
Iterable<Object> serialize(Serializers serializers, Pet object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = <Object>[];
|
||||
if (object.id != null) {
|
||||
result
|
||||
..add(r'id')
|
||||
..add(serializers.serialize(object.id,
|
||||
specifiedType: const FullType(int)));
|
||||
}
|
||||
if (object.category != null) {
|
||||
result
|
||||
..add(r'category')
|
||||
..add(serializers.serialize(object.category,
|
||||
specifiedType: const FullType(Category)));
|
||||
}
|
||||
result
|
||||
..add(r'name')
|
||||
..add(serializers.serialize(object.name,
|
||||
specifiedType: const FullType(String)));
|
||||
result
|
||||
..add(r'photoUrls')
|
||||
..add(serializers.serialize(object.photoUrls,
|
||||
specifiedType: const FullType(BuiltList, [FullType(String)])));
|
||||
if (object.tags != null) {
|
||||
result
|
||||
..add(r'tags')
|
||||
..add(serializers.serialize(object.tags,
|
||||
specifiedType: const FullType(BuiltList, [FullType(Tag)])));
|
||||
}
|
||||
if (object.status != null) {
|
||||
result
|
||||
..add(r'status')
|
||||
..add(serializers.serialize(object.status,
|
||||
specifiedType: const FullType(PetStatusEnum)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
Pet deserialize(Serializers serializers, Iterable<Object> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = PetBuilder();
|
||||
|
||||
final iterator = serialized.iterator;
|
||||
while (iterator.moveNext()) {
|
||||
final key = iterator.current as String;
|
||||
iterator.moveNext();
|
||||
final dynamic value = iterator.current;
|
||||
switch (key) {
|
||||
case r'id':
|
||||
result.id = serializers.deserialize(value,
|
||||
specifiedType: const FullType(int)) as int;
|
||||
break;
|
||||
case r'category':
|
||||
result.category.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(Category)) as Category);
|
||||
break;
|
||||
case r'name':
|
||||
result.name = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String;
|
||||
break;
|
||||
case r'photoUrls':
|
||||
result.photoUrls.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(BuiltList, [FullType(String)])) as BuiltList<String>);
|
||||
break;
|
||||
case r'tags':
|
||||
result.tags.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(BuiltList, [FullType(Tag)])) as BuiltList<Tag>);
|
||||
break;
|
||||
case r'status':
|
||||
result.status = serializers.deserialize(value,
|
||||
specifiedType: const FullType(PetStatusEnum)) as PetStatusEnum;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result.build();
|
||||
}
|
||||
}
|
||||
|
||||
class PetStatusEnum extends EnumClass {
|
||||
|
||||
/// pet status in the store
|
||||
@BuiltValueEnumConst(wireName: r'available')
|
||||
static const PetStatusEnum available = _$petStatusEnum_available;
|
||||
/// pet status in the store
|
||||
@BuiltValueEnumConst(wireName: r'pending')
|
||||
static const PetStatusEnum pending = _$petStatusEnum_pending;
|
||||
/// pet status in the store
|
||||
@BuiltValueEnumConst(wireName: r'sold')
|
||||
static const PetStatusEnum sold = _$petStatusEnum_sold;
|
||||
/// pet status in the store
|
||||
@BuiltValueEnumConst(wireName: r'unknown_default_open_api', fallback: true)
|
||||
static const PetStatusEnum unknownDefaultOpenApi = _$petStatusEnum_unknownDefaultOpenApi;
|
||||
|
||||
static Serializer<PetStatusEnum> get serializer => _$petStatusEnumSerializer;
|
||||
|
||||
const PetStatusEnum._(String name): super(name);
|
||||
|
||||
static BuiltSet<PetStatusEnum> get values => _$petStatusEnumValues;
|
||||
static PetStatusEnum valueOf(String name) => _$petStatusEnumValueOf(name);
|
||||
}
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.7
|
||||
|
||||
// ignore_for_file: unused_import
|
||||
|
||||
import 'package:built_value/built_value.dart';
|
||||
import 'package:built_value/serializer.dart';
|
||||
|
||||
part 'tag.g.dart';
|
||||
|
||||
abstract class Tag implements Built<Tag, TagBuilder> {
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: r'id')
|
||||
int get id;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: r'name')
|
||||
String get name;
|
||||
|
||||
Tag._();
|
||||
|
||||
static void _initializeBuilder(TagBuilder b) => b;
|
||||
|
||||
factory Tag([void updates(TagBuilder b)]) = _$Tag;
|
||||
|
||||
@BuiltValueSerializer(custom: true)
|
||||
static Serializer<Tag> get serializer => _$TagSerializer();
|
||||
}
|
||||
|
||||
class _$TagSerializer implements StructuredSerializer<Tag> {
|
||||
|
||||
@override
|
||||
final Iterable<Type> types = const [Tag, _$Tag];
|
||||
@override
|
||||
final String wireName = r'Tag';
|
||||
|
||||
@override
|
||||
Iterable<Object> serialize(Serializers serializers, Tag object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = <Object>[];
|
||||
if (object.id != null) {
|
||||
result
|
||||
..add(r'id')
|
||||
..add(serializers.serialize(object.id,
|
||||
specifiedType: const FullType(int)));
|
||||
}
|
||||
if (object.name != null) {
|
||||
result
|
||||
..add(r'name')
|
||||
..add(serializers.serialize(object.name,
|
||||
specifiedType: const FullType(String)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
Tag deserialize(Serializers serializers, Iterable<Object> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = TagBuilder();
|
||||
|
||||
final iterator = serialized.iterator;
|
||||
while (iterator.moveNext()) {
|
||||
final key = iterator.current as String;
|
||||
iterator.moveNext();
|
||||
final dynamic value = iterator.current;
|
||||
switch (key) {
|
||||
case r'id':
|
||||
result.id = serializers.deserialize(value,
|
||||
specifiedType: const FullType(int)) as int;
|
||||
break;
|
||||
case r'name':
|
||||
result.name = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,168 +0,0 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.7
|
||||
|
||||
// ignore_for_file: unused_import
|
||||
|
||||
import 'package:built_value/built_value.dart';
|
||||
import 'package:built_value/serializer.dart';
|
||||
|
||||
part 'user.g.dart';
|
||||
|
||||
abstract class User implements Built<User, UserBuilder> {
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: r'id')
|
||||
int get id;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: r'username')
|
||||
String get username;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: r'firstName')
|
||||
String get firstName;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: r'lastName')
|
||||
String get lastName;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: r'email')
|
||||
String get email;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: r'password')
|
||||
String get password;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: r'phone')
|
||||
String get phone;
|
||||
|
||||
/// User Status
|
||||
@nullable
|
||||
@BuiltValueField(wireName: r'userStatus')
|
||||
int get userStatus;
|
||||
|
||||
User._();
|
||||
|
||||
static void _initializeBuilder(UserBuilder b) => b;
|
||||
|
||||
factory User([void updates(UserBuilder b)]) = _$User;
|
||||
|
||||
@BuiltValueSerializer(custom: true)
|
||||
static Serializer<User> get serializer => _$UserSerializer();
|
||||
}
|
||||
|
||||
class _$UserSerializer implements StructuredSerializer<User> {
|
||||
|
||||
@override
|
||||
final Iterable<Type> types = const [User, _$User];
|
||||
@override
|
||||
final String wireName = r'User';
|
||||
|
||||
@override
|
||||
Iterable<Object> serialize(Serializers serializers, User object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = <Object>[];
|
||||
if (object.id != null) {
|
||||
result
|
||||
..add(r'id')
|
||||
..add(serializers.serialize(object.id,
|
||||
specifiedType: const FullType(int)));
|
||||
}
|
||||
if (object.username != null) {
|
||||
result
|
||||
..add(r'username')
|
||||
..add(serializers.serialize(object.username,
|
||||
specifiedType: const FullType(String)));
|
||||
}
|
||||
if (object.firstName != null) {
|
||||
result
|
||||
..add(r'firstName')
|
||||
..add(serializers.serialize(object.firstName,
|
||||
specifiedType: const FullType(String)));
|
||||
}
|
||||
if (object.lastName != null) {
|
||||
result
|
||||
..add(r'lastName')
|
||||
..add(serializers.serialize(object.lastName,
|
||||
specifiedType: const FullType(String)));
|
||||
}
|
||||
if (object.email != null) {
|
||||
result
|
||||
..add(r'email')
|
||||
..add(serializers.serialize(object.email,
|
||||
specifiedType: const FullType(String)));
|
||||
}
|
||||
if (object.password != null) {
|
||||
result
|
||||
..add(r'password')
|
||||
..add(serializers.serialize(object.password,
|
||||
specifiedType: const FullType(String)));
|
||||
}
|
||||
if (object.phone != null) {
|
||||
result
|
||||
..add(r'phone')
|
||||
..add(serializers.serialize(object.phone,
|
||||
specifiedType: const FullType(String)));
|
||||
}
|
||||
if (object.userStatus != null) {
|
||||
result
|
||||
..add(r'userStatus')
|
||||
..add(serializers.serialize(object.userStatus,
|
||||
specifiedType: const FullType(int)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
User deserialize(Serializers serializers, Iterable<Object> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = UserBuilder();
|
||||
|
||||
final iterator = serialized.iterator;
|
||||
while (iterator.moveNext()) {
|
||||
final key = iterator.current as String;
|
||||
iterator.moveNext();
|
||||
final dynamic value = iterator.current;
|
||||
switch (key) {
|
||||
case r'id':
|
||||
result.id = serializers.deserialize(value,
|
||||
specifiedType: const FullType(int)) as int;
|
||||
break;
|
||||
case r'username':
|
||||
result.username = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String;
|
||||
break;
|
||||
case r'firstName':
|
||||
result.firstName = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String;
|
||||
break;
|
||||
case r'lastName':
|
||||
result.lastName = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String;
|
||||
break;
|
||||
case r'email':
|
||||
result.email = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String;
|
||||
break;
|
||||
case r'password':
|
||||
result.password = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String;
|
||||
break;
|
||||
case r'phone':
|
||||
result.phone = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String;
|
||||
break;
|
||||
case r'userStatus':
|
||||
result.userStatus = serializers.deserialize(value,
|
||||
specifiedType: const FullType(int)) as int;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.7
|
||||
|
||||
// ignore_for_file: unused_import
|
||||
|
||||
library serializers;
|
||||
|
||||
import 'package:built_value/iso_8601_date_time_serializer.dart';
|
||||
import 'package:built_value/serializer.dart';
|
||||
import 'package:built_collection/built_collection.dart';
|
||||
import 'package:built_value/json_object.dart';
|
||||
import 'package:built_value/standard_json_plugin.dart';
|
||||
|
||||
import 'package:openapi/model/api_response.dart';
|
||||
import 'package:openapi/model/category.dart';
|
||||
import 'package:openapi/model/order.dart';
|
||||
import 'package:openapi/model/pet.dart';
|
||||
import 'package:openapi/model/tag.dart';
|
||||
import 'package:openapi/model/user.dart';
|
||||
|
||||
part 'serializers.g.dart';
|
||||
|
||||
@SerializersFor(const [
|
||||
ApiResponse,
|
||||
Category,
|
||||
Order,
|
||||
Pet,
|
||||
Tag,
|
||||
User,
|
||||
])
|
||||
Serializers serializers = (_$serializers.toBuilder()
|
||||
..addBuilderFactory(
|
||||
const FullType(BuiltList, [FullType(Pet)]),
|
||||
() => ListBuilder<Pet>(),
|
||||
)
|
||||
..addBuilderFactory(
|
||||
const FullType(BuiltMap, [FullType(String), FullType(int)]),
|
||||
() => MapBuilder<String, int>(),
|
||||
)
|
||||
..addBuilderFactory(
|
||||
const FullType(BuiltList, [FullType(User)]),
|
||||
() => ListBuilder<User>(),
|
||||
)
|
||||
..add(Iso8601DateTimeSerializer()))
|
||||
.build();
|
||||
|
||||
Serializers standardSerializers =
|
||||
(serializers.toBuilder()..addPlugin(StandardJsonPlugin())).build();
|
||||
@@ -1,104 +0,0 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>DartDioPetstoreClientLibTests</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<name>DartDio Petstore Client Lib</name>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>export-dartfmt</id>
|
||||
<phase>pre-install-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>export</executable>
|
||||
<arguments>
|
||||
<argument>DART_FMT_PATH=/usr/local/bin/dartfmt</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>pub-get</id>
|
||||
<phase>pre-integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>pub</executable>
|
||||
<arguments>
|
||||
<argument>get</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>pub-run-build-runner</id>
|
||||
<phase>pre-integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>pub</executable>
|
||||
<arguments>
|
||||
<argument>run</argument>
|
||||
<argument>build_runner</argument>
|
||||
<argument>build</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>dartanalyzer</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>dartanalyzer</executable>
|
||||
<arguments>
|
||||
<argument>--fatal-infos</argument>
|
||||
<argument>--options</argument>
|
||||
<argument>analysis_options.yaml</argument>
|
||||
<argument>.</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>pub-test</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>pub</executable>
|
||||
<arguments>
|
||||
<argument>run</argument>
|
||||
<argument>test</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -1,17 +0,0 @@
|
||||
name: openapi
|
||||
version: 1.0.0
|
||||
description: OpenAPI API client
|
||||
homepage: homepage
|
||||
|
||||
environment:
|
||||
sdk: '>=2.7.0 <3.0.0'
|
||||
|
||||
dependencies:
|
||||
dio: '^3.0.9'
|
||||
built_value: '>=7.1.0 <8.0.0'
|
||||
built_collection: '>=4.3.2 <5.0.0'
|
||||
|
||||
dev_dependencies:
|
||||
built_value_generator: '>=7.1.0 <8.0.0'
|
||||
build_runner: any
|
||||
test: '>=1.3.0 <1.16.0'
|
||||
@@ -1,35 +0,0 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.7
|
||||
|
||||
// ignore_for_file: unused_import
|
||||
|
||||
import 'package:openapi/model/api_response.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
// tests for ApiResponse
|
||||
void main() {
|
||||
final instance = ApiResponseBuilder();
|
||||
// TODO add properties to the builder and call build()
|
||||
|
||||
group(ApiResponse, () {
|
||||
// int code
|
||||
test('to test the property `code`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// String type
|
||||
test('to test the property `type`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// String message
|
||||
test('to test the property `message`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.7
|
||||
|
||||
// ignore_for_file: unused_import
|
||||
|
||||
import 'package:openapi/model/category.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
// tests for Category
|
||||
void main() {
|
||||
final instance = CategoryBuilder();
|
||||
// TODO add properties to the builder and call build()
|
||||
|
||||
group(Category, () {
|
||||
// int id
|
||||
test('to test the property `id`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// String name
|
||||
test('to test the property `name`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.7
|
||||
|
||||
// ignore_for_file: unused_import
|
||||
|
||||
import 'package:openapi/model/order.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
// tests for Order
|
||||
void main() {
|
||||
final instance = OrderBuilder();
|
||||
// TODO add properties to the builder and call build()
|
||||
|
||||
group(Order, () {
|
||||
// int id
|
||||
test('to test the property `id`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// int petId
|
||||
test('to test the property `petId`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// int quantity
|
||||
test('to test the property `quantity`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// DateTime shipDate
|
||||
test('to test the property `shipDate`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// Order Status
|
||||
// String status
|
||||
test('to test the property `status`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// bool complete (default value: false)
|
||||
test('to test the property `complete`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.7
|
||||
|
||||
// ignore_for_file: unused_import
|
||||
|
||||
import 'package:openapi/api.dart';
|
||||
import 'package:openapi/api/pet_api.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
|
||||
/// tests for PetApi
|
||||
void main() {
|
||||
final instance = Openapi().getPetApi();
|
||||
|
||||
group(PetApi, () {
|
||||
// Add a new pet to the store
|
||||
//
|
||||
//Future<Pet> addPet(Pet pet) async
|
||||
test('test addPet', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// Deletes a pet
|
||||
//
|
||||
//Future deletePet(int petId, { String apiKey }) async
|
||||
test('test deletePet', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// Finds Pets by status
|
||||
//
|
||||
// Multiple status values can be provided with comma separated strings
|
||||
//
|
||||
//Future<BuiltList<Pet>> findPetsByStatus(BuiltList<String> status) async
|
||||
test('test findPetsByStatus', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// Finds Pets by tags
|
||||
//
|
||||
// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
//
|
||||
//Future<BuiltList<Pet>> findPetsByTags(BuiltList<String> tags) async
|
||||
test('test findPetsByTags', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// Find pet by ID
|
||||
//
|
||||
// Returns a single pet
|
||||
//
|
||||
//Future<Pet> getPetById(int petId) async
|
||||
test('test getPetById', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// Update an existing pet
|
||||
//
|
||||
//Future<Pet> updatePet(Pet pet) async
|
||||
test('test updatePet', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// Updates a pet in the store with form data
|
||||
//
|
||||
//Future updatePetWithForm(int petId, { String name, String status }) async
|
||||
test('test updatePetWithForm', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// uploads an image
|
||||
//
|
||||
//Future<ApiResponse> uploadFile(int petId, { String additionalMetadata, Uint8List file }) async
|
||||
test('test uploadFile', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.7
|
||||
|
||||
// ignore_for_file: unused_import
|
||||
|
||||
import 'package:openapi/model/pet.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
// tests for Pet
|
||||
void main() {
|
||||
final instance = PetBuilder();
|
||||
// TODO add properties to the builder and call build()
|
||||
|
||||
group(Pet, () {
|
||||
// int id
|
||||
test('to test the property `id`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// Category category
|
||||
test('to test the property `category`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// String name
|
||||
test('to test the property `name`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// BuiltList<String> photoUrls
|
||||
test('to test the property `photoUrls`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// BuiltList<Tag> tags
|
||||
test('to test the property `tags`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// pet status in the store
|
||||
// String status
|
||||
test('to test the property `status`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.7
|
||||
|
||||
// ignore_for_file: unused_import
|
||||
|
||||
import 'package:openapi/api.dart';
|
||||
import 'package:openapi/api/store_api.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
|
||||
/// tests for StoreApi
|
||||
void main() {
|
||||
final instance = Openapi().getStoreApi();
|
||||
|
||||
group(StoreApi, () {
|
||||
// Delete purchase order by ID
|
||||
//
|
||||
// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
//
|
||||
//Future deleteOrder(String orderId) async
|
||||
test('test deleteOrder', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// Returns pet inventories by status
|
||||
//
|
||||
// Returns a map of status codes to quantities
|
||||
//
|
||||
//Future<BuiltMap<String, int>> getInventory() async
|
||||
test('test getInventory', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// Find purchase order by ID
|
||||
//
|
||||
// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
//
|
||||
//Future<Order> getOrderById(int orderId) async
|
||||
test('test getOrderById', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// Place an order for a pet
|
||||
//
|
||||
//Future<Order> placeOrder(Order order) async
|
||||
test('test placeOrder', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.7
|
||||
|
||||
// ignore_for_file: unused_import
|
||||
|
||||
import 'package:openapi/model/tag.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
// tests for Tag
|
||||
void main() {
|
||||
final instance = TagBuilder();
|
||||
// TODO add properties to the builder and call build()
|
||||
|
||||
group(Tag, () {
|
||||
// int id
|
||||
test('to test the property `id`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// String name
|
||||
test('to test the property `name`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.7
|
||||
|
||||
// ignore_for_file: unused_import
|
||||
|
||||
import 'package:openapi/api.dart';
|
||||
import 'package:openapi/api/user_api.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
|
||||
/// tests for UserApi
|
||||
void main() {
|
||||
final instance = Openapi().getUserApi();
|
||||
|
||||
group(UserApi, () {
|
||||
// Create user
|
||||
//
|
||||
// This can only be done by the logged in user.
|
||||
//
|
||||
//Future createUser(User user) async
|
||||
test('test createUser', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// Creates list of users with given input array
|
||||
//
|
||||
//Future createUsersWithArrayInput(BuiltList<User> user) async
|
||||
test('test createUsersWithArrayInput', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// Creates list of users with given input array
|
||||
//
|
||||
//Future createUsersWithListInput(BuiltList<User> user) async
|
||||
test('test createUsersWithListInput', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// Delete user
|
||||
//
|
||||
// This can only be done by the logged in user.
|
||||
//
|
||||
//Future deleteUser(String username) async
|
||||
test('test deleteUser', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// Get user by user name
|
||||
//
|
||||
//Future<User> getUserByName(String username) async
|
||||
test('test getUserByName', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// Logs user into the system
|
||||
//
|
||||
//Future<String> loginUser(String username, String password) async
|
||||
test('test loginUser', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// Logs out current logged in user session
|
||||
//
|
||||
//Future logoutUser() async
|
||||
test('test logoutUser', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// Updated user
|
||||
//
|
||||
// This can only be done by the logged in user.
|
||||
//
|
||||
//Future updateUser(String username, User user) async
|
||||
test('test updateUser', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.7
|
||||
|
||||
// ignore_for_file: unused_import
|
||||
|
||||
import 'package:openapi/model/user.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
// tests for User
|
||||
void main() {
|
||||
final instance = UserBuilder();
|
||||
// TODO add properties to the builder and call build()
|
||||
|
||||
group(User, () {
|
||||
// int id
|
||||
test('to test the property `id`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// String username
|
||||
test('to test the property `username`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// String firstName
|
||||
test('to test the property `firstName`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// String lastName
|
||||
test('to test the property `lastName`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// String email
|
||||
test('to test the property `email`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// String password
|
||||
test('to test the property `password`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// String phone
|
||||
test('to test the property `phone`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
// User Status
|
||||
// int userStatus
|
||||
test('to test the property `userStatus`', () async {
|
||||
// TODO
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
# See https://dart.dev/guides/libraries/private-files
|
||||
|
||||
# Files and directories created by pub
|
||||
.dart_tool/
|
||||
.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
|
||||
|
||||
# Don’t commit files and directories created by other development environments.
|
||||
# For example, if your development environment creates any of the following files,
|
||||
# consider putting them in a global ignore file:
|
||||
|
||||
# IntelliJ
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# Mac
|
||||
.DS_Store
|
||||
@@ -1,23 +0,0 @@
|
||||
# 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
|
||||
@@ -1,119 +0,0 @@
|
||||
.gitignore
|
||||
README.md
|
||||
analysis_options.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/DeprecatedObject.md
|
||||
doc/Dog.md
|
||||
doc/DogAllOf.md
|
||||
doc/EnumArrays.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/ModelEnumClass.md
|
||||
doc/ModelFile.md
|
||||
doc/ModelList.md
|
||||
doc/ModelReturn.md
|
||||
doc/Name.md
|
||||
doc/NullableClass.md
|
||||
doc/NumberOnly.md
|
||||
doc/ObjectWithDeprecatedFields.md
|
||||
doc/Order.md
|
||||
doc/OuterComposite.md
|
||||
doc/OuterEnum.md
|
||||
doc/OuterEnumDefaultValue.md
|
||||
doc/OuterEnumInteger.md
|
||||
doc/OuterEnumIntegerDefaultValue.md
|
||||
doc/OuterObjectWithEnumProperty.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
|
||||
doc/UserType.md
|
||||
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_util.dart
|
||||
lib/auth/api_key_auth.dart
|
||||
lib/auth/auth.dart
|
||||
lib/auth/basic_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/deprecated_object.dart
|
||||
lib/model/dog.dart
|
||||
lib/model/dog_all_of.dart
|
||||
lib/model/enum_arrays.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_enum_class.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/object_with_deprecated_fields.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/outer_object_with_enum_property.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
|
||||
lib/model/user_type.dart
|
||||
lib/serializers.dart
|
||||
pubspec.yaml
|
||||
@@ -1 +0,0 @@
|
||||
6.0.0-SNAPSHOT
|
||||
@@ -1,195 +0,0 @@
|
||||
# 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.DartDioClientCodegen
|
||||
|
||||
## Requirements
|
||||
|
||||
Dart 2.7.0 or later OR Flutter 1.12 or later
|
||||
|
||||
## Installation & Usage
|
||||
|
||||
### Github
|
||||
If this Dart package is published to Github, please include the following in pubspec.yaml
|
||||
```
|
||||
name: openapi
|
||||
version: 1.0.0
|
||||
description: OpenAPI API client
|
||||
dependencies:
|
||||
openapi:
|
||||
git: https://github.com/GIT_USER_ID/GIT_REPO_ID.git
|
||||
version: 'any'
|
||||
```
|
||||
|
||||
### Local
|
||||
To use the package in your local drive, please include the following in pubspec.yaml
|
||||
```
|
||||
dependencies:
|
||||
openapi:
|
||||
path: /path/to/openapi
|
||||
```
|
||||
|
||||
## Getting Started
|
||||
|
||||
Please follow the [installation procedure](#installation--usage) and then run the following:
|
||||
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
|
||||
final api = AnotherFakeApi();
|
||||
final modelClient = ModelClient(); // ModelClient | client model
|
||||
|
||||
try {
|
||||
final response = await api.call123testSpecialTags(modelClient);
|
||||
print(response);
|
||||
} 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* | [**fakePropertyEnumIntegerSerialize**](doc/FakeApi.md#fakepropertyenumintegerserialize) | **POST** /fake/property/enum-int |
|
||||
*FakeApi* | [**testBodyWithBinary**](doc/FakeApi.md#testbodywithbinary) | **PUT** /fake/body-with-binary |
|
||||
*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-parameters |
|
||||
*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)
|
||||
- [DeprecatedObject](doc/DeprecatedObject.md)
|
||||
- [Dog](doc/Dog.md)
|
||||
- [DogAllOf](doc/DogAllOf.md)
|
||||
- [EnumArrays](doc/EnumArrays.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)
|
||||
- [ModelEnumClass](doc/ModelEnumClass.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)
|
||||
- [ObjectWithDeprecatedFields](doc/ObjectWithDeprecatedFields.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)
|
||||
- [OuterObjectWithEnumProperty](doc/OuterObjectWithEnumProperty.md)
|
||||
- [Pet](doc/Pet.md)
|
||||
- [ReadOnlyFirst](doc/ReadOnlyFirst.md)
|
||||
- [SpecialModelName](doc/SpecialModelName.md)
|
||||
- [Tag](doc/Tag.md)
|
||||
- [User](doc/User.md)
|
||||
- [UserType](doc/UserType.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 basic authentication
|
||||
|
||||
## http_basic_test
|
||||
|
||||
- **Type**: HTTP basic authentication
|
||||
|
||||
## http_signature_test
|
||||
|
||||
- **Type**: HTTP basic authentication
|
||||
|
||||
## 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
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
analyzer:
|
||||
language:
|
||||
strict-inference: true
|
||||
strict-raw-types: true
|
||||
strong-mode:
|
||||
implicit-dynamic: false
|
||||
implicit-casts: false
|
||||
exclude:
|
||||
- test/*.dart
|
||||
@@ -1,16 +0,0 @@
|
||||
# openapi.model.AdditionalPropertiesClass
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**mapProperty** | **BuiltMap<String, String>** | | [optional]
|
||||
**mapOfMapProperty** | [**BuiltMap<String, BuiltMap<String, String>>**](BuiltMap.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)
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
# 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)
|
||||
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
# 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';
|
||||
|
||||
var api_instance = new AnotherFakeApi();
|
||||
var modelClient = new ModelClient(); // ModelClient | client model
|
||||
|
||||
try {
|
||||
var 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)
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
# 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)
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
# openapi.model.ArrayOfArrayOfNumberOnly
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**arrayArrayNumber** | [**BuiltList<BuiltList<num>>**](BuiltList.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)
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
# openapi.model.ArrayOfNumberOnly
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**arrayNumber** | **BuiltList<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)
|
||||
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
# openapi.model.ArrayTest
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**arrayOfString** | **BuiltList<String>** | | [optional]
|
||||
**arrayArrayOfInteger** | [**BuiltList<BuiltList<int>>**](BuiltList.md) | | [optional]
|
||||
**arrayArrayOfModel** | [**BuiltList<BuiltList<ReadOnlyFirst>>**](BuiltList.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)
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
# 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)
|
||||
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
# 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)
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
# 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)
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
# 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)
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
# 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)
|
||||
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
# 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';
|
||||
|
||||
var api_instance = new DefaultApi();
|
||||
|
||||
try {
|
||||
var 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)
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
# openapi.model.DeprecatedObject
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:openapi/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**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)
|
||||
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
# 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)
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
# 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)
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user