Package io.wcm.siteapi.openapi.validator
Class OpenApiSpecVersions
- java.lang.Object
-
- io.wcm.siteapi.openapi.validator.OpenApiSpecVersions
-
public final class OpenApiSpecVersions extends java.lang.Object
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 Modifier and Type Field Description static java.util.regex.Pattern
DEFAULT_FILENAME_PATTERN
Default pattern for Site API spec files.static java.lang.String
DEFAULT_RESOURCE_PATH
Default classpath path to look for Site API spec files.
-
Constructor Summary
Constructors Constructor Description OpenApiSpecVersions()
Get all Site API Specs detected in classpath matching the default path and pattern.OpenApiSpecVersions(@NotNull java.lang.String path, @NotNull java.util.regex.Pattern filenamePattern, @Nullable java.util.Comparator<java.lang.String> versionComparator)
Get all Site API Specs detected in classpath matching given path and filename pattern.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull OpenApiSpec
get(@NotNull java.lang.String version)
Returns Site API specification.@NotNull java.util.Collection<java.lang.String>
getAllVersions()
Get all Site API versions.@NotNull OpenApiSpec
getLatest()
Returns Site API specification for highest version number.@NotNull java.lang.String
getLatestVersion()
Get latest version.
-
-
-
Field Detail
-
DEFAULT_RESOURCE_PATH
public static final java.lang.String DEFAULT_RESOURCE_PATH
Default classpath path to look for Site API spec files.- See Also:
- Constant Field Values
-
DEFAULT_FILENAME_PATTERN
public static final java.util.regex.Pattern DEFAULT_FILENAME_PATTERN
Default pattern for Site API spec files. Last group is expected to return the actual version.
-
-
Constructor Detail
-
OpenApiSpecVersions
public OpenApiSpecVersions()
Get all Site API Specs detected in classpath matching the default path and pattern.
-
OpenApiSpecVersions
public OpenApiSpecVersions(@NotNull @NotNull java.lang.String path, @NotNull @NotNull java.util.regex.Pattern filenamePattern, @Nullable @Nullable java.util.Comparator<java.lang.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 Detail
-
getAllVersions
@NotNull public @NotNull java.util.Collection<java.lang.String> getAllVersions()
Get all Site API versions.- Returns:
- Versions
-
getLatestVersion
@NotNull public @NotNull java.lang.String getLatestVersion()
Get latest version.- Returns:
- Version
-
getLatest
@NotNull public @NotNull OpenApiSpec getLatest()
Returns Site API specification for highest version number.- Returns:
- Site API specification.
-
get
@NotNull public @NotNull OpenApiSpec get(@NotNull @NotNull java.lang.String version)
Returns Site API specification.- Parameters:
version
- Requested spec version- Returns:
- Site API specification.
-
-