public class OpenApiUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static JsonNode |
buildSchema(io.swagger.v3.oas.models.media.Schema<?> schema,
io.swagger.v3.oas.models.OpenAPI api)
Build a JSON schema based on the provided
Schema. |
static io.swagger.v3.oas.models.media.Content |
getContent(io.swagger.v3.oas.models.Operation operation,
Pattern pattern)
Attempts to fetch the first Response content based off of a response code pattern.
|
static String |
getDelimiter(String name,
io.swagger.v3.oas.models.parameters.Parameter.StyleEnum style)
Returns a delimiter
String corresponding to the Open Api parameter style enum and parameter name. |
static String |
getFirstRequestContentType(io.swagger.v3.oas.models.Operation operation)
Fetches the first request content type from the given operation.
|
static io.swagger.v3.oas.models.PathItem.HttpMethod |
getHttpMethod(io.swagger.v3.oas.models.OpenAPI api,
String operationId)
Retrieves the HTTP method based off of the "name" field of the operation
|
static JSONUtil.NodeType |
getNodeType(io.swagger.v3.oas.models.media.Schema<?> schema)
Fetches the
JSONUtil.NodeType based off of the Schema definition |
static JSONUtil.NodeType |
getNodeType(io.swagger.v3.oas.models.media.Schema<?> schema,
JSONUtil.NodeType defaultValue)
Fetches the
JSONUtil.NodeType based off of the schema definition. |
static OpenAPISpecContext |
getOpenAPISpecContext(io.swagger.v3.oas.models.OpenAPI api,
io.swagger.v3.oas.models.Operation operation)
Creates an
OpenAPISpecContext object which houses the operation details in a cookie and the browse fields
to parameter map. |
static io.swagger.v3.oas.models.Operation |
getOperation(io.swagger.v3.oas.models.OpenAPI api,
io.swagger.v3.oas.models.PathItem.HttpMethod method,
String path)
Fetch the Operation by path and method.
|
static io.swagger.v3.oas.models.Operation |
getOperation(io.swagger.v3.oas.models.OpenAPI api,
String operationId)
Retrieves the operation by the "name" field of the operation.
|
static List<io.swagger.v3.oas.models.parameters.Parameter> |
getParametersFromOperation(io.swagger.v3.oas.models.OpenAPI api,
io.swagger.v3.oas.models.Operation operation)
Retrieves all of the valid supported parameters
OpenApiParameterType for this operation. |
static List<io.swagger.v3.oas.models.parameters.Parameter> |
getParametersFromOperationByType(io.swagger.v3.oas.models.OpenAPI api,
io.swagger.v3.oas.models.Operation operation,
OpenApiParameterType filterType)
Retrieves the specified
OpenApiParameterType parameter for this operation. |
static String |
getPath(io.swagger.v3.oas.models.OpenAPI api,
String operationId)
Returns the path based off of the Operation ID
|
static io.swagger.v3.oas.models.parameters.RequestBody |
getRequestBody(io.swagger.v3.oas.models.OpenAPI api,
io.swagger.v3.oas.models.PathItem.HttpMethod method,
String path)
Retrieves the request body by http method and path.
|
static io.swagger.v3.oas.models.parameters.RequestBody |
getRequestBody(io.swagger.v3.oas.models.OpenAPI api,
String operationId)
Retrieves the request body for the operation, based off of the "name" field of the operation.
|
static io.swagger.v3.oas.models.media.Content |
getRequestContent(io.swagger.v3.oas.models.OpenAPI api,
io.swagger.v3.oas.models.PathItem.HttpMethod method,
String path)
Fetches the request content type based off of the
PathItem.HttpMethod and the path. |
static io.swagger.v3.oas.models.media.Schema<?> |
getSchema(io.swagger.v3.oas.models.media.Content content)
Fetches the schema object from the given
Content. |
static io.swagger.v3.oas.models.media.Schema<?> |
getSchema(io.swagger.v3.oas.models.OpenAPI api,
io.swagger.v3.oas.models.media.Content content)
Fetches the schema object from
Content type map. |
static io.swagger.v3.oas.models.media.Schema<?> |
getSchema(io.swagger.v3.oas.models.OpenAPI api,
io.swagger.v3.oas.models.parameters.RequestBody request)
Fetches the schema for the request body.
|
static io.swagger.v3.oas.models.media.Schema<?> |
getSchema(io.swagger.v3.oas.models.OpenAPI api,
io.swagger.v3.oas.models.media.Schema<?> schema)
Fetches the schema, if this is a referenced / shared schema, then the reference will be
resolved for you
|
static String |
getSerializedHeaderParameter(String name,
String parameterValue,
OpenApiDataType dataType)
Updates input header parameter value according to the data type value from Open Api Specification.
|
static String |
getSerializedPathParameter(String name,
String parameterValue,
io.swagger.v3.oas.models.parameters.Parameter.StyleEnum style,
boolean explode,
OpenApiDataType dataType)
Updates input path parameter value according to the style, explode and data type values from Open Api Specification.
|
static List<Map.Entry<String,String>> |
getSerializedQueryParameter(String name,
String parameterValue,
io.swagger.v3.oas.models.parameters.Parameter.StyleEnum style,
boolean explode,
OpenApiDataType dataType)
Updates input query parameter value according to the style, explode and data type values from Open Api Specification.
|
static io.swagger.v3.oas.models.parameters.Parameter |
getSharedParameter(io.swagger.v3.oas.models.OpenAPI api,
String ref)
Retrieves the shared parameter under the "components" section based off of the $ref value
|
static io.swagger.v3.oas.models.media.Schema<?> |
getSharedSchema(io.swagger.v3.oas.models.OpenAPI api,
String ref)
Retrieves the shared schema under the "components" section based off of the $ref value.
|
static boolean |
isRequestBodyRequired(io.swagger.v3.oas.models.Operation operation)
Returns a boolean value of the "required" attribute from request body.
|
static boolean |
isStructured(io.swagger.v3.oas.models.media.Content content)
Content is considered structured if the schema associated with it is not null.
|
public static io.swagger.v3.oas.models.media.Schema<?> getSchema(io.swagger.v3.oas.models.OpenAPI api,
io.swagger.v3.oas.models.parameters.RequestBody request)
api - the api definitionrequest - the selected requestpublic static io.swagger.v3.oas.models.media.Schema<?> getSchema(io.swagger.v3.oas.models.OpenAPI api,
io.swagger.v3.oas.models.media.Content content)
Content type map. Currently only supports extracting schema objects
from MediaType of type CONTENT_TYPE. Also resolves any $ref pointers in the schema if present.api - the api definitioncontent - the selected contentpublic static io.swagger.v3.oas.models.media.Schema<?> getSchema(io.swagger.v3.oas.models.media.Content content)
Content. This will NOT resolve $ref for you as just has knowledge
of the incoming Content object. Returns null if no content is found within Contentcontent - the selected contentpublic static io.swagger.v3.oas.models.media.Schema<?> getSchema(io.swagger.v3.oas.models.OpenAPI api,
io.swagger.v3.oas.models.media.Schema<?> schema)
api - the api definitionschema - the selected schemapublic static io.swagger.v3.oas.models.media.Schema<?> getSharedSchema(io.swagger.v3.oas.models.OpenAPI api,
String ref)
api - the api definitionref - the reference pathpublic static io.swagger.v3.oas.models.parameters.Parameter getSharedParameter(io.swagger.v3.oas.models.OpenAPI api,
String ref)
api - the api definitionref - the reference pathpublic static JSONUtil.NodeType getNodeType(io.swagger.v3.oas.models.media.Schema<?> schema)
JSONUtil.NodeType based off of the Schema definitionschema - the selected schemapublic static JSONUtil.NodeType getNodeType(io.swagger.v3.oas.models.media.Schema<?> schema, JSONUtil.NodeType defaultValue)
JSONUtil.NodeType based off of the schema definition. Will use default if not given / invalid.schema - the selected schemadefaultValue - default value if node type isn't givenpublic static boolean isStructured(io.swagger.v3.oas.models.media.Content content)
content - the selected contentpublic static io.swagger.v3.oas.models.media.Content getContent(io.swagger.v3.oas.models.Operation operation,
Pattern pattern)
operation - the selected operationpattern - the response patternpublic static io.swagger.v3.oas.models.Operation getOperation(io.swagger.v3.oas.models.OpenAPI api,
io.swagger.v3.oas.models.PathItem.HttpMethod method,
String path)
api - the api definitionmethod - the selected http methodpath - the selected pathpublic static List<io.swagger.v3.oas.models.parameters.Parameter> getParametersFromOperation(io.swagger.v3.oas.models.OpenAPI api, io.swagger.v3.oas.models.Operation operation)
OpenApiParameterType for this operation. If the
parameters are reference parameters ($ref), then this utility will resolve the parameter reference for you.api - the api definitionoperation - the selected operationpublic static List<io.swagger.v3.oas.models.parameters.Parameter> getParametersFromOperationByType(io.swagger.v3.oas.models.OpenAPI api, io.swagger.v3.oas.models.Operation operation, OpenApiParameterType filterType)
OpenApiParameterType parameter for this operation. If the parameters are
reference parameters ($ref), then this utility will resolve the parameter reference for you.api - the api definitionoperation - the selected operationfilterType - the parameter to filter uponpublic static OpenAPISpecContext getOpenAPISpecContext(io.swagger.v3.oas.models.OpenAPI api, io.swagger.v3.oas.models.Operation operation)
OpenAPISpecContext object which houses the operation details in a cookie and the browse fields
to parameter map.api - the api definitionoperation - the selected operationpublic static io.swagger.v3.oas.models.Operation getOperation(io.swagger.v3.oas.models.OpenAPI api,
String operationId)
api - the api definitionoperationId - the operation's idpublic static io.swagger.v3.oas.models.PathItem.HttpMethod getHttpMethod(io.swagger.v3.oas.models.OpenAPI api,
String operationId)
api - the api definitionoperationId - the operation idpublic static io.swagger.v3.oas.models.parameters.RequestBody getRequestBody(io.swagger.v3.oas.models.OpenAPI api,
io.swagger.v3.oas.models.PathItem.HttpMethod method,
String path)
api - the api definitionmethod - the selected http methodpath - the selected pathpublic static io.swagger.v3.oas.models.parameters.RequestBody getRequestBody(io.swagger.v3.oas.models.OpenAPI api,
String operationId)
api - the api definitionoperationId - the operation idpublic static boolean isRequestBodyRequired(io.swagger.v3.oas.models.Operation operation)
operation - the selected operationpublic static io.swagger.v3.oas.models.media.Content getRequestContent(io.swagger.v3.oas.models.OpenAPI api,
io.swagger.v3.oas.models.PathItem.HttpMethod method,
String path)
PathItem.HttpMethod and the path. If no content is given,
then an empty content is returned.api - the api definitionmethod - the selected http methodpath - the selected pathpublic static String getFirstRequestContentType(io.swagger.v3.oas.models.Operation operation)
operation - the selected operationpublic static String getPath(io.swagger.v3.oas.models.OpenAPI api, String operationId)
api - the api definitionoperationId - the selected operation idpublic static String getSerializedPathParameter(String name, String parameterValue, io.swagger.v3.oas.models.parameters.Parameter.StyleEnum style, boolean explode, OpenApiDataType dataType)
name - Path parameter name.parameterValue - Path parameter value.style - Path parameter style.explode - boolean explode property from OpenAPI spec: specifies whether arrays and objects should generate
separate parameters for each array item or object property.dataType - OpenApiDataType of the parameter.public static List<Map.Entry<String,String>> getSerializedQueryParameter(String name, String parameterValue, io.swagger.v3.oas.models.parameters.Parameter.StyleEnum style, boolean explode, OpenApiDataType dataType)
name - Query parameter name.parameterValue - Query parameter value.style - Query parameter style.explode - boolean explode property from OpenAPI spec: specifies whether arrays and objects should generate
separate parameters for each array item or object property.dataType - OpenApiDataType of the parameter.public static String getSerializedHeaderParameter(String name, String parameterValue, OpenApiDataType dataType)
name - Header parameter name.parameterValue - Header parameter value.explode - boolean explode property from OpenAPI spec: specifies whether arrays and objects should generate separate
parameters for each array item or object property.dataType - OpenApiDataType of the parameter.public static String getDelimiter(String name, io.swagger.v3.oas.models.parameters.Parameter.StyleEnum style)
String corresponding to the Open Api parameter style enum and parameter name.name - Open Api Parameter Name.style - Open Api Parameter Style Enum.public static JsonNode buildSchema(io.swagger.v3.oas.models.media.Schema<?> schema, io.swagger.v3.oas.models.OpenAPI api)
Schema. Currently only supports building schemas with root
type of "object". Supports building schemas with ComposedSchema elements by resolving "allOf", "anyOf",
"oneOf" keywords used to combine schemas.schema - the schemaapi - the OpenAPI specificationIllegalArgumentException - if the schema is nullIllegalArgumentException - if Schema.getType() is not JSONUtil.NodeType.OBJECT