Showing results for 
Search instead for 
Did you mean: 

Referencing part of a component

Occasional Visitor

Referencing part of a component

Hi, in the component section i defined an object Book having some properties. I want to refer to this component in two distinct endpoints, one using the whole Book object in the response, but the other one using just some properties of this Book object in its response body.

In the last case, is it correct to refer to the Book component or should i define another one?


Re: Referencing part of a component

When you reference a component, you reference it as-is.


If the difference is between input and output, depending on the version of the spec that you use, you may be able to utilize the 'readOnly' and 'writeOnly' attributes. Otherwise, you'd need to split the model into two, but you can use composition to avoid duplication.

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓
New Here?
Join us and watch the welcome video:
Top Kudoed Authors