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

URL-encoding for operationRef #1677

Closed
Alan-Cha opened this issue Aug 27, 2018 · 6 comments
Closed

URL-encoding for operationRef #1677

Alan-Cha opened this issue Aug 27, 2018 · 6 comments
Assignees
Labels
bug examples requests for more or better examples in the specification
Milestone

Comments

@Alan-Cha
Copy link

Alan-Cha commented Aug 27, 2018

I was under the impression that operationRef does not need URL-encoding.

For example, in the following snippit taken directly from the link object documentation...

links:
  UserRepositories:
    # returns array of '#/components/schemas/repository'
    operationRef: '#/paths/~12.0~1repositories~1{username}/get'
    parameters:
      username: $response.body#/username

... { and } are not encoded, i.e. replaced with %7B and %7D, like in the following:

links:
  UserRepositories:
    # returns array of '#/components/schemas/repository'
    operationRef: '#/paths/~12.0~1repositories~1%7Busername%7D/get'
    parameters:
      username: $response.body#/username

However, after talking to a developer of an OAS validator, I am doubtful... I was told that because operationRef is defined as a reference in the OAS, it needs URL-encoding.

Here is the link to the discussion. The last two exchanges are most important to this topic.

Could you clarify if operationRef needs URL-encoding?

@darrelmiller
Copy link
Member

The operationRef is a fragment identifier and we need to investigate if curly braces require escaping in that portion of a URL. Some of us think they don't but we will confirm.

Change initial description of OperationRef to "A relative or absolute URI reference to an OAS operation. "

It would be useful to add comments as to how this is different than a regular JSON Reference.

@darrelmiller
Copy link
Member

According to RFC 3986,

fragment    = *( pchar / "/" / "?" )
pchar         = unreserved / pct-encoded / sub-delims / ":" / "@"
unreserved  = ALPHA / DIGIT / "-" / "." / "_" / "~"
sub-delims  = "!" / "$" / "&" / "'" / "(" / ")"/ "*" / "+" / "," / ";" / "="

This means the only way a curly brace can exist in a fragment is if it is percent-encoded. That makes me sad.

@MikeRalphson
Copy link
Member

@darrelmiller Thanks for clarifying. Do we also need to update the examples?

@jeffory-orrok
Copy link

Hi, I just went to https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#operationref-examples and there are still literal curly braces in the first two code blocks, so I was wondering whether a decision was made to relax the JSON Reference syntax requirement?

@handrews
Copy link
Member

@jeffory-orrok oof. Thanks, this needs fixing in 3.0.4 and 3.1.1.

@lornajane
Copy link
Contributor

Fixed by @handrews in #3731, #3747 and #3748 so I'll resolve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug examples requests for more or better examples in the specification
Projects
None yet
Development

No branches or pull requests

6 participants