Package io.wcm.siteapi.openapi.validator
Class OpenApiSpecVersions
java.lang.Object
io.wcm.siteapi.openapi.validator.OpenApiSpecVersions
Get available versions of Site API specification.
By default, spec files are expected in the classpath at /site-api-spec
with filenames named following this pattern:
site-api.yaml site-api-v1.yaml site-api-v2.yaml ...
But you can also specify a custom path and file name pattern.
The spec versions are derived from the file names. If no version is detected in the filename (e.g.
site-api.yaml
an empty string is used as versions. Otherwise the version from the file name
is returned (e.g. site-api-v1.yaml
-> v1
). This versions reflects the
"major version" of the spec with expected full backward compatibility within this version.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionGet all Site API Specs detected in classpath matching the default path and pattern.OpenApiSpecVersions
(@NotNull String path, @NotNull Pattern filenamePattern, @Nullable Comparator<String> versionComparator) Get all Site API Specs detected in classpath matching given path and filename pattern. -
Method Summary
Modifier and TypeMethodDescription@NotNull OpenApiSpec
Returns Site API specification.@NotNull Collection<String>
Get all Site API versions.@NotNull OpenApiSpec
Returns Site API specification for highest version number.@NotNull String
Get latest version.
-
Field Details
-
DEFAULT_RESOURCE_PATH
Default classpath path to look for Site API spec files.- See Also:
-
DEFAULT_FILENAME_PATTERN
Default pattern for Site API spec files. Last group is expected to return the actual version.
-
-
Constructor Details
-
OpenApiSpecVersions
public OpenApiSpecVersions()Get all Site API Specs detected in classpath matching the default path and pattern. -
OpenApiSpecVersions
public OpenApiSpecVersions(@NotNull @NotNull String path, @NotNull @NotNull Pattern filenamePattern, @Nullable @Nullable Comparator<String> versionComparator) Get all Site API Specs detected in classpath matching given path and filename pattern.- Parameters:
path
- Directory in classpathfilenamePattern
- File name pattern (last group is expected to return the actual version).versionComparator
- Comparator for versions ("highest" version is last version) - or null to use standard string sorting
-
-
Method Details
-
getAllVersions
Get all Site API versions.- Returns:
- Versions
-
getLatestVersion
Get latest version.- Returns:
- Version
-
getLatest
Returns Site API specification for highest version number.- Returns:
- Site API specification.
-
get
Returns Site API specification.- Parameters:
version
- Requested spec version- Returns:
- Site API specification.
-