[Dart] Fix enum generation (#6729)

* [Dart] Fix enum generation

* Update generated Order file

* Re-add constructor

* Generate dart2 files

* Dart - nicer enum formatting

* Dart - generate enum name as className+enumName

* Dart - dont initialize vars to null by default

Fixes #3633

* Dart - Generate inlined enums and deserialize them

* Merge branch 'master' of github.com:agilob/openapi-generator into 6727

* Dart - Fix using default value

* Fix typo

* Regenerate add dart files

* dart Revert override for dart dio and jaguar

* Fix dart model tests

* Fix dart1 generated template

* Use {{{datatypeWithEnum}}}

* Dart - throw when enum not known

* Fix generating enum with datatype from list
This commit is contained in:
agilob 2020-07-23 04:26:25 +01:00 committed by GitHub
parent d6549f78b4
commit 90d8c32906
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
62 changed files with 597 additions and 382 deletions

View File

@ -1768,7 +1768,7 @@ public class DefaultCodegen implements CodegenConfig {
if (encoding != null) {
codegenParameter.contentType = encoding.getContentType();
} else {
LOGGER.debug("encoding not specified for " + codegenParameter.baseName);
LOGGER.debug("encoding not specified for {}", codegenParameter.baseName);
}
}
}
@ -1790,6 +1790,9 @@ public class DefaultCodegen implements CodegenConfig {
/**
* Return the default value of the property
*
* Return null if you do NOT want a default value.
* Any non-null value will cause {{#defaultValue} check to pass.
*
* @param schema Property schema
* @return string presentation of the default value of the property
*/
@ -1810,7 +1813,7 @@ public class DefaultCodegen implements CodegenConfig {
*/
@SuppressWarnings("squid:S3923")
private String getPropertyDefaultValue(Schema schema) {
/**
/*
* Although all branches return null, this is left intentionally as examples for new contributors
*/
if (ModelUtils.isBooleanSchema(schema)) {

View File

@ -17,6 +17,7 @@
package org.openapitools.codegen.languages;
import com.google.common.collect.Sets;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
@ -30,9 +31,8 @@ import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.camelize;
@ -50,6 +50,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
public static final String PUB_HOMEPAGE = "pubHomepage";
public static final String USE_ENUM_EXTENSION = "useEnumExtension";
public static final String SUPPORT_DART2 = "supportDart2";
protected boolean browserClient = true;
protected String pubName = "openapi";
protected String pubVersion = "1.0.0";
@ -106,9 +107,11 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
modelTestTemplateFiles.put("model_test.mustache", ".dart");
apiTestTemplateFiles.put("api_test.mustache", ".dart");
List<String> reservedWordsList = new ArrayList<String>();
List<String> reservedWordsList = new ArrayList<>();
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(DartClientCodegen.class.getResourceAsStream("/dart/dart-keywords.txt"), Charset.forName("UTF-8")));
BufferedReader reader = new BufferedReader(
new InputStreamReader(DartClientCodegen.class.getResourceAsStream("/dart/dart-keywords.txt"),
StandardCharsets.UTF_8));
while (reader.ready()) {
reservedWordsList.add(reader.readLine());
}
@ -118,18 +121,17 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
}
setReservedWordsLowerCase(reservedWordsList);
languageSpecificPrimitives = new HashSet<String>(
Arrays.asList(
languageSpecificPrimitives = Sets.newHashSet(
"String",
"bool",
"int",
"num",
"double")
"double"
);
instantiationTypes.put("array", "List");
instantiationTypes.put("map", "Map");
typeMapping = new HashMap<String, String>();
typeMapping = new HashMap<>();
typeMapping.put("Array", "List");
typeMapping.put("array", "List");
typeMapping.put("List", "List");
@ -329,7 +331,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
// replace - with _ e.g. created-at => created_at
name = name.replaceAll("-", "_");
// if it's all uppper case, do nothing
// if it's all upper case, do nothing
if (name.matches("^[A-Z_]*$")) {
return name;
}
@ -403,9 +405,9 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public String toDefaultValue(Schema schema) {
if (ModelUtils.isMapSchema(schema)) {
return "{}";
return "const {}";
} else if (ModelUtils.isArraySchema(schema)) {
return "[]";
return "const []";
}
if (schema.getDefault() != null) {
@ -414,7 +416,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
}
return schema.getDefault().toString();
} else {
return "null";
return null;
}
}
@ -435,7 +437,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public String getSchemaType(Schema p) {
String openAPIType = super.getSchemaType(p);
String type = null;
String type;
if (typeMapping.containsKey(openAPIType)) {
type = typeMapping.get(openAPIType);
if (languageSpecificPrimitives.contains(type)) {
@ -495,19 +497,16 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
return false;
}
Object extension = cm.vendorExtensions.get("x-enum-values");
List<Map<String, Object>> values =
(List<Map<String, Object>>) extension;
List<Map<String, String>> enumVars =
new ArrayList<Map<String, String>>();
List<Map<String, Object>> values = (List<Map<String, Object>>) extension;
List<Map<String, String>> enumVars = new ArrayList<>();
for (Map<String, Object> value : values) {
Map<String, String> enumVar = new HashMap<String, String>();
Map<String, String> enumVar = new HashMap<>();
String name = camelize((String) value.get("identifier"), true);
if (isReservedWord(name)) {
name = escapeReservedWord(name);
}
enumVar.put("name", name);
enumVar.put("value", toEnumValue(
value.get("numericValue").toString(), cm.dataType));
enumVar.put("value", toEnumValue(value.get("numericValue").toString(), cm.dataType));
if (value.containsKey("description")) {
enumVar.put("description", value.get("description").toString());
}
@ -611,13 +610,12 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
}
// only procees the following type (or we can simply rely on the file extension to check if it's a Dart file)
Set<String> supportedFileType = new HashSet<String>(
Arrays.asList(
Set<String> supportedFileType = Sets.newHashSet(
"supporting-mustache",
"model-test",
"model",
"api-test",
"api"));
"api");
if (!supportedFileType.contains(fileType)) {
return;
}
@ -632,7 +630,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
if (exitValue != 0) {
LOGGER.error("Error running the command ({}). Exit code: {}", command, exitValue);
} else {
LOGGER.info("Successfully executed: " + command);
LOGGER.info("Successfully executed: {}", command);
}
} catch (Exception e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());

View File

@ -130,13 +130,21 @@ public class DartDioClientCodegen extends DartClientCodegen {
}
@Override
public String toDefaultValue(Schema p) {
if (ModelUtils.isMapSchema(p)) {
public String toDefaultValue(Schema schema) {
if (ModelUtils.isMapSchema(schema)) {
return "const {}";
} else if (ModelUtils.isArraySchema(p)) {
} else if (ModelUtils.isArraySchema(schema)) {
return "const []";
}
return super.toDefaultValue(p);
if (schema.getDefault() != null) {
if (ModelUtils.isStringSchema(schema)) {
return "\"" + schema.getDefault().toString().replaceAll("\"", "\\\"") + "\"";
}
return schema.getDefault().toString();
} else {
return "null";
}
}
@Override

View File

@ -132,13 +132,21 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
}
@Override
public String toDefaultValue(Schema p) {
if (ModelUtils.isMapSchema(p)) {
public String toDefaultValue(Schema schema) {
if (ModelUtils.isMapSchema(schema)) {
return "const {}";
} else if (ModelUtils.isArraySchema(p)) {
} else if (ModelUtils.isArraySchema(schema)) {
return "const []";
}
return super.toDefaultValue(p);
if (schema.getDefault() != null) {
if (ModelUtils.isStringSchema(schema)) {
return "\"" + schema.getDefault().toString().replaceAll("\"", "\\\"") + "\"";
}
return schema.getDefault().toString();
} else {
return "null";
}
}
@Override

View File

@ -1,7 +1,7 @@
class {{classname}} {
{{#vars}}
{{#description}}/* {{{description}}} */{{/description}}
{{{dataType}}} {{name}} = {{{defaultValue}}};
{{^defaultValue}}{{{dataType}}} {{name}} = null;{{/defaultValue}}{{#defaultValue}}{{{dataType}}} {{name}} = {{defaultValue}};{{/defaultValue}}
{{#allowableValues}}
{{#min}} // range from {{min}} to {{max}}{{/min}}//{{^min}}enum {{name}}Enum { {{#values}} {{.}}, {{/values}} };{{/min}}{
{{/allowableValues}}

View File

@ -1,15 +1,19 @@
class {{classname}} {
{{#vars}}
{{#description}}/* {{{description}}} */{{/description}}
{{{dataType}}} {{name}} = {{{defaultValue}}};
{{#description}}/// {{{description}}}{{/description}}
{{^isEnum}}
{{^defaultValue}}{{{dataType}}} {{name}};{{/defaultValue}}{{#defaultValue}}{{{dataType}}} {{name}} = {{defaultValue}};{{/defaultValue}}
{{/isEnum}}
{{#isEnum}}
{{#allowableValues}}
{{#min}} // range from {{min}} to {{max}}{{/min}}//{{^min}}enum {{name}}Enum { {{#values}} {{.}}, {{/values}} };{{/min}}{
{{#min}} // range from {{min}} to {{max}}{{/min}}{{classname}}{{{enumName}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}}{{/required}};
{{/allowableValues}}
{{/isEnum}}
{{/vars}}
{{classname}}({
{{#vars}}
{{#required}}@required this.{{name}},{{/required}}{{^required}}this.{{name}},{{/required}}
{{#required}}@required this.{{name}}{{/required}}{{^required}}this.{{name}}{{#defaultValue}} = {{defaultValue}}{{/defaultValue}}{{/required}},
{{/vars}}
});
@ -78,7 +82,12 @@ class {{classname}} {
json['{{baseName}}'].toDouble();
{{/isDouble}}
{{^isDouble}}
{{^isEnum}}
{{name}} = json['{{baseName}}'];
{{/isEnum}}
{{#isEnum}}
{{name}} = {{classname}}{{{enumName}}}.fromJson(json['{{baseName}}']);
{{/isEnum}}
{{/isDouble}}
{{/isMapContainer}}
{{/isListContainer}}
@ -102,7 +111,12 @@ class {{classname}} {
{{/isDate}}
{{^isDateTime}}
{{^isDate}}
{{^isEnum}}
json['{{baseName}}'] = {{name}};
{{/isEnum}}
{{#isEnum}}
json['{{baseName}}'] = {{name}}.value;
{{/isEnum}}
{{/isDate}}
{{/isDateTime}}
{{/vars}}
@ -114,7 +128,7 @@ class {{classname}} {
}
static Map<String, {{classname}}> mapFromJson(Map<String, dynamic> json) {
var map = Map<String, {{classname}}>();
final map = Map<String, {{classname}}>();
if (json != null && json.isNotEmpty) {
json.forEach((String key, dynamic value) => map[key] = {{classname}}.fromJson(value));
}
@ -123,7 +137,7 @@ class {{classname}} {
// maps a json object with a list of {{classname}}-objects as value to a dart map
static Map<String, List<{{classname}}>> mapListFromJson(Map<String, dynamic> json) {
var map = Map<String, List<{{classname}}>>();
final map = Map<String, List<{{classname}}>>();
if (json != null && json.isNotEmpty) {
json.forEach((String key, dynamic value) {
map[key] = {{classname}}.listFromJson(value);
@ -132,3 +146,8 @@ class {{classname}} {
return map;
}
}
{{#vars}}
{{#isEnum}}
{{>enum_inline}}
{{/isEnum}}
{{/vars}}

View File

@ -9,20 +9,27 @@ class {{classname}} {
{{#description}}
/// {{description}}
{{/description}}
static const {{classname}} {{{name}}} = const {{classname}}._internal({{{value}}});
static const {{classname}} {{{name}}} = {{classname}}._internal({{value}});
{{/enumVars}}
{{/allowableValues}}
{{dataType}} toJson () {
return this.value;
return value;
}
@override
String toString () {
return value;
}
static {{classname}} fromJson({{dataType}} value) {
return new {{classname}}TypeTransformer().decode(value);
return {{classname}}TypeTransformer().decode(value);
}
static List<{{classname}}> listFromJson(List<dynamic> json) {
return json == null ? new List<{{classname}}>() : json.map((value) => {{classname}}.fromJson(value)).toList();
return json == null
? List<{{classname}}>()
: json.map((value) => {{classname}}.fromJson(value)).toList();
}
}

View File

@ -0,0 +1,52 @@
class {{classname}}{{enumName}} {
/// The underlying value of this enum member.
final {{{dataType}}} value;
const {{classname}}{{enumName}}._internal(this.value);
{{#allowableValues}}
{{#enumVars}}
{{#description}}
/// {{description}}
{{/description}}
static const {{classname}}{{enumName}} {{name}} = {{classname}}{{enumName}}._internal({{{value}}});
{{/enumVars}}
{{/allowableValues}}
{{{dataType}}} toJson () {
return value;
}
@override
String toString () {
return value;
}
static {{classname}}{{enumName}} fromJson({{{dataType}}} value) {
return {{classname}}{{enumName}}TypeTransformer().decode(value);
}
static List<{{classname}}{{enumName}}> listFromJson(List<dynamic> json) {
return json == null
? List<{{classname}}{{enumName}}>()
: json.map((value) => {{classname}}{{enumName}}.fromJson(value)).toList();
}
}
class {{classname}}{{enumName}}TypeTransformer {
dynamic encode({{classname}}{{enumName}} data) {
return data.value;
}
{{classname}}{{enumName}} decode(dynamic data) {
switch (data) {
{{#allowableValues}}
{{#enumVars}}
case {{{value}}}: return {{classname}}{{enumName}}.{{{name}}};
{{/enumVars}}
{{/allowableValues}}
default: return null;
}
}
}

View File

@ -36,6 +36,7 @@ public class DartModelTest {
.addProperties("id", new IntegerSchema())
.addProperties("name", new StringSchema())
.addProperties("createdAt", new DateTimeSchema())
.addProperties("defaultItem", new IntegerSchema()._default(1))
.addRequiredItem("id")
.addRequiredItem("name");
final DefaultCodegen codegen = new DartClientCodegen();
@ -46,7 +47,7 @@ public class DartModelTest {
Assert.assertEquals(cm.name, "sample");
Assert.assertEquals(cm.classname, "Sample");
Assert.assertEquals(cm.description, "a sample model");
Assert.assertEquals(cm.vars.size(), 3);
Assert.assertEquals(cm.vars.size(), 4);
// {{imports}} is not used in template
//Assert.assertEquals(cm.imports.size(), 1);
@ -54,7 +55,7 @@ public class DartModelTest {
Assert.assertEquals(property1.baseName, "id");
Assert.assertEquals(property1.dataType, "int");
Assert.assertEquals(property1.name, "id");
Assert.assertEquals(property1.defaultValue, "null");
Assert.assertNull(property1.defaultValue);
Assert.assertEquals(property1.baseType, "int");
Assert.assertTrue(property1.hasMore);
Assert.assertTrue(property1.required);
@ -65,7 +66,7 @@ public class DartModelTest {
Assert.assertEquals(property2.baseName, "name");
Assert.assertEquals(property2.dataType, "String");
Assert.assertEquals(property2.name, "name");
Assert.assertEquals(property2.defaultValue, "null");
Assert.assertNull(property2.defaultValue);
Assert.assertEquals(property2.baseType, "String");
Assert.assertTrue(property2.hasMore);
Assert.assertTrue(property2.required);
@ -77,11 +78,20 @@ public class DartModelTest {
Assert.assertEquals(property3.complexType, "DateTime");
Assert.assertEquals(property3.dataType, "DateTime");
Assert.assertEquals(property3.name, "createdAt");
Assert.assertEquals(property3.defaultValue, "null");
Assert.assertNull(property3.defaultValue);
Assert.assertEquals(property3.baseType, "DateTime");
Assert.assertFalse(property3.hasMore);
Assert.assertTrue(property3.hasMore);
Assert.assertFalse(property3.required);
Assert.assertFalse(property3.isContainer);
final CodegenProperty property4 = cm.vars.get(3);
Assert.assertEquals(property4.baseName, "defaultItem");
Assert.assertEquals(property4.dataType, "int");
Assert.assertEquals(property4.defaultValue, "1");
Assert.assertEquals(property4.baseType, "int");
Assert.assertFalse(property4.hasMore);
Assert.assertFalse(property4.required);
Assert.assertFalse(property4.isContainer);
}
@Test(description = "convert a model with list property")
@ -89,9 +99,9 @@ public class DartModelTest {
final Schema model = new Schema()
.description("a sample model")
.addProperties("id", new IntegerSchema())
.addProperties("urls", new ArraySchema()
.items(new StringSchema()))
.addProperties("urls", new ArraySchema().items(new StringSchema()))
.addRequiredItem("id");
final DefaultCodegen codegen = new DartClientCodegen();
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
codegen.setOpenAPI(openAPI);
@ -106,7 +116,7 @@ public class DartModelTest {
Assert.assertEquals(property1.baseName, "id");
Assert.assertEquals(property1.dataType, "int");
Assert.assertEquals(property1.name, "id");
Assert.assertEquals(property1.defaultValue, "null");
Assert.assertNull(property1.defaultValue);
Assert.assertEquals(property1.baseType, "int");
Assert.assertTrue(property1.hasMore);
Assert.assertTrue(property1.required);

View File

@ -8,9 +8,9 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**code** | **int** | | [optional] [default to null]
**type** | **String** | | [optional] [default to null]
**message** | **String** | | [optional] [default to null]
**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)

View File

@ -8,8 +8,8 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **int** | | [optional] [default to null]
**name** | **String** | | [optional] [default to null]
**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)

View File

@ -8,8 +8,8 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **String** | Updated name of the pet | [optional] [default to null]
**status** | **String** | Updated status of the pet | [optional] [default to null]
**name** | **String** | Updated name of the pet | [optional]
**status** | **String** | Updated status 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)

View File

@ -8,8 +8,8 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**additionalMetadata** | **String** | Additional data to pass to server | [optional] [default to null]
**file** | [**MultipartFile**](File.md) | file to upload | [optional] [default to null]
**additionalMetadata** | **String** | Additional data to pass to server | [optional]
**file** | [**MultipartFile**](File.md) | file to upload | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -8,11 +8,11 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **int** | | [optional] [default to null]
**petId** | **int** | | [optional] [default to null]
**quantity** | **int** | | [optional] [default to null]
**shipDate** | [**DateTime**](DateTime.md) | | [optional] [default to null]
**status** | **String** | Order Status | [optional] [default to null]
**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)

View File

@ -8,12 +8,12 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **int** | | [optional] [default to null]
**category** | [**Category**](Category.md) | | [optional] [default to null]
**name** | **String** | | [default to null]
**photoUrls** | **List&lt;String&gt;** | | [default to []]
**tags** | [**List&lt;Tag&gt;**](Tag.md) | | [optional] [default to []]
**status** | **String** | pet status in the store | [optional] [default to null]
**id** | **int** | | [optional]
**category** | [**Category**](Category.md) | | [optional]
**name** | **String** | |
**photoUrls** | **List&lt;String&gt;** | | [default to const []]
**tags** | [**List&lt;Tag&gt;**](Tag.md) | | [optional] [default to const []]
**status** | **String** | pet status in the store | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -88,8 +88,8 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **int**| Pet id to delete | [default to null]
**apiKey** | **String**| | [optional] [default to null]
**petId** | **int**| Pet id to delete |
**apiKey** | **String**| | [optional]
### Return type
@ -134,7 +134,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**status** | [**List&lt;String&gt;**](String.md)| Status values that need to be considered for filter | [default to []]
**status** | [**List&lt;String&gt;**](String.md)| Status values that need to be considered for filter | [default to const []]
### Return type
@ -179,7 +179,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**tags** | [**List&lt;String&gt;**](String.md)| Tags to filter by | [default to []]
**tags** | [**List&lt;String&gt;**](String.md)| Tags to filter by | [default to const []]
### Return type
@ -226,7 +226,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **int**| ID of pet to return | [default to null]
**petId** | **int**| ID of pet to return |
### Return type
@ -313,9 +313,9 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **int**| ID of pet that needs to be updated | [default to null]
**name** | **String**| Updated name of the pet | [optional] [default to null]
**status** | **String**| Updated status of the pet | [optional] [default to null]
**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
@ -360,9 +360,9 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **int**| ID of pet to update | [default to null]
**additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null]
**file** | **MultipartFile**| file to upload | [optional] [default to null]
**petId** | **int**| ID of pet to update |
**additionalMetadata** | **String**| Additional data to pass to server | [optional]
**file** | **MultipartFile**| file to upload | [optional]
### Return type

View File

@ -40,7 +40,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**orderId** | **String**| ID of the order that needs to be deleted | [default to null]
**orderId** | **String**| ID of the order that needs to be deleted |
### Return type
@ -126,7 +126,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**orderId** | **int**| ID of pet that needs to be fetched | [default to null]
**orderId** | **int**| ID of pet that needs to be fetched |
### Return type

View File

@ -8,8 +8,8 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **int** | | [optional] [default to null]
**name** | **String** | | [optional] [default to null]
**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)

View File

@ -8,14 +8,14 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **int** | | [optional] [default to null]
**username** | **String** | | [optional] [default to null]
**firstName** | **String** | | [optional] [default to null]
**lastName** | **String** | | [optional] [default to null]
**email** | **String** | | [optional] [default to null]
**password** | **String** | | [optional] [default to null]
**phone** | **String** | | [optional] [default to null]
**userStatus** | **int** | User Status | [optional] [default to null]
**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)

View File

@ -182,7 +182,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The name that needs to be deleted | [default to null]
**username** | **String**| The name that needs to be deleted |
### Return type
@ -223,7 +223,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The name that needs to be fetched. Use user1 for testing. | [default to null]
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
### Return type
@ -265,8 +265,8 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The user name for login | [default to null]
**password** | **String**| The password for login in clear text | [default to null]
**username** | **String**| The user name for login |
**password** | **String**| The password for login in clear text |
### Return type
@ -353,7 +353,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| name that need to be deleted | [default to null]
**username** | **String**| name that need to be deleted |
**user** | [**User**](User.md)| Updated user object |
### Return type

View File

@ -8,9 +8,9 @@ class Pet {
String name = null;
List<String> photoUrls = [];
List<String> photoUrls = const [];
List<Tag> tags = [];
List<Tag> tags = const [];
/* pet status in the store */
String status = null;
//enum statusEnum { available, pending, sold, };{

View File

@ -8,9 +8,9 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**code** | **int** | | [optional] [default to null]
**type** | **String** | | [optional] [default to null]
**message** | **String** | | [optional] [default to null]
**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)

View File

@ -8,8 +8,8 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **int** | | [optional] [default to null]
**name** | **String** | | [optional] [default to null]
**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)

View File

@ -8,11 +8,11 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **int** | | [optional] [default to null]
**petId** | **int** | | [optional] [default to null]
**quantity** | **int** | | [optional] [default to null]
**shipDate** | [**DateTime**](DateTime.md) | | [optional] [default to null]
**status** | **String** | Order Status | [optional] [default to null]
**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)

View File

@ -8,12 +8,12 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **int** | | [optional] [default to null]
**category** | [**Category**](Category.md) | | [optional] [default to null]
**name** | **String** | | [default to null]
**photoUrls** | **List&lt;String&gt;** | | [default to []]
**tags** | [**List&lt;Tag&gt;**](Tag.md) | | [optional] [default to []]
**status** | **String** | pet status in the store | [optional] [default to null]
**id** | **int** | | [optional]
**category** | [**Category**](Category.md) | | [optional]
**name** | **String** | |
**photoUrls** | **List&lt;String&gt;** | | [default to const []]
**tags** | [**List&lt;Tag&gt;**](Tag.md) | | [optional] [default to const []]
**status** | **String** | pet status in the store | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -87,8 +87,8 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **int**| Pet id to delete | [default to null]
**apiKey** | **String**| | [optional] [default to null]
**petId** | **int**| Pet id to delete |
**apiKey** | **String**| | [optional]
### Return type
@ -133,7 +133,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**status** | [**List&lt;String&gt;**](String.md)| Status values that need to be considered for filter | [default to []]
**status** | [**List&lt;String&gt;**](String.md)| Status values that need to be considered for filter | [default to const []]
### Return type
@ -178,7 +178,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**tags** | [**List&lt;String&gt;**](String.md)| Tags to filter by | [default to []]
**tags** | [**List&lt;String&gt;**](String.md)| Tags to filter by | [default to const []]
### Return type
@ -225,7 +225,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **int**| ID of pet to return | [default to null]
**petId** | **int**| ID of pet to return |
### Return type
@ -311,9 +311,9 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **int**| ID of pet that needs to be updated | [default to null]
**name** | **String**| Updated name of the pet | [optional] [default to null]
**status** | **String**| Updated status of the pet | [optional] [default to null]
**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
@ -358,9 +358,9 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **int**| ID of pet to update | [default to null]
**additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null]
**file** | **MultipartFile**| file to upload | [optional] [default to null]
**petId** | **int**| ID of pet to update |
**additionalMetadata** | **String**| Additional data to pass to server | [optional]
**file** | **MultipartFile**| file to upload | [optional]
### Return type

View File

@ -40,7 +40,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**orderId** | **String**| ID of the order that needs to be deleted | [default to null]
**orderId** | **String**| ID of the order that needs to be deleted |
### Return type
@ -126,7 +126,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**orderId** | **int**| ID of pet that needs to be fetched | [default to null]
**orderId** | **int**| ID of pet that needs to be fetched |
### Return type

View File

@ -8,8 +8,8 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **int** | | [optional] [default to null]
**name** | **String** | | [optional] [default to null]
**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)

View File

@ -8,14 +8,14 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **int** | | [optional] [default to null]
**username** | **String** | | [optional] [default to null]
**firstName** | **String** | | [optional] [default to null]
**lastName** | **String** | | [optional] [default to null]
**email** | **String** | | [optional] [default to null]
**password** | **String** | | [optional] [default to null]
**phone** | **String** | | [optional] [default to null]
**userStatus** | **int** | User Status | [optional] [default to null]
**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)

View File

@ -166,7 +166,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The name that needs to be deleted | [default to null]
**username** | **String**| The name that needs to be deleted |
### Return type
@ -207,7 +207,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The name that needs to be fetched. Use user1 for testing. | [default to null]
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
### Return type
@ -249,8 +249,8 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The user name for login | [default to null]
**password** | **String**| The password for login in clear text | [default to null]
**username** | **String**| The user name for login |
**password** | **String**| The password for login in clear text |
### Return type
@ -329,7 +329,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| name that need to be deleted | [default to null]
**username** | **String**| name that need to be deleted |
**body** | [**User**](User.md)| Updated user object |
### Return type

View File

@ -8,9 +8,9 @@ class Pet {
String name = null;
List<String> photoUrls = [];
List<String> photoUrls = const [];
List<Tag> tags = [];
List<Tag> tags = const [];
/* pet status in the store */
String status = null;
//enum statusEnum { available, pending, sold, };{

View File

@ -8,9 +8,9 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**code** | **int** | | [optional] [default to null]
**type** | **String** | | [optional] [default to null]
**message** | **String** | | [optional] [default to null]
**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)

View File

@ -8,8 +8,8 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **int** | | [optional] [default to null]
**name** | **String** | | [optional] [default to null]
**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)

View File

@ -8,11 +8,11 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **int** | | [optional] [default to null]
**petId** | **int** | | [optional] [default to null]
**quantity** | **int** | | [optional] [default to null]
**shipDate** | [**DateTime**](DateTime.md) | | [optional] [default to null]
**status** | **String** | Order Status | [optional] [default to null]
**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)

View File

@ -8,12 +8,12 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **int** | | [optional] [default to null]
**category** | [**Category**](Category.md) | | [optional] [default to null]
**name** | **String** | | [default to null]
**photoUrls** | **List&lt;String&gt;** | | [default to []]
**tags** | [**List&lt;Tag&gt;**](Tag.md) | | [optional] [default to []]
**status** | **String** | pet status in the store | [optional] [default to null]
**id** | **int** | | [optional]
**category** | [**Category**](Category.md) | | [optional]
**name** | **String** | |
**photoUrls** | **List&lt;String&gt;** | | [default to const []]
**tags** | [**List&lt;Tag&gt;**](Tag.md) | | [optional] [default to const []]
**status** | **String** | pet status in the store | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -87,8 +87,8 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **int**| Pet id to delete | [default to null]
**apiKey** | **String**| | [optional] [default to null]
**petId** | **int**| Pet id to delete |
**apiKey** | **String**| | [optional]
### Return type
@ -133,7 +133,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**status** | [**List&lt;String&gt;**](String.md)| Status values that need to be considered for filter | [default to []]
**status** | [**List&lt;String&gt;**](String.md)| Status values that need to be considered for filter | [default to const []]
### Return type
@ -178,7 +178,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**tags** | [**List&lt;String&gt;**](String.md)| Tags to filter by | [default to []]
**tags** | [**List&lt;String&gt;**](String.md)| Tags to filter by | [default to const []]
### Return type
@ -225,7 +225,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **int**| ID of pet to return | [default to null]
**petId** | **int**| ID of pet to return |
### Return type
@ -311,9 +311,9 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **int**| ID of pet that needs to be updated | [default to null]
**name** | **String**| Updated name of the pet | [optional] [default to null]
**status** | **String**| Updated status of the pet | [optional] [default to null]
**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
@ -358,9 +358,9 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **int**| ID of pet to update | [default to null]
**additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null]
**file** | **MultipartFile**| file to upload | [optional] [default to null]
**petId** | **int**| ID of pet to update |
**additionalMetadata** | **String**| Additional data to pass to server | [optional]
**file** | **MultipartFile**| file to upload | [optional]
### Return type

View File

@ -40,7 +40,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**orderId** | **String**| ID of the order that needs to be deleted | [default to null]
**orderId** | **String**| ID of the order that needs to be deleted |
### Return type
@ -126,7 +126,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**orderId** | **int**| ID of pet that needs to be fetched | [default to null]
**orderId** | **int**| ID of pet that needs to be fetched |
### Return type

View File

@ -8,8 +8,8 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **int** | | [optional] [default to null]
**name** | **String** | | [optional] [default to null]
**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)

View File

@ -8,14 +8,14 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **int** | | [optional] [default to null]
**username** | **String** | | [optional] [default to null]
**firstName** | **String** | | [optional] [default to null]
**lastName** | **String** | | [optional] [default to null]
**email** | **String** | | [optional] [default to null]
**password** | **String** | | [optional] [default to null]
**phone** | **String** | | [optional] [default to null]
**userStatus** | **int** | User Status | [optional] [default to null]
**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)

View File

@ -166,7 +166,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The name that needs to be deleted | [default to null]
**username** | **String**| The name that needs to be deleted |
### Return type
@ -207,7 +207,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The name that needs to be fetched. Use user1 for testing. | [default to null]
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
### Return type
@ -249,8 +249,8 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The user name for login | [default to null]
**password** | **String**| The password for login in clear text | [default to null]
**username** | **String**| The user name for login |
**password** | **String**| The password for login in clear text |
### Return type
@ -329,7 +329,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| name that need to be deleted | [default to null]
**username** | **String**| name that need to be deleted |
**body** | [**User**](User.md)| Updated user object |
### Return type

View File

@ -8,9 +8,9 @@ class Pet {
String name = null;
List<String> photoUrls = [];
List<String> photoUrls = const [];
List<Tag> tags = [];
List<Tag> tags = const [];
/* pet status in the store */
String status = null;
//enum statusEnum { available, pending, sold, };{

View File

@ -9,12 +9,10 @@ class Order {
int quantity = null;
DateTime shipDate = null;
/* Order Status */
String status = null;
//enum statusEnum { placed, approved, delivered, };{
/// Order Status
StatusEnum status = null;
bool complete = false;
Order();
@override
String toString() {
@ -74,3 +72,5 @@ class Order {
}
}
enum StatusEnum { placed, approved, delivered, }

View File

@ -11,10 +11,8 @@ class Pet {
List<String> photoUrls = [];
List<Tag> tags = [];
/* pet status in the store */
String status = null;
//enum statusEnum { available, pending, sold, };{
Pet();
/// pet status in the store
StatusEnum status = null;
@override
String toString() {
@ -78,3 +76,5 @@ class Pet {
}
}
enum StatusEnum { available, pending, sold, }

View File

@ -5,7 +5,6 @@ class Tag {
int id = null;
String name = null;
Tag();
@override
String toString() {
@ -50,4 +49,3 @@ class Tag {
return map;
}
}

View File

@ -0,0 +1,9 @@
import 'package:openapi/api.dart';
import 'package:test/test.dart';
void main() {
test('Check if default value is generated', () async {
var order = Order();
expect(order.complete, equals(false));
});
}

View File

@ -1,4 +1,5 @@
import 'dart:io';
import 'dart:math';
import 'package:http/http.dart';
import 'package:openapi/api.dart';
@ -31,7 +32,7 @@ void main() {
..category = category
..tags = tags
..name = name
..status = status
..status = PetStatusEnum.fromJson(status)
..photoUrls = ['https://petstore.com/sample/photo1.jpg'];
}
@ -188,10 +189,10 @@ void main() {
final id1 = newId();
final id2 = newId();
final id3 = newId();
final status = 'available';
final status = PetStatusEnum.available_.value;
final pet1 = makePet(id: id1, status: status);
final pet2 = makePet(id: id2, status: status);
final pet3 = makePet(id: id3, status: 'sold');
final pet3 = makePet(id: id3, status: PetStatusEnum.sold_.value);
return Future.wait([addPet(pet1), addPet(pet2), addPet(pet3)])
.then((_) async {
@ -202,6 +203,10 @@ void main() {
getResponseBody: petApi.apiClient.serialize([pet1, pet2]),
);
final pets = await petApi.findPetsByStatus([status]);
// tests serialisation and deserialisation of enum
final petsByStatus = pets.where((p) => p.status == PetStatusEnum.available_);
expect(petsByStatus.length, equals(2));
final petIds = pets.map((pet) => pet.id).toList();
expect(petIds, contains(id1));
expect(petIds, contains(id2));

View File

@ -25,14 +25,16 @@ void main() {
..id = 124321
..name = 'Jose'
];
return Pet(
id : id,
category: category,
name: name, //required field
tags: tags,
photoUrls: ['https://petstore.com/sample/photo1.jpg'] //required field
)
..tags = tags
..status = '';
..status = PetStatusEnum.fromJson(status)
..photoUrls = ['https://petstore.com/sample/photo1.jpg'];
}
group('Pet API with live client', () {
@ -79,12 +81,12 @@ void main() {
var id1 = newId();
var id2 = newId();
var id3 = newId();
var status = 'available';
var status = PetStatusEnum.available_.value;
return Future.wait([
petApi.addPet(makePet(id: id1, status: status)),
petApi.addPet(makePet(id: id2, status: status)),
petApi.addPet(makePet(id: id3, status: 'sold'))
petApi.addPet(makePet(id: id3, status: PetStatusEnum.sold_.value))
]).then((_) async {
var pets = await petApi.findPetsByStatus([status]);
var petIds = pets.map((pet) => pet.id).toList();

View File

@ -8,9 +8,9 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**code** | **int** | | [optional] [default to null]
**type** | **String** | | [optional] [default to null]
**message** | **String** | | [optional] [default to null]
**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)

View File

@ -8,8 +8,8 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **int** | | [optional] [default to null]
**name** | **String** | | [optional] [default to null]
**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)

View File

@ -8,11 +8,11 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **int** | | [optional] [default to null]
**petId** | **int** | | [optional] [default to null]
**quantity** | **int** | | [optional] [default to null]
**shipDate** | [**DateTime**](DateTime.md) | | [optional] [default to null]
**status** | **String** | Order Status | [optional] [default to null]
**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)

View File

@ -8,12 +8,12 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **int** | | [optional] [default to null]
**category** | [**Category**](Category.md) | | [optional] [default to null]
**name** | **String** | | [default to null]
**photoUrls** | **List&lt;String&gt;** | | [default to []]
**tags** | [**List&lt;Tag&gt;**](Tag.md) | | [optional] [default to []]
**status** | **String** | pet status in the store | [optional] [default to null]
**id** | **int** | | [optional]
**category** | [**Category**](Category.md) | | [optional]
**name** | **String** | |
**photoUrls** | **List&lt;String&gt;** | | [default to const []]
**tags** | [**List&lt;Tag&gt;**](Tag.md) | | [optional] [default to const []]
**status** | **String** | pet status in the store | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -87,8 +87,8 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **int**| Pet id to delete | [default to null]
**apiKey** | **String**| | [optional] [default to null]
**petId** | **int**| Pet id to delete |
**apiKey** | **String**| | [optional]
### Return type
@ -133,7 +133,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**status** | [**List&lt;String&gt;**](String.md)| Status values that need to be considered for filter | [default to []]
**status** | [**List&lt;String&gt;**](String.md)| Status values that need to be considered for filter | [default to const []]
### Return type
@ -178,7 +178,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**tags** | [**List&lt;String&gt;**](String.md)| Tags to filter by | [default to []]
**tags** | [**List&lt;String&gt;**](String.md)| Tags to filter by | [default to const []]
### Return type
@ -225,7 +225,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **int**| ID of pet to return | [default to null]
**petId** | **int**| ID of pet to return |
### Return type
@ -311,9 +311,9 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **int**| ID of pet that needs to be updated | [default to null]
**name** | **String**| Updated name of the pet | [optional] [default to null]
**status** | **String**| Updated status of the pet | [optional] [default to null]
**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
@ -358,9 +358,9 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **int**| ID of pet to update | [default to null]
**additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null]
**file** | **MultipartFile**| file to upload | [optional] [default to null]
**petId** | **int**| ID of pet to update |
**additionalMetadata** | **String**| Additional data to pass to server | [optional]
**file** | **MultipartFile**| file to upload | [optional]
### Return type

View File

@ -40,7 +40,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**orderId** | **String**| ID of the order that needs to be deleted | [default to null]
**orderId** | **String**| ID of the order that needs to be deleted |
### Return type
@ -126,7 +126,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**orderId** | **int**| ID of pet that needs to be fetched | [default to null]
**orderId** | **int**| ID of pet that needs to be fetched |
### Return type

View File

@ -8,8 +8,8 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **int** | | [optional] [default to null]
**name** | **String** | | [optional] [default to null]
**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)

View File

@ -8,14 +8,14 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **int** | | [optional] [default to null]
**username** | **String** | | [optional] [default to null]
**firstName** | **String** | | [optional] [default to null]
**lastName** | **String** | | [optional] [default to null]
**email** | **String** | | [optional] [default to null]
**password** | **String** | | [optional] [default to null]
**phone** | **String** | | [optional] [default to null]
**userStatus** | **int** | User Status | [optional] [default to null]
**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)

View File

@ -166,7 +166,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The name that needs to be deleted | [default to null]
**username** | **String**| The name that needs to be deleted |
### Return type
@ -207,7 +207,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The name that needs to be fetched. Use user1 for testing. | [default to null]
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
### Return type
@ -249,8 +249,8 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The user name for login | [default to null]
**password** | **String**| The password for login in clear text | [default to null]
**username** | **String**| The user name for login |
**password** | **String**| The password for login in clear text |
### Return type
@ -329,7 +329,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| name that need to be deleted | [default to null]
**username** | **String**| name that need to be deleted |
**body** | [**User**](User.md)| Updated user object |
### Return type

View File

@ -2,11 +2,11 @@ part of openapi.api;
class ApiResponse {
int code = null;
int code;
String type = null;
String type;
String message = null;
String message;
ApiResponse({
this.code,
@ -42,7 +42,7 @@ class ApiResponse {
}
static Map<String, ApiResponse> mapFromJson(Map<String, dynamic> json) {
var map = Map<String, ApiResponse>();
final map = Map<String, ApiResponse>();
if (json != null && json.isNotEmpty) {
json.forEach((String key, dynamic value) => map[key] = ApiResponse.fromJson(value));
}
@ -51,7 +51,7 @@ class ApiResponse {
// maps a json object with a list of ApiResponse-objects as value to a dart map
static Map<String, List<ApiResponse>> mapListFromJson(Map<String, dynamic> json) {
var map = Map<String, List<ApiResponse>>();
final map = Map<String, List<ApiResponse>>();
if (json != null && json.isNotEmpty) {
json.forEach((String key, dynamic value) {
map[key] = ApiResponse.listFromJson(value);

View File

@ -2,9 +2,9 @@ part of openapi.api;
class Category {
int id = null;
int id;
String name = null;
String name;
Category({
this.id,
@ -36,7 +36,7 @@ class Category {
}
static Map<String, Category> mapFromJson(Map<String, dynamic> json) {
var map = Map<String, Category>();
final map = Map<String, Category>();
if (json != null && json.isNotEmpty) {
json.forEach((String key, dynamic value) => map[key] = Category.fromJson(value));
}
@ -45,7 +45,7 @@ class Category {
// maps a json object with a list of Category-objects as value to a dart map
static Map<String, List<Category>> mapListFromJson(Map<String, dynamic> json) {
var map = Map<String, List<Category>>();
final map = Map<String, List<Category>>();
if (json != null && json.isNotEmpty) {
json.forEach((String key, dynamic value) {
map[key] = Category.listFromJson(value);

View File

@ -2,16 +2,15 @@ part of openapi.api;
class Order {
int id = null;
int id;
int petId = null;
int petId;
int quantity = null;
int quantity;
DateTime shipDate = null;
/* Order Status */
String status = null;
//enum statusEnum { placed, approved, delivered, };{
DateTime shipDate;
/// Order Status
OrderStatusEnum status;
bool complete = false;
@ -21,7 +20,7 @@ class Order {
this.quantity,
this.shipDate,
this.status,
this.complete,
this.complete = false,
});
@override
@ -37,7 +36,7 @@ class Order {
shipDate = (json['shipDate'] == null) ?
null :
DateTime.parse(json['shipDate']);
status = json['status'];
status = OrderStatusEnum.fromJson(json['status']);
complete = json['complete'];
}
@ -52,7 +51,7 @@ class Order {
if (shipDate != null)
json['shipDate'] = shipDate == null ? null : shipDate.toUtc().toIso8601String();
if (status != null)
json['status'] = status;
json['status'] = status.value;
if (complete != null)
json['complete'] = complete;
return json;
@ -63,7 +62,7 @@ class Order {
}
static Map<String, Order> mapFromJson(Map<String, dynamic> json) {
var map = Map<String, Order>();
final map = Map<String, Order>();
if (json != null && json.isNotEmpty) {
json.forEach((String key, dynamic value) => map[key] = Order.fromJson(value));
}
@ -72,7 +71,7 @@ class Order {
// maps a json object with a list of Order-objects as value to a dart map
static Map<String, List<Order>> mapListFromJson(Map<String, dynamic> json) {
var map = Map<String, List<Order>>();
final map = Map<String, List<Order>>();
if (json != null && json.isNotEmpty) {
json.forEach((String key, dynamic value) {
map[key] = Order.listFromJson(value);
@ -81,4 +80,53 @@ class Order {
return map;
}
}
class OrderStatusEnum {
/// The underlying value of this enum member.
final String value;
const OrderStatusEnum._internal(this.value);
/// Order Status
static const OrderStatusEnum placed_ = OrderStatusEnum._internal("placed");
/// Order Status
static const OrderStatusEnum approved_ = OrderStatusEnum._internal("approved");
/// Order Status
static const OrderStatusEnum delivered_ = OrderStatusEnum._internal("delivered");
String toJson () {
return value;
}
@override
String toString () {
return value;
}
static OrderStatusEnum fromJson(String value) {
return OrderStatusEnumTypeTransformer().decode(value);
}
static List<OrderStatusEnum> listFromJson(List<dynamic> json) {
return json == null
? List<OrderStatusEnum>()
: json.map((value) => OrderStatusEnum.fromJson(value)).toList();
}
}
class OrderStatusEnumTypeTransformer {
dynamic encode(OrderStatusEnum data) {
return data.value;
}
OrderStatusEnum decode(dynamic data) {
switch (data) {
case "placed": return OrderStatusEnum.placed_;
case "approved": return OrderStatusEnum.approved_;
case "delivered": return OrderStatusEnum.delivered_;
default: return null;
}
}
}

View File

@ -2,25 +2,24 @@ part of openapi.api;
class Pet {
int id = null;
int id;
Category category = null;
Category category;
String name = null;
String name;
List<String> photoUrls = [];
List<String> photoUrls = const [];
List<Tag> tags = [];
/* pet status in the store */
String status = null;
//enum statusEnum { available, pending, sold, };{
List<Tag> tags = const [];
/// pet status in the store
PetStatusEnum status;
Pet({
this.id,
this.category,
@required this.name,
@required this.photoUrls,
this.tags,
this.tags = const [],
this.status,
});
@ -42,7 +41,7 @@ class Pet {
tags = (json['tags'] == null) ?
null :
Tag.listFromJson(json['tags']);
status = json['status'];
status = PetStatusEnum.fromJson(json['status']);
}
Map<String, dynamic> toJson() {
@ -58,7 +57,7 @@ class Pet {
if (tags != null)
json['tags'] = tags;
if (status != null)
json['status'] = status;
json['status'] = status.value;
return json;
}
@ -67,7 +66,7 @@ class Pet {
}
static Map<String, Pet> mapFromJson(Map<String, dynamic> json) {
var map = Map<String, Pet>();
final map = Map<String, Pet>();
if (json != null && json.isNotEmpty) {
json.forEach((String key, dynamic value) => map[key] = Pet.fromJson(value));
}
@ -76,7 +75,7 @@ class Pet {
// maps a json object with a list of Pet-objects as value to a dart map
static Map<String, List<Pet>> mapListFromJson(Map<String, dynamic> json) {
var map = Map<String, List<Pet>>();
final map = Map<String, List<Pet>>();
if (json != null && json.isNotEmpty) {
json.forEach((String key, dynamic value) {
map[key] = Pet.listFromJson(value);
@ -85,4 +84,53 @@ class Pet {
return map;
}
}
class PetStatusEnum {
/// The underlying value of this enum member.
final String value;
const PetStatusEnum._internal(this.value);
/// pet status in the store
static const PetStatusEnum available_ = PetStatusEnum._internal("available");
/// pet status in the store
static const PetStatusEnum pending_ = PetStatusEnum._internal("pending");
/// pet status in the store
static const PetStatusEnum sold_ = PetStatusEnum._internal("sold");
String toJson () {
return value;
}
@override
String toString () {
return value;
}
static PetStatusEnum fromJson(String value) {
return PetStatusEnumTypeTransformer().decode(value);
}
static List<PetStatusEnum> listFromJson(List<dynamic> json) {
return json == null
? List<PetStatusEnum>()
: json.map((value) => PetStatusEnum.fromJson(value)).toList();
}
}
class PetStatusEnumTypeTransformer {
dynamic encode(PetStatusEnum data) {
return data.value;
}
PetStatusEnum decode(dynamic data) {
switch (data) {
case "available": return PetStatusEnum.available_;
case "pending": return PetStatusEnum.pending_;
case "sold": return PetStatusEnum.sold_;
default: return null;
}
}
}

View File

@ -2,9 +2,9 @@ part of openapi.api;
class Tag {
int id = null;
int id;
String name = null;
String name;
Tag({
this.id,
@ -36,7 +36,7 @@ class Tag {
}
static Map<String, Tag> mapFromJson(Map<String, dynamic> json) {
var map = Map<String, Tag>();
final map = Map<String, Tag>();
if (json != null && json.isNotEmpty) {
json.forEach((String key, dynamic value) => map[key] = Tag.fromJson(value));
}
@ -45,7 +45,7 @@ class Tag {
// maps a json object with a list of Tag-objects as value to a dart map
static Map<String, List<Tag>> mapListFromJson(Map<String, dynamic> json) {
var map = Map<String, List<Tag>>();
final map = Map<String, List<Tag>>();
if (json != null && json.isNotEmpty) {
json.forEach((String key, dynamic value) {
map[key] = Tag.listFromJson(value);

View File

@ -2,21 +2,21 @@ part of openapi.api;
class User {
int id = null;
int id;
String username = null;
String username;
String firstName = null;
String firstName;
String lastName = null;
String lastName;
String email = null;
String email;
String password = null;
String password;
String phone = null;
/* User Status */
int userStatus = null;
String phone;
/// User Status
int userStatus;
User({
this.id,
@ -72,7 +72,7 @@ class User {
}
static Map<String, User> mapFromJson(Map<String, dynamic> json) {
var map = Map<String, User>();
final map = Map<String, User>();
if (json != null && json.isNotEmpty) {
json.forEach((String key, dynamic value) => map[key] = User.fromJson(value));
}
@ -81,7 +81,7 @@ class User {
// maps a json object with a list of User-objects as value to a dart map
static Map<String, List<User>> mapListFromJson(Map<String, dynamic> json) {
var map = Map<String, List<User>>();
final map = Map<String, List<User>>();
if (json != null && json.isNotEmpty) {
json.forEach((String key, dynamic value) {
map[key] = User.listFromJson(value);