Path parameter sent, body parameter is empty

30 views
Skip to first unread message

Patryk Wlaź

unread,
Oct 22, 2016, 7:36:54 AM10/22/16
to Swagger
Hello, I,m using swagger with node.js and express. Set project up as in quick start for swagger-express-mw. I got following in yaml file (its a part of it ofc):
/users/{id}/movies:
    x-swagger-router-controller: movies
    get:
      description: Returns users movies to the caller
      operationId: getGallery
      parameters:
        - name: id
          type: integer
          in: path
          required: true
          description: id of user
        - name: moviesSelection
          in: body
          required: true
          description: object describing what movies are requested
          schema:
            $ref: '#/definitions/MoviesSelection'
      responses:
        "200":
          description: Success
          schema:
            $ref: "#/definitions/GetMoviesResponse"
        default:
          description: Error
          schema:
            $ref: "#/definitions/ErrorResponse"
#later:
definitions:
      
  MoviesSelection:
    description: object describing what movies are requested
    properties:
      onlyFavs:
        type: boolean
        description: are only favourite movies requested
      sort:
        type: string
        description: property that should become sorting key
      skip:
        type: string
        description: how many movies should be skipped (pagination)
      limit:
        type: integer
        description: how many movies should be returned (pagination)
    required:
      - onlyFavs
      - sort
      - skip
      - limit

First problem is swagger crying about missing required property when setting onlyFavs to false. But ok, lets set it to true.
Now second problem is swagger erroring with Bad request. Ok I'm tired, so lets try removing 'required' part from MoviesSelection definition.
Now third problem is this: call is made, but req.swagger.params.moviesSelection.value = {} (so every property on this object is undefined). In the same time req.swagger.params.id.value is set to proper integer.
Please tell me what am I doing wrong. Thanks.

Reply all
Reply to author
Forward
0 new messages