question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Semantic error at definitions.Response«Page«EnterpriseProfile»».properties.payLoad.$ref $ref values must be RFC3986-compliant percent-encoded URIs in swagger editor

See original GitHub issue

Till yesturday(5/22/2018) it was working fine.

now i am getting this error Semantic error at definitions.Response«Page«AppServerProfile»».properties.payLoad.$ref $ref values must be RFC3986-compliant percent-encoded URIs

can u help me. how to resolve this issue.

example yaml:

    - in: body
      name: appServerProfile
      description: appServerProfile
      required: true
      schema:
        $ref: '#/definitions/AppServerProfile'
  responses:
    '200':
      description: App Server Profile modified Successfully
      schema:
        **$ref: '#/definitions/Response«AppServerProfile»'**// here i am getting this errror
    '201':
      description: Created

thanks

Q&A (please complete the following information)

  • OS: [e.g. macOS]
  • Browser: [e.g. chrome, safari]
  • Version: [e.g. 22]
  • Method of installation: [e.g. npm, dist assets]
  • Swagger-Editor version: [e.g. 3.10.0]
  • Swagger/OpenAPI version: [e.g. Swagger 2.0, OpenAPI 3.0]

Content & configuration

Example Swagger/OpenAPI definition:

# your YAML here

Swagger-Editor configuration options:

SwaggerEditor({
  // your config options here
})
?yourQueryStringConfig

Describe the bug you’re encountering

To reproduce…

Steps to reproduce the behavior:

  1. Go to ‘…’
  2. Click on ‘…’
  3. Scroll down to ‘…’
  4. See error

Expected behavior

Screenshots

Additional context or thoughts

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

11reactions
hkosovacommented, May 23, 2018

@karunchinna The error is valid. #/foo/bar is a JSON Pointer, and according to the JSON Pointer Specification, special characters in key names must be percent-encoded when a JSON Pointer is used as an URL fragment[1] (as is the case with $refs). So you need to replace

$ref: '#/definitions/Response«AppServerProfile»'

with

$ref: '#/definitions/Response%C2%ABAppServerProfile%C2%BB'

By the way, if you will be migrating to OpenAPI 3.0, keep in mind that it only allows the characters a-z A-Z 0-9 . - _ in component names. So Response«AppServerProfile» is not a valid model name in OpenAPI 3.0.


[1] JSON Pointer Specification, section 6 (emphasis mine):

A JSON Pointer can be represented in a URI fragment identifier by encoding it into octets using UTF-8 [RFC3629], while percent-encoding those characters not allowed by the fragment rule in [RFC3986].

RFC3986, section 3.5:

fragment    = *( pchar / "/" / "?" )

where

pchar         = unreserved / pct-encoded / sub-delims / ":" / "@"
unreserved    = ALPHA / DIGIT / "-" / "." / "_" / "~"
pct-encoded   = "%" HEXDIG HEXDIG

and ALPHA = A-Z a-z, DIGIT = 0-9.

The characters « and » do not belong to the unreserved set, so they must be percent-encoded when used after the # character in URLs.

1reaction
protegesolutionscommented, Jun 4, 2018

@shockey @hkosova Also, if you make the recommended escaping change to the $ref values (in my case [ and ] to %5B and %5D respectively), you end up with broken client-side - and presumably, server-side - generated code:

    ApiCollection5BString5D AttachmentTags (); instead of ApiCollectionString AttachmentTags ();

    ApiCollection5BCustomFieldCategoryRead5D OpportunityCustomFieldCategories (); instead of ApiCollectionCustomFieldCategoryRead OpportunityCustomFieldCategories ();

This is because the generator removes the % but not the rest of the escape code: %5B -> 5B, %5D -> 5D, etc.

So, essentially, it’s now impossible to use Swagger Editor to generate - at least - C# client-side code and probably most of the rest of the code types.

Excellent, well-done!

Read more comments on GitHub >

github_iconTop Results From Across the Web

$ref values must be RFC3986-compliant percent-encoded ...
Issue is when I do use URL encoding, swagger is unable to recognize UpdateTestCustomerResponse reference(error is missing reference) and ...
Read more >
UISP Swagger 2.0 API Not Validating
user.get.responses.200.schema should NOT have additional properties ... ref $ref values must be RFC3986-compliant percent-encoded URIs Jump to line 6719 ...
Read more >
$ref values must be RFC3986-compliant percent-encoded ...
Hi team,. First, thanks for this amazing tool... Recently, we started the validation process of our APIs (version 2.0) using Swagger-Hub ...
Read more >
Generated Swagger.json Does Not Validate with ...
A OpenAPI-standards-compliant file is generated. No errors or warnings appear in the Swagger editor. The Swagger Editor generates code samples ...
Read more >
Parameters cannot have both a "in: body" and "in: formData ...
I'm using 5.1.0 to generate our API. A customer has tried to import the resulting openapi.json file into Swagger Editor and has come...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found