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

[General] default value of enum property that are $ref-ed is not recognized

Open fuj1g0n opened this issue 8 years ago • 2 comments

Description

openapi-generator doesn't recognize default value of enum property that are $ref-ed.

openapi-generator version

current master eb4dfe0fc1362f82d91d8371e7493dc4e1195d24

OpenAPI declaration file content or url

https://gist.github.com/fujigon/4ae17fc6497cb599d1dfb53c2ebeadea#file-openapi-yaml

Command line used for generation
# git clone, etc
mvn package
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i my-api-spec/openapi.yaml -g jaxrs-jersey -o generated-code/ -v
Steps to reproduce

When I execute the generator with the gisted openapi.yaml file, I get https://gist.github.com/fujigon/4ae17fc6497cb599d1dfb53c2ebeadea#file-inlineresponsedefault-java

The problem is that default value of enum property that are $ref-ed is null

https://gist.github.com/fujigon/4ae17fc6497cb599d1dfb53c2ebeadea#file-inlineresponsedefault-java-L39

Related issues/PRs
Suggest a fix/enhancement

I investigated and found that https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java#L703 is the problem.

current implementation of unaliasSchema method doesn't return the ref-resolved schema.

I'm working to file the PR to fix this issue.

fuj1g0n avatar Oct 26 '18 08:10 fuj1g0n

It sounds like https://github.com/OpenAPITools/openapi-generator/issues/1981 what I have tried to address with https://github.com/OpenAPITools/openapi-generator/pull/2001

During my tests and for @ajdergute it seems to work.

So we need to understand what additional case you need to support.

jmini avatar Feb 12 '19 04:02 jmini

I confirmed that following up issue https://github.com/OpenAPITools/openapi-generator/issues/2127 is fixed and now this issue is completely resolved.

Thanks for support! :)

fuj1g0n avatar Feb 21 '19 07:02 fuj1g0n