Closed bwgjoseph closed 5 years ago
What fields you want to be shown on the page is completely up to you. You define the schema.
You can define as many different schemas as you want. And use the different schemas for the different methods. You can specify that in the refs option of the service.
Thanks, refs
was the key to it.
I was initially thinking if I could just define somewhere to exclude some fields. But looks like defining another definitions
and passing to refs
is the way to go.
As a side note if you need an object only once you don't have to create a reference for it but could directly define it in docs.operations wherever you need it.
Sorry, I don't quite get it. Any simple example to go along with it?
Thanks.
Nothing special, I just meant you could set the request/response etc. directly in the operations option of the service without using references.
e.g.
service.docs = {
operations: {
create: {
'requestBody.content': {
type: 'object',
properties: { ... }
}
}
}
}
I was trying that initially, but couldn't quite get it format right.
So it was in requestBody.content
.
Thanks for the tip!
Hi,
I am wondering if it is possible to override the default schema generation, and at the
service.docs
remove certain fields to display in theexample
portion?My schema is as such.
And the
example
inPOST
ops will be as such.I would like to remove
_id
,createdAt
,updatedAt
, and_v
from theexample
as those are values generated by database. If it is showing there, user may be mistaken that those values are required to be submitted during thePOST
ops.So it would be as such.
Thanks.
Also wondering if it is a common practice to expose all these fields at all? Assuming that all these are for internal consumption only. So that it only show as such.