Package io.wcm.siteapi.openapi.validator
Class OpenApiSpec
java.lang.Object
io.wcm.siteapi.openapi.validator.OpenApiSpec
Reads and validates an OAS3 YAML specification.
Gives access to
OpenApiSchemaValidator
instances for each path/suffix defined in the specification.-
Constructor Summary
ConstructorsConstructorDescriptionOpenApiSpec
(@NotNull String path, @NotNull String version) Create instance with given spec files.OpenApiSpec
(@NotNull URL url, @NotNull String version) Create instance with given spec files. -
Method Summary
Modifier and TypeMethodDescription@NotNull OpenApiSchemaValidator
getSchemaValidator
(@NotNull String suffix) Get Schema for default response of operation mapped to given suffix.@NotNull URL
getURL()
@NotNull String
toString()
-
Constructor Details
-
OpenApiSpec
Create instance with given spec files.- Parameters:
path
- Resource Path to OAS3 specversion
- Spec version or empty string- Throws:
SpecInvalidException
- If reading OAS3 spec fails.
-
OpenApiSpec
Create instance with given spec files.- Parameters:
url
- URL pointing to OAS3 specversion
- Spec version or empty string- Throws:
SpecInvalidException
- If reading OAS3 spec fails.
-
-
Method Details
-
getURL
- Returns:
- Specification URL.
-
getVersion
- Returns:
- Spec version (derived from file name) or empty string.
-
getSchemaValidator
Get Schema for default response of operation mapped to given suffix.It looks for a path definition ending with
/{suffix}.json
in the spec and returns the JSON schema defined in the YAML for HTTP 200 GET response withapplication/json
content type.See site-api.yaml as minimal example for a valid specification.
- Parameters:
suffix
- Suffix ID- Returns:
- Schema JSON node
-
toString
-