My App's response looks like this:
{
"status": "success",
"data": {
"status": "ready"
},
"request_id": "string"
}
I tried to define response in Swagger
* @SWG\Response (
* response=200,
* description="Success response",
* @SWG\Schema (
* @SWG\Property(
* property="status",
* type="string",
* default="success"
* ),
* @SWG\Property(
* property="data",
* @SWG\Schema(
* ref="#/definitions/Service/models/Status"
* )
* ),
* @SWG\Property(
* property="request_id",
* type="string"
* ),
* )
* ),
But it does not use Schema definition for Status, so my response actually looks like:
{
"status": "success",
"data": {},
"request_id": "string"
}
How can I define data property to use schema definition? Or can it can be done in a different way?
OpenAPI 3.0 data types are based on an extended subset JSON Schema Specification Wright Draft 00 (aka Draft 5). The data types are described using a Schema object. To learn how to model various data types, see the following topics: Data Types.
The discriminator is the schema property name that is used to differentiate between other schema that inherit this schema. The property name used MUST be defined at this schema and it MUST be in the required property list. When used, the value MUST be the name of this schema or any schema that inherits it.
How funny can be the fact, that people sometimes find the answer just after posting a question.
Answer is:
* @SWG\Response (
* response=200,
* description="Success response",
* @SWG\Schema (
* @SWG\Property(
* property="status",
* type="string",
* default="success"
* ),
* @SWG\Property(
* property="data",
* ref="#/definitions/Service/models/Status"
* ),
* @SWG\Property(
* property="request_id",
* type="string"
* ),
* )
* ),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With