Repository navigation
Parameter only for POST #2865
|
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. 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 |
Answered by
webron
Jan 26, 2022
Replies: 2 comments 1 reply
|
JSON Schema doesn't quite allow you to pick and choose which properties you want to use from a given schema definition.
|
1 reply
Answer selected by
DenisFerrero
|
Answer accepted by OP, closing. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
JSON Schema doesn't quite allow you to pick and choose which properties you want to use from a given schema definition.
You have two options:
userinto two schemas, where one usesallOfthe other and adds theinviteCodeuserschema for both, but in the case of put make it a combination ofallOfandnotto remove support forinviteCode