openapi-generator
openapi-generator copied to clipboard
[BUG][graphql-schema] doesn't support reuseble enum
Bug Report Checklist
- [x] Have you provided a full/minimal spec to reproduce the issue?
- [x] Have you validated the input using an OpenAPI validator (example)?
- [x] What's the version of OpenAPI Generator used?
- [x] Have you search for related issues/PRs?
- [x] What's the actual output vs expected output?
- [ ] [Optional] Bounty to sponsor the fix (example)
Description
graphql-schema generator doesn't support reusable enum
openapi-generator version
4.3.0
OpenAPI declaration file content or url
Resource:
type: object
properties:
status:
$ref: '#/components/schemas/ResourceStatus'
ResourceStatus:
type: string
enum:
- a
- b
- c
Command line used for generation
npx openapi-generator generate -g graphql-schema -i example.yaml -o somedir
Steps to reproduce
Just run this command with schemas provided above, you will get an empty graphql file for this enum
# Paths for user service
# No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
# The version of the OpenAPI document: 1.0.0
# Generated by OpenAPI Generator: https://openapi-generator.tech
#
type ResourceStatus {
}
Related issues/PRs
Suggest a fix
Bug still present in 5.4.0 too.
I fixed a solution by the PR https://github.com/OpenAPITools/openapi-generator/pull/12389 .
Bug still present in v7.8.0 Could be fixed using the following model.mustache file:
{{#models}}
{{#model}}
{{>partial_header}}
{{#description}}
"""
{{.}}
"""
{{/description}}
{{#isEnum}}
enum {{classname}} {
{{#allowableValues}}
{{#values}}
{{.}}
{{/values}}
{{/allowableValues}}
}
{{/isEnum}}
{{^isEnum}}
type {{classname}} {
{{#vars}}
{{#description}}
"""
{{.}}
"""
{{/description}}
{{baseName}}: {{datatypeWithEnum}}
{{/vars}}
}
{{/isEnum}}
{{/model}}
{{/models}}