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

JsonReferenceResolver does not support paths containing '/' escaped with '~1' #1573

Open
ebuter9292 opened this issue Oct 31, 2022 · 0 comments · May be fixed by #1725
Open

JsonReferenceResolver does not support paths containing '/' escaped with '~1' #1573

ebuter9292 opened this issue Oct 31, 2022 · 0 comments · May be fixed by #1725

Comments

@ebuter9292
Copy link

ebuter9292 commented Oct 31, 2022

In JSON pointers, the characters '~' and '/' need to be encoded as '~0' and '~1' respectively, when used in a reference token.
(See RFC 6901

The JsonReferenceResolver currently does not seem to support this, as it throws a InvalidOperationException: Could not resolve the path.

An example: For referencing a path named "/pets/{petid}" you'd use "$ref": "#/paths/~1pets~1{petId}".

Included is a zip file containing a .NET 6 project using NSwag.ApiDescription.Client to demonstrate the problem. Using the included broken.json and working.json in an online validator such as apitools.dev results in both examples validating, while trying to use broken.json in NSwagStudio also results in above exception.

I have also included the broken json file separately, as broken.txt.
The problematic statement can be found on line 55, under paths/~1pets/get/responses/default
NSwagRefIssue.zip
broken.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant