OpenAPITools / OpenAPITools/openapi-generator
[BUG][Crystal] Uncompilable crystal code is generated
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
If the crystal generator is used, and the templates partial_model_generic.mustache, base_object.mustache or partial_oneof_module.mustache are instanced, we generate code using ....get_const(...) which isn't a thing in crystal, so the resulting code is unusable. (see https://github.com/crystal-lang/crystal/issues/8180 for proof of no const_get in crystal)
openapi-generator version
This seems to be from crystal introduction until latest master branch. (b3ec7faa8fc)
Reproducing
I encounter it when creating enum schemas, which is only used as a subtype in the petstore example which makes this not occur.
...
content:
schema:
type: string
enum:
- "a"
- "b"
Using some spec with the above contents trigger it.
Suggest a fix
The generator files mentioned should be fixed so it is not producing ruby code that doesn't work in crystal.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with partial_model_generic.mustache, base_object.mustache, and partial_oneof_module.mustache, then reproduce the issue using an enum schema with values "a" and "b". Inspect the generated Crystal code for get_const calls; done means the affected templates generate usable Crystal code without that unsupported call.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- crystal
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100