简体   繁体   中英

Swagger Server Node JS + Post with integer and/or null

I am trying to develop a server on Node.js. There is a POST request where I need to send a value for grade , this value can be an integer or null . I tried any type of ways, but no success.

Here is my API definition:

swagger: "2.0"
paths:
  /credits/operations:
    post:
      operationId: "creditsOperationsPOST"
      parameters:
        - in: "body"
          name: "credito"
          required: false
          schema:
            $ref: "#/definitions/credito"
      responses:
        200:
          description: "Created"
      x-swagger-router-controller: "Credits"

definitions:
  credito:
    type: "object"
    properties:
      sgecode:
        type: "string"
      grade:
        type: "integer"
        x-nullable: true

Can someone help me please?

I found a way to use null and integer. On the YAML file, I added this

grade:
    type: ["integer","null"]

and works well for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM