cyclosproject / ng-openapi-gen

An OpenAPI 3.0 codegen for Angular
MIT License
404 stars 134 forks source link

Components Object: keys are not forced to adhere to the OpenAPI spec #179

Closed Kattoor closed 3 years ago

Kattoor commented 3 years ago

Another OpenAPI generator that I'm using for Flutter development made me aware of the following constraint that the OpenAPI spec applies to the keys of the records in the 'Components' object:

All the fixed fields declared above are objects that MUST use keys that match the regular expression: ^[a-zA-Z0-9.-_]+$.

By omitting this, the ng-openapi-gen project will successfully generate code, even if the input json/yaml file doesn't adhere to the OpenAPI spec.

luisfpg commented 3 years ago

To be honest, I wasn't aware of this constraint either. Anyway, this doesn't affect so much the generator, because it would only affect reusable definitions, which are only referenced elsewhere. Of course, there are the schemas, which is the most important for us. But the generated model names are normalized anyhow, because . and - are accepted. So I don't see a reason to break the generation if any of those fixed names don't comply with the spec's regex.