2020年12月20日星期日

Can example in OpenAPI be inline?

I have this component:

components:    schemas:      book:        type: object        required:         - id        properties:          id:           type: string          title:           type: string          author:           type: string  

Is there a way to define a response object that includes the book attributes using this component? The response is this:

{    "id": "xxxxx",    "title": "This is title",    "author": "John"  }  

I tried like this:

responses:    200-response:      description: HTTP 200 response      content:        application/json:          schema:            type: object            properties:              book:                $ref: '#/components/schemas/book'  

but it has the parent object of book instead of the attributes immediately

https://stackoverflow.com/questions/65386710/can-example-in-openapi-be-inline December 21, 2020 at 10:05AM

没有评论:

发表评论