Is there a way to reuse objects between POST and PUT `requests`?
Our request objects for POST and PUT are very similar - only an identifier (ID) differs in the two.
Is there a way to reuse an object between the two? I know that the readOnly property can be used for the response (and also for the GET) with regards to an ID field
The problem with readOnly is that we cannot use it for the `PUT` request - it will not be rendered...
Only possibility to solve the above (as I see it) is to have 2 different objects (I know this can be done extending request-object with an `allOf`)...
If anyone has a "smart" design pattern for this I would be happy to hear about it 🙂
You actually did summarize all the possibilities (2 distinct objects, allOf).
I am not sure about that but if you define an object including all common properties, you can try to add "additionalProperties: true".
In such case you will be able to use, several times, the object and to inject the ID only when you need.
But in such way, the ID is taken into account only during the run time.