[BUG][Dart] Generated Enum is a string without validation
Created by: agilob
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs? -
What's the actual output vs expected output?
Description
Requested generated Enum is a string without validation.
openapi-generator version
4.3.1
OpenAPI declaration file content or url
If you post the code inline, please wrap it with
components:
schemas:
Sorting:
type: object
description: sorting order
properties:
sortingOrder:
type: string
enum: [asc, desc]
Generates:
part of openapi.api;
class Sorting {
String sortingOrder = null;
//enum sortingOrderEnum { asc, desc, };{
Sorting();
@override
String toString() {
return 'Sorting[sortingOrder=$sortingOrder, ]';
}
Sorting.fromJson(Map<String, dynamic> json) {
if (json == null) return;
sortingOrder = json['sortingOrder'];
}
Map<String, dynamic> toJson() {
Map <String, dynamic> json = {};
if (sortingOrder != null)
json['sortingOrder'] = sortingOrder;
return json;
}
static List<Sorting> listFromJson(List<dynamic> json) {
return json == null ? List<Sorting>() : json.map((value) => Sorting.fromJson(value)).toList();
}
static Map<String, Sorting> mapFromJson(Map<String, dynamic> json) {
var map = Map<String, Sorting>();
if (json != null && json.isNotEmpty) {
json.forEach((String key, dynamic value) => map[key] = Sorting.fromJson(value));
}
return map;
}
// maps a json object with a list of Sorting-objects as value to a dart map
static Map<String, List<Sorting>> mapListFromJson(Map<String, dynamic> json) {
var map = Map<String, List<Sorting>>();
if (json != null && json.isNotEmpty) {
json.forEach((String key, dynamic value) {
map[key] = Sorting.listFromJson(value);
});
}
return map;
}
}
Command line used for generation
openapi-generator generate -i openapi-spec.yaml -g dart --skip-validate-spec -o lib/generated --additional-properties=pubName=agilob,useEnumExtension=true