{new} Models

The {@link oaj.jsonschema.JsonSchemaGenerator#JSONSCHEMA_useBeanDefs} setting can be used to reduce the size of your generated Swagger JSON files by creating model definitions for beans and referencing those definitions through `$ref` attributes.

By default, this flag is enabled when extending from {@link oajr.BasicRestServlet}:

public abstract class BasicRestServlet extends RestServlet implements BasicRestConfig { @RestMethod(name=OPTIONS, path="/*", ... flags={ // Use $ref references for bean definitions to reduce duplication in Swagger. JSONSCHEMA_useBeanDefs } ) public Swagger getOptions(RestRequest req) {...}

In the Swagger UI, this causes bean definitions to show up in the Models section at the bottom of the page:

##### Models section

##### Models section with Order bean expanded

In the generated Swagger JSON, embedded schema information for beans will be replaced with references such as the one shown below for the `Order` bean:

{ "swagger": "2.0", "paths": { "/store/order": { "get": { "operationId": "getOrders", "summary": "Petstore orders", "responses": { "200": { "description": "OK", "schema": { "description": "java.util.Collection<org.apache.juneau.examples.rest.petstore.Order>", "type": "array", "items": { "$ref": "#/definitions/Order" } }, ... ... ... ... ... }, "definitions": { "Order": { "type": "object", "properties": { "id": { "type": "integer", "format": "int64" }, "petId": { "type": "integer", "format": "int64" }, "shipDate": { "type": "string" }, "status": { "type": "string", "enum": [ "PLACED", "APPROVED", "DELIVERED" ] } }, "description": "org.apache.juneau.examples.rest.petstore.Order", "example": { "id": 123, "petId": 456, "shipDate": "2012-12-21", "status": "APPROVED" } }, ... }

Note that this does not affect how the information is rendered for that bean in the Swagger UI: