Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support the "readOnly" and "writeOnly" attribute #49

Open
mefellows opened this issue Oct 25, 2023 · 2 comments
Open

Support the "readOnly" and "writeOnly" attribute #49

mefellows opened this issue Oct 25, 2023 · 2 comments
Labels
enhancement New feature or request smartbear-supported Issues with this label have been added to the Pactflow team's Jira backlog

Comments

@mefellows
Copy link
Contributor

mefellows commented Oct 25, 2023

From https://swagger.io/specification/v3/?sbsearch=readOnly

Relevant only for Schema "properties" definitions. Declares the property as "read only". This means that it MAY be sent as part of a response but SHOULD NOT be sent as part of the request. If the property is marked as readOnly being true and is in the required list, the required will take effect on the response only. A property MUST NOT be marked as both readOnly and writeOnly being true. Default value is false.

That is, attributes marked as "readOnly" in a shared model between request and response bodies should only be part of the response, writeOnly attributes should only be part of the request body.

The validator currently does not consider these attributes, which makes it hard to re-use models on the request and response.

Given this model:

bb9214c9-c137-461d-80ea-2c7c722b194c

An error will show if the created_at property is not in the request, despite it being a read-only property:

758e889c-224e-458f-aa44-7d20987c1237

Workaround

The workaround is to separate request and response schemas, perhaps using other composition capabilities of JSON schema.

@mefellows mefellows added enhancement New feature or request smartbear-supported Issues with this label have been added to the Pactflow team's Jira backlog labels Oct 25, 2023
@github-actions
Copy link
Contributor

👋 Hi! The 'smartbear-supported' label has just been added to this issue, which will create an internal tracking ticket in PactFlow's Jira (PACT-1435). We will use this to prioritise and assign a team member to this task. All activity will be public on this ticket. For now, sit tight and we'll update this ticket once we have more information on the next steps.

See our documentation for more information.

@mefellows
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request smartbear-supported Issues with this label have been added to the Pactflow team's Jira backlog
Projects
None yet
Development

No branches or pull requests

1 participant