vert-x3 / vertx-web

HTTP web applications for Vert.x
Apache License 2.0
1.11k stars 534 forks source link

OpenAPI writeOnly property appears in response #2055

Open KeerthanaSrikanth opened 3 years ago

KeerthanaSrikanth commented 3 years ago

Version

4.1.3

Context

Properties which are writeOnly are still appearing in response body

Sample Schema

SampleObject:
  type: object
  description: Sample description
  properties:
    id:
      type: string
    name:
      type: string
      writeOnly: true

Expected behaviour: Only id should be present in response body Actual behaviour: Both id and name are present in response

As per the OpenAPI documentation: readOnly properties are included in responses but not in requests, and writeOnly properties may be sent in requests but not in responses.

Do you have a reproducer?

https://github.com/KeerthanaSrikanth/web-and-openapi-howto/tree/writeonly I have added writeOnly property to the property tag in the Pet schema.

Steps to reproduce

1. `mvn compile exec:java`
2. `curl -X POST -H "Content-type: application/json" --data '{"id":4,"name":"Alan", "tag": "PQR"}' http://localhost:8080/pets`
3. `curl http://localhost:8080/pets/4`

Expected response: {"id":4,"name":"Alan"}% Actual response: {"id":4,"name":"Alan","tag":"PQR"}%

Stwissel commented 3 years ago

AFAIK the OpenAPI contract only validates the request coming in, not the response going out. The outgoing code is your responsibility