Class OpenApiRouteBuilder
- java.lang.Object
-
- org.forgerock.openig.handler.router.OpenApiRouteBuilder
-
public class OpenApiRouteBuilder extends Object
Converts a parsedOpenAPImodel into an OpenIG routeJsonValue.The generated route:
- Has a
namederived frominfo.title(slugified) or the spec filename stem. - Has a
conditionexpression built from every(path, method)pair declared in the spec. Path parameter placeholders such as{id}are converted to the regex[^/]+, and each clause also checksrequest.methodagainst the HTTP verbs declared for that path. - Has a
heapcontaining a singleOpenApiValidationFilterheap object pointing at the spec file. - Has a
handlerthat is aChainwith the validation filter followed by aClientHandlerthat proxies to the first server URL declared in the spec.
The generated route uses the
baseURIdecorator if a server URL is found in the spec so that all requests are forwarded to the upstream service. - Has a
-
-
Constructor Summary
Constructors Constructor Description OpenApiRouteBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.forgerock.json.JsonValuebuildRouteJson(io.swagger.v3.oas.models.OpenAPI spec, File specFile, boolean failOnResponseViolation)Builds an OpenIG routeJsonValuefor the supplied OpenAPI specification.org.forgerock.json.JsonValuebuildRouteJson(io.swagger.v3.oas.models.OpenAPI spec, File specFile, boolean failOnResponseViolation, boolean mockMode)Builds an OpenIG routeJsonValuefor the supplied OpenAPI specification.
-
-
-
Method Detail
-
buildRouteJson
public org.forgerock.json.JsonValue buildRouteJson(io.swagger.v3.oas.models.OpenAPI spec, File specFile, boolean failOnResponseViolation)Builds an OpenIG routeJsonValuefor the supplied OpenAPI specification.- Parameters:
spec- the parsed OpenAPI modelspecFile- the original spec file on disk (used for the validator config and as a fallback route name)failOnResponseViolation- iftrue, the generatedOpenApiValidationFilterwill return502 Bad Gatewaywhen a response violates the spec; iffalse(default), violations are only logged- Returns:
- a
JsonValuethat can be passed directly to theRouterHandler's internal route-loading mechanism
-
buildRouteJson
public org.forgerock.json.JsonValue buildRouteJson(io.swagger.v3.oas.models.OpenAPI spec, File specFile, boolean failOnResponseViolation, boolean mockMode)Builds an OpenIG routeJsonValuefor the supplied OpenAPI specification.- Parameters:
spec- the parsed OpenAPI modelspecFile- the original spec file on disk (used for the validator config and as a fallback route name)failOnResponseViolation- iftrue, the generatedOpenApiValidationFilterwill return502 Bad Gatewaywhen a response violates the spec; iffalse(default), violations are only loggedmockMode- iftrue, the route handler chain terminates at anOpenApiMockResponseHandlerinstead of aClientHandler; whenfalse(default) requests are forwarded upstream- Returns:
- a
JsonValuethat can be passed directly to theRouterHandler's internal route-loading mechanism
-
-