public class ModelUtil extends Object
Modifier and Type | Method and Description |
---|---|
static void |
addTag(org.eclipse.microprofile.openapi.models.OpenAPI openApi,
org.eclipse.microprofile.openapi.models.tags.Tag tag)
Adds a
Tag to the OpenAPI model. |
static org.eclipse.microprofile.openapi.models.Components |
components(org.eclipse.microprofile.openapi.models.OpenAPI openApi)
Gets the
Components from the OAI model. |
static List<org.eclipse.microprofile.openapi.models.media.Schema> |
getParameterSchemas(org.eclipse.microprofile.openapi.models.parameters.Parameter parameter)
Returns the list of
Schema s defined for the given Parameter . |
static String |
nameFromRef(String ref)
Returns the name component of the ref.
|
static boolean |
operationHasParameter(org.eclipse.microprofile.openapi.models.Operation operation,
String name)
Returns true if the given operation has a parameter with the given name.
|
static boolean |
parameterHasSchema(org.eclipse.microprofile.openapi.models.parameters.Parameter parameter)
Returns true only if the given
Parameter has a schema defined
for it. |
static org.eclipse.microprofile.openapi.models.Paths |
paths(OpenAPIImpl openApi)
Gets the
Paths from the OAI model. |
static boolean |
requestBodyHasSchema(org.eclipse.microprofile.openapi.models.parameters.RequestBody requestBody)
Returns true only if the given
RequestBody has a schema defined
for it. |
static org.eclipse.microprofile.openapi.models.responses.APIResponses |
responses(org.eclipse.microprofile.openapi.models.Operation operation)
Gets the
APIResponses child model from the given operation. |
static void |
setParameterSchema(org.eclipse.microprofile.openapi.models.parameters.Parameter parameter,
org.eclipse.microprofile.openapi.models.media.Schema schema)
Sets the given
Schema on the given Parameter . |
static void |
setRequestBodySchema(org.eclipse.microprofile.openapi.models.parameters.RequestBody requestBody,
org.eclipse.microprofile.openapi.models.media.Schema schema,
String[] mediaTypes)
Sets the given
Schema on the given RequestBody . |
public static void addTag(org.eclipse.microprofile.openapi.models.OpenAPI openApi, org.eclipse.microprofile.openapi.models.tags.Tag tag)
Tag
to the OpenAPI
model. If a tag having the same
name already exists in the model, the tags' attributes are merged, with the
new tag's attributes overriding the value of any attributes specified on
both.openApi
- the OpenAPI modeltag
- a new Tag
to addpublic static org.eclipse.microprofile.openapi.models.Components components(org.eclipse.microprofile.openapi.models.OpenAPI openApi)
Components
from the OAI model. If it doesn't exist, creates it.openApi
- OpenAPIpublic static org.eclipse.microprofile.openapi.models.Paths paths(OpenAPIImpl openApi)
Paths
from the OAI model. If it doesn't exist, creates it.openApi
- OpenAPIpublic static org.eclipse.microprofile.openapi.models.responses.APIResponses responses(org.eclipse.microprofile.openapi.models.Operation operation)
APIResponses
child model from the given operation. If it's null
then it will be created and returned.operation
- Operationpublic static boolean parameterHasSchema(org.eclipse.microprofile.openapi.models.parameters.Parameter parameter)
Parameter
has a schema defined
for it. A schema can be defined either via the parameter's "schema"
property, or any "content.*.schema" property.parameter
- Parameterpublic static List<org.eclipse.microprofile.openapi.models.media.Schema> getParameterSchemas(org.eclipse.microprofile.openapi.models.parameters.Parameter parameter)
Schema
s defined for the given Parameter
.
A schema can be defined either via the parameter's "schema" property, or any
"content.*.schema" property.parameter
- Parameterpublic static void setParameterSchema(org.eclipse.microprofile.openapi.models.parameters.Parameter parameter, org.eclipse.microprofile.openapi.models.media.Schema schema)
Schema
on the given Parameter
. This is tricky
because the paramater may EITHER have a schema property or it may have a
Content
child which itself has zero or more MediaType
children
which will contain the Schema
.
The OpenAPI specification requires that a parameter have *either* a schema
or a content, but not both.parameter
- Parameterschema
- Schemapublic static boolean requestBodyHasSchema(org.eclipse.microprofile.openapi.models.parameters.RequestBody requestBody)
RequestBody
has a schema defined
for it. A schema would be found within the request body's Content/MediaType
children.requestBody
- RequestBodypublic static void setRequestBodySchema(org.eclipse.microprofile.openapi.models.parameters.RequestBody requestBody, org.eclipse.microprofile.openapi.models.media.Schema schema, String[] mediaTypes)
Schema
on the given RequestBody
.requestBody
- RequestBodyschema
- SchemamediaTypes
- String arraypublic static boolean operationHasParameter(org.eclipse.microprofile.openapi.models.Operation operation, String name)
operation
- Operationname
- StringCopyright © 2018–2020. All rights reserved.