Skip to content

SwaggerEditor@next: unescaped autocompletion of references #3628

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

Closed
char0n opened this issue Nov 8, 2022 · 2 comments
Closed

SwaggerEditor@next: unescaped autocompletion of references #3628

char0n opened this issue Nov 8, 2022 · 2 comments

Comments

@char0n
Copy link
Member

char0n commented Nov 8, 2022

Q&A (please complete the following information)

Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.1.0
info:
  title: deref
  version: 1.0.0
servers:
  - description: local
    url: http://localhost:8082/
paths:
  /path/segment1/segment2:
    get:
      operationId: aget
    post:
      operationId: apost
components:
  pathItems: 
    pathItem1:
      $ref: '#/paths//path/segment1/segment2'

Describe the bug you're encountering

When autocompletion of components.pathItems.pathItem1.$ref is performed, the '#/paths//path/segment1/segment2' will be suggested and inserted. That's incorrect, because the text should be inserted in JSON Pointer encoded form: '#/~1paths~1path~1segment1~1segment2'.

NOTE: also notice that there are two un-escaped backslashes instead of one: '#/paths//path/segment1/segment2'

To reproduce...

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

Suggestion shows unescaped form of the future inserted text, but the insertion will insert properly JSON Pointer encoded text.

Screenshots

image

Additional context

Note that apidom-json-pointer package contains all the tooling needed to implement this fix: https://github.com/swagger-api/apidom/blob/main/packages/apidom-json-pointer/README.md#escaping

@ponelat
Copy link
Contributor

ponelat commented Jul 5, 2023

Ran into this as well for $ref inside of a Webhook.
image

Both the suggestion and the completion have an unescaped / which also resolves (i.e., works even though it should not).
Expected: #/paths/~1foo/ got #/paths//foo.

Update: If I manually type out the $ref it does not resolve!
image

@frantuma
Copy link
Member

fixed in swagger-api/apidom#2975

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

No branches or pull requests

3 participants