-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid schema with types with primes ('
)
#57
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When generically deriving a schema for a type whose name contains a
'
we (might) generate a malformed spec.(Such a type may come from being defined to have such a name, or mentioning a promoted constructor (with DataKinds).)
If the openapi3 generates a named schema object, it will be named the same as the type (applied to parameters, with spaces replaced by underscores).
Unfortunately, the spec https://swagger.io/specification/#components-object says this is invalid:
Both the online swagger editor and
openapi-generator-cli validate
reject the schema as invalid.For example, consider the program
This prints
Notice that the map keys include the character
'
.The solutions I can see are:
It is unusual to manually name an API-visible type with a
'
, so it is not worth fixing -- a user can always change their data declaration.However, if a poorly-named type comes from an external library or a user is using DataKinds, they cannot simply rename.
Thus we should also document a workaround (one can generically derive, and use rename)
I don't know how possible this is for the "polymorphic type with a promoted argument" case.
It would be nice if names without
'
are not mangled, and we should ensure that the encoding is injective (to avoid name clashes). On this second point, see also Generically derived schema reference names can clash #56.The text was updated successfully, but these errors were encountered: