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

Referenced parameters are converted incorrectly #17

Open
hkosova opened this issue Sep 13, 2017 · 1 comment
Open

Referenced parameters are converted incorrectly #17

hkosova opened this issue Sep 13, 2017 · 1 comment

Comments

@hkosova
Copy link

hkosova commented Sep 13, 2017

Spec: https://gist.githubusercontent.com/hkosova/49dc5ed081cf553e01a1182e11b2e4ca/raw/5ea6988984bd8a0c0b3a506ac13b9dac396a74bc/param-ref.yaml

swagger: '2.0'
info:
  version: '1.0'
  title: Parameter references

paths:
  /report/{userId}:
    get:
      parameters:
        - $ref: '#/parameters/userIdParam'
        - $ref: '#/parameters/dateRangeParam'
      responses:
        200:
          description: OK
  /formPost:
    post:
      consumes:
        - application/x-www-form-urlencoded
      parameters:
        - $ref: '#/parameters/formEmail'
        - $ref: '#/parameters/formPassword'
      responses:
        200:
          description: OK
  /bodyPost:
    post:
      consumes:
        - application/json
      parameters:
        - $ref: '#/parameters/bodyParam'
      responses:
        200:
          description: OK

parameters:
  dateRangeParam:
    in: query
    name: dateRange
    type: string
    enum:
      - Today
      - Yesterday
      - LastWeek
    default: Today
  userIdParam:
    in: path
    name: userId
    type: integer
    required: true

  formEmail:
    in: formData
    name: email
    type: string
    format: email
    required: true
  formPassword:
    in: formData
    name: password
    type: string
    format: password
    required: true
  
  bodyParam:
    in: body
    name: body
    required: true
    schema:
      type: object
      properties:
        status:
          type: string
      required:
        - status

Problems:

  1. Parameter $refs are converted to:
      parameters:
        - schema:
            $ref: '#/parameters/userIdParam'
        - schema:
            $ref: '#/parameters/dateRangeParam'

Should be:

      parameters:
        - $ref: '#/components/schemas/userIdParam'
        - $ref: '#/components/schemas/dateRangeParam'
  1. Form and body parameters are converted in the same way as query/path parameters, but should be converted to requestBody instead.
@webron
Copy link
Contributor

webron commented Sep 14, 2017

Fixed:

  • Parameters reference components now.
  • Top level body and formData parameters are converted to request bodies.

Not fixed:

  • Path level formData and body parameters are not converted.
  • References to top-level body/formData parameters reference #/components/parameters instead of #/components/requestBodies.

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

No branches or pull requests

2 participants