elastic / elasticsearch-specification

Elasticsearch full specification
Apache License 2.0
121 stars 72 forks source link

OAS errors due to characters in schema names #2375

Open lcawl opened 9 months ago

lcawl commented 9 months ago

While testing the OAS output in Readme, it failed to import the file due to errors in the schema names. The same type of errors can be seen by running npx @redocly/cli lint elasticsearch-serverless-openapi.json. For example:

[100] elasticsearch-serverless-openapi.json:21272:7 at #/components/parameters/cat.transforms#size The map key in parameters "cat.transforms#size" does not match the regular expression "^[a-zA-Z0-9.-_]+$"

21270 | "style": "form" 21271 | }, 21272 | "cat.transforms#size": { 21273 | "in": "query", 21274 | "name": "size",

Error was generated by the spec-components-invalid-map-name rule.

< ... 2495 more problems hidden > increase with --max-problems N elasticsearch-serverless-openapi.json: validated in 540ms

❌ Validation failed with 2220 errors and 375 warnings.

Similar errors occur when there are colons in the name, for example:

... at #/components/schemas/_spec_utils:Stringifiedboolean

The map key in schemas "_specutils:Stringifiedboolean" does not match the regular expression "^[a-zA-Z0-9.-]+$"

In my local tests, these errors disappear if we use an underscore or period instead of a colon or number sign.

lcawl commented 4 months ago

We now recommend using the following linting rules in spectral: https://github.com/elastic/elastic-openapi/blob/main/.spectral.yaml

We've turned off quite a few default checks since Bump.sh doesn't seem to have a problem with these values, but in case folks use other tools it might still be nice to fix.