Closed agilob closed 4 years ago
I'm either incorrectly using it, or the package doesn't generate enums correctly.
I have this component:
components: schemas: Sorting: type: object description: sorting order properties: sortingOrder: type: string enum: [asc, desc]
This is generated as:
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; } }
where enum exists, but it's not used to validate if passed string is allowed.
Do I need to use:
useEnumExtension: true supportDart2: true
If so, where do I set them? An example in documentation would be helpful.
Nvm, I thought this is repo for https://openapi-generator.tech/docs/generators/dart/ but pubdev package :D
No worries.
I'm either incorrectly using it, or the package doesn't generate enums correctly.
I have this component:
This is generated as:
where enum exists, but it's not used to validate if passed string is allowed.
Do I need to use:
If so, where do I set them? An example in documentation would be helpful.