Search code examples
node.jsswaggerswagger-uiswagger-2.0

swagger post body without schema


I am using node-swagger. It's working fine. I want to post json body without defining the schema in details. For example below I don't want to specify object properties. Is there any way to do this?

/pets:
 post:
 description: Add new
 parameters:
  - name: id
   in: body
   description: data to post
   required: true
   type: object
 responses:
  '200':
    description: A list of pets
    schema:
      type : string

It's not rendering the textarea to post json data.


Solution

  • Try this YAML:

    ---
    swagger: '2.0'
    info:
      version: 0.0.0
      title: Simple API
    paths:
      /:
        post:
          produces:
            - application/json
          parameters:
            - in: body
              name: id
              required: true
              schema: 
                "$ref": "#/definitions/inBody"
          responses:
            201:
              description: Added
    definitions:
      inBody:
        type: object