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

Impossible to construct a SchemaLocation containing a json pointer with an escaped fragment #1036

Closed
Mahoney opened this issue May 3, 2024 · 0 comments · Fixed by #1038
Closed

Comments

@Mahoney
Copy link

Mahoney commented May 3, 2024

It's common to have json pointers including a / in a segment in OpenAPI, because OpenAPI uses both paths and content types as keys.

/ is escaped as ~1 in Json Pointer - so for instance in the json pointer /paths/~users/post/requestBody/application~1json/schema the unescaped segments are paths, /users, post, requestBody, application/json and schema.

It is not possible to construct a SchemaLocation from this valid json pointer.

The following test fails:

@Test
void handlesEscapedJsonPointer() {
    assertEquals("#/application~1json", SchemaLocation.of("#/application~1json").toString());
}
Expected :#/application~1json
Actual   :#/application~01json

Because the following test fails:

@Test
void handlesEscapedJsonPointer() {
    assertEquals("/application~1json", SchemaLocation.Fragment.of("/application~1json").toString());
}
Expected :/application~1json
Actual   :/application~01json
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