Skip to content

Parameter only for POST #2864

@DenisFerrero

Description

@DenisFerrero

I have a schema that I would like to use for both POST and PUT methods but a target parameter is allowed only for the POST request.

To make it clear let's imagine that there is a possibility to create and update a user.
At the POST it's required the name and the inviteCode, then for the PUT just the name and don't allow to edit the inviteCode anymore

components:
  schemas:
    user:
      type: object
      properties:
        name:
          type: string
        inviteCode:
          type: string
paths:
  "/user":
    post:
      requestBody:
        content:
          application/json:
            schema:
              "$ref": "#/components/schemas/user"
  "/user/{id}":
    put:
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      requestBody:
        content:
          application/json:
            schema:
              "$ref": "#/components/schemas/user"

Is there a way to do it by just adding a parameter to the inviteCode?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions