Open zellidev0 opened 8 months ago
Generating dart code from a swagger json that has a uniqueItems attribute set to true for a List automatically converts it to a Set while parsing. But the parsing fails because a json List is not a Set.
uniqueItems
"experts": { "uniqueItems": true, "type": "array", "items": { "type": "string" } },
this part gets a json parsing like that:
json[r'experts'] is Set ? (json[r'experts'] as Set).cast<String>() : const {},
because the returned Json is never a Set, the result is always empty.
minimal json:
{ "openapi": "3.0.1", "info": { "title": "my-service", "version": "1.0" }, "servers": [ { "url": "/my-service" } ], "security": [ { "Authorization": [] } ], "paths": { "/api/v2/subscription/cancel": { "delete": { "tags": [ "subscription-v-2-controller" ], "operationId": "cancelSubscription_2", "responses": { "200": { "description": "OK" } } } } }, "components": { "schemas": { "WechatPayRedirectToAndroidApp": { "type": "object", "properties": { "timestamp": { "type": "string" }, "experts": { "uniqueItems": true, "type": "array", "items": { "type": "string" } }, "package": { "type": "string" } } } } } }
Annotation:
@Openapi( additionalProperties: AdditionalProperties( pubName: 'my_service', ), alwaysRun: true, inputSpecFile: 'lib/src/common/openapi_specs/my_service.json', generatorName: Generator.dart, outputDirectory: '../generated/my_service/', ) class MyServiceOpenapiGeneratorConfig {}
The parsing is done as a List and converted to a Set afterwards.
No response
macOS
4.12.0
3.13.4
stable
Description of the bug
Generating dart code from a swagger json that has a automatically converts it to a Set while parsing.
But the parsing fails because a json List is not a Set.
uniqueItems
attribute set to true for a Listthis part gets a json parsing like that:
because the returned Json is never a Set, the result is always empty.
Steps to reproduce
minimal json:
Annotation:
Expected behavior
The parsing is done as a List and converted to a Set afterwards.
Logs
No response
Screenshots
No response
Platform
macOS
Library version
4.12.0
Flutter version
3.13.4
Flutter channel
stable
Additional context
No response