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

Error when using $ref for components/parameters #58

Open
cvgaviao opened this issue Mar 12, 2019 · 6 comments
Open

Error when using $ref for components/parameters #58

cvgaviao opened this issue Mar 12, 2019 · 6 comments
Labels

Comments

@cvgaviao
Copy link

cvgaviao commented Mar 12, 2019

I was generating maven java OpenAPI Server project properly while evolving my openapi model.
But when I moved some parameters to components/parameters and referenced them inside paths I started to get errors on the generation.
See the example below. It contains 2 parameters.

  /mycollection:
    get:
      operationId: listCollection
      parameters:
        - $ref: '#/components/parameters/some-ID'
        - name: orderBy
          required: false
          in: query
          schema:
            type: array
            items:
              type: string

When I let only orderBy parameter the generation is ok. But if I use the reference I got the error:
Exception during code generatione is undefined TypeError: e is undefined

@cvgaviao
Copy link
Author

I have used the online swagger-parser tool (https://apidevtools.org/swagger-parser/online/#) to test using the same api file. No error.
So the problem is not in the parsing ....

@slinkydeveloper
Copy link
Collaborator

I need to check it, can you provide a simple reproducer?

@cvgaviao
Copy link
Author

cvgaviao commented Mar 12, 2019

I cut a model that reproduce the error:

openapi: 3.0.0
info:
  version: 1.0.0
  title: Location API
servers:
- url: 'http:localhost:8080'

paths:
  /locations/countries:
    get:
      description: A list of countries
      operationId: listCountries

      parameters:
      - $ref: '#/components/parameters/Param_Query_OrderBy'
      - $ref: '#/components/parameters/Param_Query_Limit'
      responses:
        '200':
          $ref: '#/components/responses/200_OK_CountriesList'
          

components:
      
  responses:
    200_OK_CountriesList:
      description: Created
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CountriesList'
          examples:
            An country list ordered by code in descending:
              value: {
                }
      
      
  parameters:
      
    Param_Query_Limit:
      description: The max number of items to retrieve. Default is 20, maximum is 100.
      name: limit
      in: query
      required: false
      schema:
        type: integer
        format: int32
        minimum: 1
        maximum: 100
        default: 20

    Param_Query_OrderBy:
      description: Allows to specify the sort order of the returned collection. 
      name: orderBy
      required: false
      in: query
      schema:
        type: array
        items:
          type: string

  schemas:
    CountriesList:
      type: array
      items:
        $ref: '#/components/schemas/Country'

    Country:
      type: object
      required:
        - code
        - name
      properties:
        code:
          type: string
        name:
          type: string

@slinkydeveloper
Copy link
Collaborator

Thank you 😄

@cvgaviao
Copy link
Author

cvgaviao commented Apr 2, 2019

Hello @slinkydeveloper , have you reproduced the error ?

@slinkydeveloper
Copy link
Collaborator

Sorry I had not enough time to work on it, i fix it asap

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

No branches or pull requests

2 participants