0
swagger: "2.0"
info: 
  version: "1.0.0"
  title: "CCA API"
host: localhost:1337
basePath: /v1
schemes: 
  - http
consumes:
  - application/json
produces:
  - application/json
paths:
  /user/login:
    post:
      description: Access a user account
      summary: User Account Access
      operationId: loginAccount
      parameters:
      - name: email
        dataType: string
        in: body
        required: true
        description: Your email
      - name: password
        dataType: string
        in: body
        required: true
        description: Your password
      responses:
        "200":
          description: Successfully signed in
          schema:
            type: object
            properties:
              email:
                type: string
              firstName:
                type: string
              lastName:
                type: string
              token:
                type: string
              userType:
                type: string
        401:
          description: Invalid email or password.

Which is a correct way to write yaml file? I have this error: "Not a valid parameter definition" in each declaration of the parameters...

I would also like to know the correct way to integrate Sails JS with Swagger?

  • Possible duplicate of [Post a json body with swagger](https://stackoverflow.com/questions/35411628/post-a-json-body-with-swagger) and [How to describe this POST JSON request body in OpenAPI (Swagger)?](https://stackoverflow.com/q/31390806/113116). More info: [Describing Request Body](https://swagger.io/docs/specification/2-0/describing-request-body/) – Helen Jul 05 '18 at 08:43

2 Answers2

1

As Vantroys said dataType is not the correct key. It's type. But in this case you try to define an post method and need to define some type of input data, like in the example below. Have look at the pet store example from swagger itself: https://editor.swagger.io/

parameters:
  - in: "body"
    name: "body"
    description: "Pet object that needs to be added to the store"
    required: true
    schema:
      $ref: "#/definitions/Pet"
JWo
  • 650
  • 1
  • 6
  • 23
0

Concerning your parameters : I think you have to use "type", and not "dataType" :

parameters: - name: email

type: string
in: body
required: true
description: Your email

- name: password

type: string
in: body
required: true
description: Your password
  • You are correct about using `type` instead of `dataType`, but your example is still not the right way to describe JSON request body. It should be [a single body parameter with an object schema](https://stackoverflow.com/q/35411628/113116). – Helen Jul 06 '18 at 20:26