Skip to content
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

OAS 3.1 - arbitrary schema keywords are classified as lint errors #1546

Open
Drew-Kimberly opened this issue May 3, 2024 · 5 comments
Open
Labels
p2 Type: Bug Something isn't working

Comments

@Drew-Kimberly
Copy link

Describe the bug
For OAS 3.1, arbitrary keywords within schemas produce lint errors. This contradicts the 3.1 specification.

To Reproduce
Using minimal, this example spec from OpenAPI fails linting when it should pass.

Expected behavior

The spec should pass linting.

Logs

message: 'Property `myArbitraryKeyword` is not expected here.',

OpenAPI description

3.1

Redocly Version(s)

@redocly/openapi-core@1.12.0

@Drew-Kimberly Drew-Kimberly added the Type: Bug Something isn't working label May 3, 2024
@tatomyr
Copy link
Contributor

tatomyr commented May 3, 2024

Interesting. I didn't know arbitrary keys are allowed in Schema Objects. Could you share where exactly in the specification this is mentioned?
Anyway, I'm not sure if it makes sense to allow arbitrary properties in the Schema Object when linting OAS descriptions, as it makes it harder to detect typos and other mistakes.

@Drew-Kimberly
Copy link
Author

@tatomyr Thanks for the quick response! Here's the ref from the spec.

Typos would still be detected in most cases since schema definitions would be missing required properties. Obviously my preference here is that ReDocly strictly adheres to the specification by default 🙏 (rules can always toggle certain behaviors)

@tatomyr
Copy link
Contributor

tatomyr commented May 7, 2024

Thanks for the link @Drew-Kimberly!

I'm still not sure if we want to change the behaviour. Let's wait until we get more votes for that.

Meanwhile, you can tweak the behaviour by supplying the type extension via a plugin. I understand it won't change the default settings but most users don't need those additional keys (or they can use specification extensions instead; BTW, could the specification extension cover your case?).

@MorelSerge
Copy link

MorelSerge commented Jul 15, 2024

This is currently breaking for mere on a property that has a nullable defined:

"confirmedAt": {
  "type": "string",
  "description": "something something",
  "nullable": true,
  "example": "2024-07-01T14:00:00Z"
}

@lornajane
Copy link
Contributor

I am not in support of changing the default behaviour because I think it works well for the majority but I can see the point that these are valid descriptions. The approach of using type extensions (especially if you use a few known keywords) is a very good workaround in the short term. However we should figure out a way to add a rule that relaxes these checks, so users can easily choose the behaviour that's right for them.

@MorelSerge thanks for the example, since nullable is a 3.0 feature, the linter will flag it if you use it in OpenAPI 3.1 descriptions. Again, you can use a type extension to work around this for now while we look at the options.

@lornajane lornajane added the p2 label Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2 Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants