Class OpenApiSpecLoader
- java.lang.Object
-
- org.forgerock.openig.handler.router.OpenApiSpecLoader
-
public class OpenApiSpecLoader extends Object
Detects whether a file in the routes directory is an OpenAPI spec (Swagger 2.x or OpenAPI 3.x) in either JSON or YAML format, and parses it into anOpenAPImodel.Detection logic:
- File extension must be
.json,.yaml, or.yml. - The parsed root object must contain an
openapikey (OAS 3.x) or aswaggerkey (Swagger 2.x).
Normal OpenIG route JSON files contain a
handlerornameroot key but notopenapi/swagger, so they are not matched. - File extension must be
-
-
Constructor Summary
Constructors Constructor Description OpenApiSpecLoader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisOpenApiFile(File file)Returnstrueif the given file has a supported extension AND its root document contains anopenapiorswaggerkey, meaning it looks like an OpenAPI spec rather than a regular OpenIG route configuration.Optional<io.swagger.v3.oas.models.OpenAPI>tryLoad(File file)
-
-
-
Method Detail
-
isOpenApiFile
public boolean isOpenApiFile(File file)
Returnstrueif the given file has a supported extension AND its root document contains anopenapiorswaggerkey, meaning it looks like an OpenAPI spec rather than a regular OpenIG route configuration.- Parameters:
file- the file to test- Returns:
trueif the file appears to be an OpenAPI specification
-
-