API Studio making parameter required for specific REST calls

Not applicable

I have this YAML: http://playground.apistudio.io/6e0d3dca-4c4f-4c41-865c-b27eb39820f4/#/

It is consuming a public API, for tests.

In my definitions block I have Posts

Posts:
    properties:
      userId:
        type: integer
      title:
        type: string
      body:
        type: string	

None of the properties are required by default by I want to make them required when creating a new post on #26.

Is it possible to specify the required parameters when using a schema?

I have tried this:

    post:
      description: Criar um novo post
      parameters:
        - name: post
          in: body
          schema:
            "$ref": "#/definitions/Posts"

	required:
		- userId
			- title
		- body

I am trying to do that because in my PUT method, none of the fields are required, only the ones sent will be updated.

Thanks a lot!

0 2 448
2 REPLIES 2

Not applicable

It just occurred to me the following....

I leave the definition Post with all required fields and in the PUT method I remove the required: true.

Is that the best/correct way of solving this?

HI @danielgerep

I just made the changes to the spec. Included required fields to the definition "Posts"

required:
      - userId
      - title
      - body

If you use the "Try this Operation" on the right pane, you will see that UI shows that those fields are mandatory.

3854-screen-shot-2016-10-31-at-122302-pm.png