Swagger throws “Swagger Error Not a valid parameter definition”

989 views
Skip to first unread message

Benjamin SOULAS

unread,
Aug 8, 2016, 3:54:46 AM8/8/16
to Swagger
Hello people, I am trying to generate my own REST server in python Flask framework, actually I only have a GET method and a POST one.

But the POST method IS the problem about paramters which seems not to correspond to the YAML Syntax in Swagger. The idea, I need the template ID which is into the path and a config in a JSON parameter (is it in body? query? Maybe this is it the problem?).

Here is my .YAML file:

# Example YAML to get you started quickly.
# Be aware that YAML has indentation based scoping.
# Code completion support is available so start typing for available options.
swagger: '2.0'

# This is your document metadata
info:
  version: "0.0.0"
  title: <jitter api>

# Describe your paths here
paths:
  /v0/templates:
    get:
      description:
        Get the templates list
      produces:
        - application/json
      responses:
        "200":
          description: Successful response
          schema:
            title: ArrayOfTemplates
            type: array
            items:
              type: object
              properties:
                templateId:
                  type: string
                description:
                  type: string
  /v0/application/new/{templateId}:
    post:
      description: |
        Get the templates list
      consumes:
        - application/json
      produces:
        - application/json
      parameters:
        - name: templateId
          description: Template's Id
          required: true
          type: string
          paramType: path
        - name: config
          description: Config in which we will define the encoder's number do deploy
          required: true
          paramType: query
          type: object
          properties:
            encoders_count:
              type: integer
              format: int32
      responses:
        "200":
          description: Successful response
          schema:
            title: object of the app infos
            type: object
            items:
              type: object
              properties:
                appId:
                  type: string
                templateId:
                  type: string
                config:
                  type: object
                  properties:
                    encoders_count:
                      type: integer
                      format: int32

Tony Tam

unread,
Aug 8, 2016, 4:19:37 AM8/8/16
to swagger-sw...@googlegroups.com
Change "paramType" to "in" for starters. I suggest checking syntax with http://editor.swagger.io
--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Benjamin SOULAS

unread,
Aug 8, 2016, 4:52:37 AM8/8/16
to Swagger
Thanks, I forgot to say I work on this editor.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

Benjamin SOULAS

unread,
Aug 8, 2016, 4:57:24 AM8/8/16
to Swagger
Still the same problem, maybe I missunderstood the way to handle POST request? Here is a screenshot:
capture_swagger.png

Ron Ratovsky

unread,
Aug 8, 2016, 7:06:22 PM8/8/16
to swagger-sw...@googlegroups.com

You defined your query parameter as an object, but query parameters can only be primitives.

Only body parameters can

 

be objects.

--

You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

Benjamin SOULAS

unread,
Aug 10, 2016, 11:07:29 AM8/10/16
to Swagger
Hi Ron,

Yes I saw that later, if that could be useful for someone, here is my yaml file with the correct syntax:
      operationId: newApplication

      consumes:
        - application/json
      produces:
        - application/json
      parameters:
        - in: path
          name: templateId
          type: string
          required: true
        - in: body
          name: config
          required: true
          description: encoders needed to be implemented
          schema:
            $ref: '#/definitions/template'
      responses:
        "200":
          description: Successfull response

          schema:
            title: object of the app infos
            type: object
            items:
              type: object
              properties:
                appId:
                  type: string
                templateId:
                  type: string
                config:
                  type: object
                  properties:
                    encoders_count:
                      type: integer
                      format: int32
definitions:
  template:

    type: object
    properties:
      encoders_count:
        type: integer
        format: int32

Thank you very much !!!

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages