Model composition in swagger spec without additional nesting layer -


if have following example settings definition embedded in thing via composition:

definitions:   settings:     properties:        foobar:         type: number          format: double       boofar:         type: string    thing:     properties:       allof:         $ref: '#/definitions/settings'       name:         type: string 

if define method post thing in editor.swagger.io, ends constructing json looks this:

{   settings: {     foobar: 1,     boofar: "text here"   },   name: "some name" } 

i want embed model definition composition without additional nested property definition -- possible? json structure have thing:

{   foobar: 1,   boofar: "text here",   name: "some name" } 

is there way achieve this?

your example not use composition allof property.

allof supposed on root of definition , it's array of schema (reference or inline).

here's proper way use allof example:

swagger: '2.0' info: title: api version: 1.0.0

paths:    /thing:     get:       responses:         200:           description: ok           schema:             $ref: '#/definitions/thing'  definitions:   settings:     properties:        foobar:         type: number          format: double       boofar:         type: string    thing:     allof:       - $ref: '#/definitions/settings'       - properties:           name:             type: string 

resulting rendering in swaggerui:

enter image description here


Comments