readmeio/swagger-inline

swagger-inline does not parse property 'scope'

giovanni9793 opened this issue · 5 comments

Hi, I noticed that swagger-inline does not parse the property scope, for example in this piece of definition (written in a Typescript file)

/{par1}/path/{par2}/scope:
   put:
      description: description
      operationId: operation
      parameters:
      - $ref: '#/components/parameters/par1'
      - $ref: '#/components/parameters/par2'
      requestBody:
         required: true
         content:
            application/json:
               schema:
               type: object
               required:
                  - par3
               properties:
                  par3:
                     type: array
                     items:
                        type: object
                     required:
                        - prop1
                        - prop2
                        - prop3
                     properties:
                        prop1:
                           type: string
                        prop2:
                           type: string
                        prop3:
                           type: string
                        scope:
                           type: array
                           items:
                              type: string
                     additionalProperties: false
               additionalProperties: false
components:
  parameters:
    par1:
      name: par1
      in: path
      required: true
      description: description
      schema:
        type: string
    par2:
      name: par2
      in: path
      required: true
      description: description
      schema:
        type: string

I receive the following error:

An error occured:
Error: YAMLException: duplicated mapping key (33:22)

 30 |                      type: string
 31 |                    prop3:
 32 |                      type: string
 33 |                      type: array
---------------------------^
 34 |                      items:
 35 |                        type: string 
 at ./src/path/file.ts
    at /home/user/package/node_modules/swagger-inline/src/index.js:99:39
    at Array.map (<anonymous>)
    at /home/user/package/node_modules/swagger-inline/src/index.js:83:27

As you can see, the line of property 'scope' is not present. I tried validators and prettifiers, but the result is that the yaml is valid, so it's a bug or an expected behaviour? If I change the name of the property (for example from 'scope' to 'scope1'), all go well, but I'm implemented an RFC, so I can't change the name of the property.

Some updates? @erunion

@giovanni9793 Looks like the error is coming from the client_id property, not scope and is because you have a duplicate type declaration there.

The client_id is prop3 in the definition written above, just edited the error for clarity

Resolved in 0d1d537 and published to v4.2.2.

Great find and sorry about that! The scope stuff didn't have any tests before but does now. 😬

Great, thank you :)