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

Hard-coded query parameters are wrongly extracted as path parameters #24

Open
MikeRalphson opened this issue Jun 28, 2017 · 4 comments
Open

Comments

@MikeRalphson
Copy link

Given the following from http://docs.icons8.apiary.io/api-description-document

# Search [/api/iconsets]

## By Keyword [GET /api/iconsets/v3/search?term={term}&amout={amount}&offset={offset}&platform={platform}&language={language}]

+ Parameters
    + term: `home` (string, required) - the name or tag of the icon or any other phrase.
        e.g. use "@home" to find icons with the tag "home" and "=home" to find icons with the name "home"
    + amount (number, optional) - the maximum number of icons which you'd like to receive
        + Default: 25
    + offset (number, optional) - the offset from the first received result
        + Default: 0
    + platform (enum[string], optional) - the style of the icons
        + Default: `all`
        + Members
            + `all`
            + `ios7`
            + `win8`
            + `win10`
            + `android`
            + `androidL`
            + `color`
            + `office`
    + language: `en-US` (enum[string], required) - the language code to get localized result
        + Members
            + `en-US`
            + `fr-FR`
            + `de-DE`
            + `it-IT`
            + `pt-BR`
            + `pl-PL`
            + `ru-RU`
            + `es-ES`

The generated swagger looks like:

  '/api/iconsets/v3/search?term={term}&amout={amount}&offset={offset}&platform={platform}&language={language}':
    get:
      description: ''
      parameters:
        - description: |
            the name or tag of the icon or any other phrase.
            e.g. use "@home" to find icons with the tag "home" and "=home" to find icons with the name "home"
          in: path
          name: term
          required: true
          type: string
        - default: 25
          description: the maximum number of icons which you'd like to receive
          in: path
          name: amount
          required: true
          type: number
        - description: the offset from the first received result
          in: path
          name: offset
          required: true
          type: number
        - default: all
          description: the style of the icons
          enum:
            - all
            - ios7
            - win8
            - win10
            - android
            - androidL
            - color
            - office
          in: path
          name: platform
          required: true
          type: string
        - description: the language code to get localized result
          enum:
            - en-US
            - fr-FR
            - de-DE
            - it-IT
            - pt-BR
            - pl-PL
            - ru-RU
            - es-ES
          in: path
          name: language
          required: true
          type: string

Whereas I would expect something like:

  '/api/iconsets/v3/search':
    get:
      description: ''
      parameters:
        - description: |
            the name or tag of the icon or any other phrase.
            e.g. use "@home" to find icons with the tag "home" and "=home" to find icons with the name "home"
          in: query
          name: term
          required: true
          type: string
        - default: 25
          description: the maximum number of icons which you'd like to receive
          in: query
          name: amount
          required: true
          type: number
        - description: the offset from the first received result
          in: query
          name: offset
          required: true
          type: number
        - default: all
          description: the style of the icons
          enum:
            - all
            - ios7
            - win8
            - win10
            - android
            - androidL
            - color
            - office
          in: query
          name: platform
          required: true
          type: string
        - description: the language code to get localized result
          enum:
            - en-US
            - fr-FR
            - de-DE
            - it-IT
            - pt-BR
            - pl-PL
            - ru-RU
            - es-ES
          in: query
          name: language
          required: true
          type: string
@kminami
Copy link
Owner

kminami commented Jun 28, 2017

@MikeRalphson
Copy link
Author

I may be reading the API Blueprint spec wrongly, but it seems to specify

To define variables for a form-style query use the question mark (?) operator

@kminami
Copy link
Owner

kminami commented Jun 28, 2017

To indicate a form-style parameter, you should add the question mark (?) operator IN a variable expression, I think.

https://tools.ietf.org/html/rfc6570#section-1.1

   For example, the following URI Template includes a form-style
   parameter expression, as indicated by the "?" operator appearing
   before the variable names.
    http://www.example.com/foo{?query,number}

@MikeRalphson
Copy link
Author

@visualpharm do you agree, the parameter definitions in the API Blueprint definition may not be correct?

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