You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a scenario where when I create an entity using a POST I need to have several required fields. However when I update it those fields may no longer be required (as I will have already used them) and as such they become optional.
My question then is that given the schema for the object is the same and I want to use a reference, how can I set properties of that referred schema to be required at the point of the action for the path.
EG (snippet)
swagger: '2.0'info:
version: "01"host: localhostbasePath: /api/v1paths:
/user:
post:
description: Creates a new `User` entity, duplicates are not allowedparameters:
- name: requestin: bodyrequired: trueschema:
type: objectrequired:
- user // this makes the user object required and inherits the reqs for the User referenceproperties:
user:
$ref: '#/definitions/User'put:
description: Updates a `User` given the appropriate `uuid`parameters:
- name: uuidin: headerdescription: UUID of the `User` to requestrequired: truetype: string
- name: requestin: bodyschema:
$ref: '#/definitions/User'definitions:
User:
type: objectdescription: | A `User` object describes a user entity.properties:
email:
type: stringdescription: Must be email validfirst_name:
type: stringlast_name:
type: stringcreated_at:
type: stringformat: date-time
I have a scenario where when I create an entity using a POST I need to have several required fields. However when I update it those fields may no longer be required (as I will have already used them) and as such they become optional.
My question then is that given the schema for the object is the same and I want to use a reference, how can I set properties of that referred schema to be required at the point of the action for the path.
EG (snippet)
What I want to be able to do is say in here:
For example so that the required aspect of this is set to the properties of the referenced object
Hopefully that makes sense and there's a way to do this?
The text was updated successfully, but these errors were encountered: