pyeve / eve-swagger

Swagger extension for Eve-powered RESTful APIs
http://python-eve.org
Other
154 stars 43 forks source link

Swagged Editor reports error on generated JSON #62

Closed samsantiago closed 5 years ago

samsantiago commented 6 years ago

Swagger Online Editor, http://editor2.swagger.io generates error on JSON generated.

Swagger Error Not a valid parameter definition

Jump to line 616 Details Object code: "ONE_OF_MISSING" params: Array [0] message: "Not a valid parameter definition" path: Array [2] 0: "parameters" 1: "business__id" schemaId: "http://swagger.io/v2/schema.json#" inner: Array [2] 0: Object code: "OBJECT_MISSING_REQUIRED_PROPERTY" params: Array [1] message: "Missing required property: schema" path: Array [2] 0: "parameters" 1: "business__id" 1: Object code: "ONE_OF_MISSING" params: Array [0] message: "Data does not match any schemas from 'oneOf'" path: Array [2] inner: Array [4] level: 900 type: "Swagger Error"

Line 616 is in the "parameters:" definition area. Each parameter defined generated same error.

business__id: in: path name: businessId required: true description: '' example: '' type: string format: objectid

business__id is referenced in this path definition and the parameter line is flagged with same error:

patch: summary: Updates a business document responses: '200': description: business document updated successfully parameters:

ghost commented 6 years ago

comment string 84 and 117 in objects.py:

  # example = rd['schema'][lookup_field].get('example') or ''
  ...
  # p['example'] = example
samuelhnrq commented 5 years ago

I found out, that the path parameters need to be defined at the path level, not at the individual methods. Instead of

  '/desenho/{desenhoId}':
    put:
      summary: Replaces a Desenho document
      responses:
        '200':
          description: Desenho document replaced successfully
      parameters:
        - $ref: '#/parameters/Desenho__id' # <------- NOT HERE!!!
        - in: body
          name: Desenho
          required: true
          schema:
            $ref: '#/definitions/Desenho'

this:

  '/desenho/{desenhoId}':
    parameters:
      - $ref: '#/parameters/Desenho__id' # <------- HERE INSTEAD
    put:
      summary: Replaces a Desenho document
      responses:
        '200':
          description: Desenho document replaced successfully
      parameters:
        - in: body
          name: Desenho
          required: true
          schema:
            $ref: '#/definitions/Desenho'

But I really believe this is a issue with eve-swagger itself right? Necroposting intensifies.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.