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

fix(rulesets): variable not supported in server url within OAS 3.1 #1914

Merged
merged 2 commits into from
Oct 25, 2021

Conversation

P0lip
Copy link
Contributor

@P0lip P0lip commented Oct 24, 2021

Fixes #1911

Checklist

  • Tests added / updated
  • Docs added / updated

Does this PR introduce a breaking change?

  • Yes
  • No

Additional context

I treated this issue as an opportunity to pull the latest JSON Schema definition for OAS 3.1.
That being said, a few manual changes have been applied:

  • $dynamicRef -> $ref cause Ajv doesn't like it. The former definition has the same transformation applied.
  • fixed a typo in descriptions - should be description
  • the url property in schema had still an invalid type - they changed uri to uri-reference, but it's uri-template.

@P0lip P0lip added the t/bug Something isn't working label Oct 24, 2021
@P0lip P0lip self-assigned this Oct 24, 2021
@@ -138,7 +140,8 @@
"type": "object",
"properties": {
"url": {
"$ref": "#/$defs/uri"
"type": "string",
"format": "uri-template"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the original schema has uri-reference here.

@@ -167,7 +170,7 @@
"default": {
"type": "string"
},
"descriptions": {
"description": {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@P0lip P0lip force-pushed the fix/rulesets/oas-schema-server-url branch from a8f5bf8 to 23cb15b Compare October 24, 2021 14:24
@P0lip P0lip marked this pull request as ready for review October 24, 2021 14:24
@P0lip P0lip enabled auto-merge (squash) October 24, 2021 14:25
@P0lip P0lip requested a review from a team October 24, 2021 14:31
Copy link
Contributor

@marbemac marbemac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks OK - more just questions for my own edification on the changes to the schema.

@@ -840,45 +856,42 @@
"default": false,
"type": "boolean"
},
"allowEmptyValue": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 where did this go? And why didn't header have schema or content before?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is for Header Object, and allowEmptyValue is not a valid trait since it only applies to query parameters and Header Object has to follow "header"

All traits that are affected by the location MUST be applicable to a location of header (for example, style).

https://spec.openapis.org/oas/v3.1.0#parameter-object

image

},
"explode": {
"default": false,
"type": "boolean"
},
"allowReserved": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto - seems like a substantial change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as the other - it's a header object and allowReserved is applicable only to query parameters
image

@@ -909,7 +922,8 @@
"type": "object",
"properties": {
"$ref": {
"$ref": "#/$defs/uri"
"type": "string",
"format": "uri-reference"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting - why did some "#/$defs/uri" become uri (see towards top of file), and some uri-reference?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uri-reference means it can be a relative URI, like ../foo.json, while uri format enforces a well-formed absolute URI with the scheme and so on.

@@ -1003,7 +1017,8 @@
"const": "http"
},
"scheme": {
"const": "bearer"
"type": "string",
"pattern": "^[Bb][Ee][Aa][Rr][Ee][Rr]$"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ha

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha yeah, it's case insensitive 😆

@P0lip P0lip merged commit c4f6762 into develop Oct 25, 2021
@P0lip P0lip deleted the fix/rulesets/oas-schema-server-url branch October 25, 2021 08:25
stoplight-bot pushed a commit that referenced this pull request Oct 25, 2021
# [@stoplight/spectral-rulesets-v1.2.7](https://github.com/stoplightio/spectral/compare/@stoplight/spectral-rulesets-v1.2.6...@stoplight/spectral-rulesets-v1.2.7) (2021-10-25)

### Bug Fixes

* **rulesets:** exclusiveMinimum must be a number thrown for OAS 3.0 ([#1913](#1913)) ([65d287a](65d287a))
* **rulesets:** variable not supported in server url within OAS 3.1 ([#1914](#1914)) ([c4f6762](c4f6762))
@stoplight-bot
Copy link
Collaborator

🎉 This PR is included in version @stoplight/spectral-rulesets-v1.2.7 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released t/bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

variable not supported in server url within openapi 3.1.0
3 participants