-
-
Notifications
You must be signed in to change notification settings - Fork 50
Open
Labels
Description
Using the same schema for request and response with writeOnly + required fields causes validation failures.
openapi
openapi: 3.0.3
info:
title: Readonly writeonly test
version: 1.0.0
paths:
/users:
post:
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/User'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/User'
components:
schemas:
User:
type: object
properties:
id:
type: string
readOnly: true
name:
type: string
writeOnly: true
required: [name]
scenario
desc: OpenAPI readonly writeonly validation issue
runners:
api:
endpoint: http://localhost:8081
openapi3: openapi3.yml
steps:
- api:
/users:
post:
body:
application/json:
name: userName
test: current.res.status == 200error
Failure/Error: http request failed on "OpenAPI readonly writeonly validation issue".steps[0]: openapi3 validation error: Error: 200 response body for '/users' failed to validate schema, Reason: The response body for status code '200' is defined as an object. However, it does not meet the schema requirements of the specification, Validation Errors: [Reason: missing property 'name', Location: /required], Line: 24, Column: 7
Log
❯ runn run --scopes read:parent openapi_readonly_writeonly_issue.yml --debug
Run "api" on "OpenAPI readonly writeonly validation issue".steps[0]
-----START HTTP REQUEST-----
POST /users HTTP/1.1
Host: localhost:8081
Content-Type: application/json
{"name":"userName"}
-----END HTTP REQUEST-----
-----START HTTP RESPONSE-----
HTTP/1.1 200 OK
Content-Length: 13
Content-Type: application/json
Date: Sat, 06 Sep 2025 08:00:11 GMT
{"id":"123"}
-----END HTTP RESPONSE-----
F
1) openapi_readonly_writeonly_issue.yml 3396445fadda9df9f5e32746a5ddd9d81bc9ee10
Failure/Error: http request failed on "OpenAPI readonly writeonly validation issue".steps[0]: openapi3 validation error: Error: 200 response body for '/users' failed to validate schema, Reason: The response body for status code '200' is defined as an object. However, it does not meet the schema requirements of the specification, Validation Errors: [Reason: missing property 'name', Location: /required], Line: 24, Column: 7
-----START HTTP REQUEST-----
POST /users HTTP/1.1
Host: localhost:8081
Content-Type: application/json
-----END HTTP REQUEST-----
-----START HTTP RESPONSE-----
HTTP/1.1 200 OK
Content-Length: 13
Content-Type: application/json
Date: Sat, 06 Sep 2025 08:00:11 GMT
{"id":"123"}
-----END HTTP RESPONSE-----
Failure step (openapi_readonly_writeonly_issue.yml):
8 - api:
9 /users:
10 post:
11 body:
12 application/json:
13 name: userName
14 test: current.res.status == 200
1 scenario, 0 skipped, 1 failure