speccy icon indicating copy to clipboard operation
speccy copied to clipboard

Reference path change after Resolve

Open lagonnebula opened this issue 5 years ago • 1 comments

Detailed description

When i put two of the same reference, the first one keep the current path, but the second change is path to the first one.

This is related to #315 , but i tried the solution of the issue but it's keep doing it

Example

I am using multiple files for this The output after the resolve is this:

components:
    parameters:
        Include:
            in: query
            name: include
            schema:
                type: array
                items:
                    type: string
paths:
    /route1:
        get:
          parameters:
            - $ref: "#/components/parameters/Include"
    /route2:
        get:
          parameters:
            - $ref: "#/paths/~1route1/get/parameters/0"

But in the yaml before the resolve I have this:

Components and paths are in different file

parameters.yml
Include:
    $ref: ./parameters/include.yml
parameters/include.yml
in: query
name: include
schema:
       type: array
       items:
            type: string
paths.yml
/route1:
     get:
          parameters:
              - $ref: '#components/parameters/Include'
/route2:
    get:
          parameters:
              - $ref: '#components/parameters/Include'
index.yml
components:
    parameters:
        $ref: './parameters.yml'
paths:
    $ref: './paths.yml'

Question

Why the reference become : "#/paths/~1route1/get/parameters/0" instead of keeping "#/components/parameters/Include" ? This ref is causing an issue on some swagger plugin because he can't resolve the "#/paths/~1route1/get/parameters/0" reference

Your environment

  • Node Version: 11.0.0
  • MacOS
  • Speccy 0.10.1

lagonnebula avatar Jun 07 '19 08:06 lagonnebula

I have very similar problem.

main.yaml

paths: 
  /path:
    $ref: './public/path.yaml'
  /path2:
    $ref:'./public/path2.yaml'
components: 
  responses:
    NotFound:
       $ref:'./responses/NotFound.yaml'
path.yaml

get:
  operationId: get1
  responses:
    404:
      $ref: '../main.yaml#/components/responses/NotFound'
path2.yaml

get:
  operationId: get2
  responses:
    404:
      $ref: '../main.yaml#/components/responses/NotFound'
NotFound.yaml

description: Not Found
result.yaml

paths: 
  /path:
    get:
      operationId: get1
      responses:
         404:
           $ref: '#/components/responses/NotFound'
  /path2:
    get:
      operationId: get2
      responses:
         404:
           $ref: '#/~1path/get/responses/404'

@lagonnebula did you find a workaround?

Lifree avatar Oct 09 '20 13:10 Lifree