openapi-generator-dart icon indicating copy to clipboard operation
openapi-generator-dart copied to clipboard

Generator.dio doesn't work

Open jiffstudio opened this issue 2 years ago • 3 comments

Description of the bug

I chose the generatorName as Generator.dio. But it produces dart version.

Steps to reproduce

@Openapi( additionalProperties: DioProperties(pubName: 'coclass_api', pubAuthor: 'Jiff'), inputSpecFile: 'lib/apis/api_spec.yaml', generatorName: Generator.dio, outputDirectory: 'plugins/coclass_api', useNextGen: true) class CustomOpenapiGeneratorConfig extends OpenapiGeneratorConfig {}

Expected behavior

Expect it to use dio to request. But it only uses http library.

Logs

No response

Screenshots

No response

Platform

Windows

Library version

4.12.1

Flutter version

3.13.1

Flutter channel

stable

Additional context

No response

jiffstudio avatar Aug 25 '23 02:08 jiffstudio

HI, did you try deleting the coclass_api folder and running the generator again?

when you do, look for a log that says something like generate -I lib/apis/api_spec.yaml or something like that and paste here.

Also, if you find that the generator is not running, make a simple modification to the file that has the @openapi annotation so that build runner will detect changes and run the generator. Awaiting your feedback.

gibahjoe avatar Aug 25 '23 11:08 gibahjoe

I can confirm that the generator always uses the dart generator, regardless of what is defined.

Version: 4.13.1

Config:

@Openapi(
  additionalProperties: DioAltProperties(
    pubName: 'wichteln_api',
    pubAuthor: 'Andreas Schulz',
    nullSafe: true,
    nullSafeArrayDefault: true,
    listAnyOf: true,
  ),
  inputSpecFile: 'wichteln-api.yaml',
  generatorName: Generator.dio,
  outputDirectory: 'wichteln_api',
  alwaysRun: true,
)

Log:

[ generate -o=wichteln_api -i=wichteln-api.yaml -g=dart --additional-properties=allowUnicodeIdentifiers=false,ensureUniqueParams=true,useEnumExtension=true,prependFormOrBodyParameters=false,pubAuthor=Andreas Schulz,pubName=wichteln_api,legacyDiscriminatorBehavior=true,sortModelPropertiesByRequiredFlag=true,sortParamsByRequiredFlag=true,wrapper=none,nullSafe=true,nullSafe-array-default=true,listAnyOf=true ]

So every parameter seems to be applied correctly, except -g=dart.

aschulz90 avatar Dec 09 '23 10:12 aschulz90

it happen when your pub outdated (usually source_gen) so you can fix by run flutter pub upgrade (maybe --major-versions)

quyenvsp avatar Mar 08 '24 04:03 quyenvsp