Package io.wcm.siteapi.openapi.validator
Class OpenApiSpec
- java.lang.Object
-
- io.wcm.siteapi.openapi.validator.OpenApiSpec
-
public final class OpenApiSpec extends java.lang.Object
Reads and validates an OAS3 YAML specification. Gives access toOpenApiSchemaValidator
instances for each path/suffix defined in the specification.
-
-
Constructor Summary
Constructors Constructor Description OpenApiSpec(@NotNull java.lang.String path, @NotNull java.lang.String version)
Create instance with given spec files.OpenApiSpec(@NotNull java.net.URL url, @NotNull java.lang.String version)
Create instance with given spec files.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull OpenApiSchemaValidator
getSchemaValidator(@NotNull java.lang.String suffix)
Get Schema for default response of operation mapped to given suffix.@NotNull java.net.URL
getURL()
@NotNull java.lang.String
getVersion()
java.lang.String
toString()
-
-
-
Constructor Detail
-
OpenApiSpec
public OpenApiSpec(@NotNull @NotNull java.lang.String path, @NotNull @NotNull java.lang.String version)
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
public OpenApiSpec(@NotNull @NotNull java.net.URL url, @NotNull @NotNull java.lang.String version)
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 Detail
-
getURL
@NotNull public @NotNull java.net.URL getURL()
- Returns:
- Specification URL.
-
getVersion
@NotNull public @NotNull java.lang.String getVersion()
- Returns:
- Spec version (derived from file name) or empty string.
-
getSchemaValidator
@NotNull public @NotNull OpenApiSchemaValidator getSchemaValidator(@NotNull @NotNull java.lang.String suffix)
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
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-