OpenAPI Schema Customization
OpenAPI Schema Customization
The OpenL Tablets Rule Services web service produces the OpenAPI schema for each deployed service automatically from the
OpenL projects based on the OpenAPI and JAX-RS annotations.
To change the output of openapi.json, create the openapi-configuration.json file in the classpath of the service with the following contents:
{
"openAPI": {
"info": {
"version": "2.4.7",
"description": "Secured"
},
"security": [
{
"Basic": []
}
],
"components": {
"securitySchemes": {
"Basic": {
"type": "http",
"scheme": "basic"
}
}
}
}
}
For the description of the openapi-configuration.json file, see “Swagger 2.X Integration and Configuration”.
Server URL
The first server of the schema is the address the schema is requested from, without the query. A schema requested through a proxy or another host names that address, in both openapi.json and openapi.yaml. Servers listed in openapi-configuration*.json follow it.
Multiple Configuration Files
OpenL Rule Services scans the classpath for every file matching the openapi-configuration*.json pattern and merges them on top of the auto-generated schema. This makes it possible to split overrides across modules or layer environment-specific tweaks on top of a shared base.
Files are applied in a deterministic order:
openapi-configuration.jsonis always applied first.- Suffixed variants such as
openapi-configuration-1.jsonoropenapi-configuration-alpha.jsonfollow in natural filename order, soopenapi-configuration-alpha.jsonis applied beforeopenapi-configuration-zeta.json. - Each subsequent file overrides matching fields from the previous ones; non-overlapping fields are merged.
[!Note] Resources are resolved against the deployed service classpath, which means an extension JAR can ship its own
openapi-configuration-*.jsonand it will be picked up automatically alongside the base file.
Spring Property Placeholders
Each openapi-configuration*.json file may contain Spring-style property placeholders that are resolved against the application environment before JSON parsing:
${property.name}— replaced with the value ofproperty.name. A placeholder of an undefined property stays in the text as it is written.${property.name:default-value}— replaced with the value ofproperty.name, or withdefault-valueif the property is not defined.
Example:
{
"openAPI": {
"info": {
"title": "${service.title:OpenL Rule Services}",
"version": "${service.version}"
}
}
}
Properties come from the standard OpenL Rule Services configuration sources (application.properties, JVM -D system properties, environment variables, and so on).
Operation IDs
An operation takes the name of its method as its operationId. Methods of the same name get an index: calculate, calculate_1, calculate_2.
A name of a JavaScript object member also gets an index, for example toString_1, because Swagger UI and RapiDoc cannot load a schema with such an operationId. These names are constructor, hasOwnProperty, isPrototypeOf, propertyIsEnumerable, toLocaleString, toString, valueOf, __defineGetter__, __defineSetter__, __lookupGetter__, __lookupSetter__ and __proto__. The rule applies to an operationId declared in an annotation template too. The path of the operation keeps the method name.