Merge pull request #2642 from constantine2nd/develop

OpenAPI 3.1
This commit is contained in:
Simon Redfern 2025-12-09 14:52:48 +01:00 committed by GitHub
commit 39f6a5a47d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 26 additions and 9 deletions

View File

@ -603,6 +603,26 @@ Please note that first will be checked `per second` call limit then `per minute`
Info about rate limiting availability at some instance can be found over next API endpoint: https://apisandbox.openbankproject.com/obp/v3.1.0/rate-limiting. The response we are interested in looks like this:
### OpenAPI Server Configuration
The OpenAPI documentation endpoint (`/resource-docs/VERSION/openapi`) now dynamically uses the configured `hostname` property instead of hardcoded values.
The `hostname` property is required for the API to start and must contain the full URL:
```properties
# This property is required and must contain the full URL
hostname=https://your-api-server.com
```
If not configured, the application will fail to start with error "OBP-00001: Hostname not specified".
The OpenAPI documentation will show a single server entry using the configured hostname:
```json
"servers": [
{"url": "https://your-api-server.com", "description": "Back-end server"}
]
```
```JSON
{
"enabled": false,

View File

@ -348,7 +348,7 @@ object OpenAPI31JSONFactory extends MdcLoggable {
def createOpenAPI31Json(
resourceDocs: List[ResourceDocJson],
requestedApiVersion: String,
hostname: String = "api.openbankproject.com"
hostname: String
): OpenAPI31Json = {
val timestamp = LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)
@ -380,12 +380,8 @@ object OpenAPI31JSONFactory extends MdcLoggable {
// Create Servers
val servers = List(
ServerJson(
url = s"https://$hostname",
description = Some("Production server")
),
ServerJson(
url = "https://apisandbox.openbankproject.com",
description = Some("Sandbox server")
url = hostname,
description = Some("Back-end server")
)
)

View File

@ -1,6 +1,6 @@
package code.api.ResourceDocs1_4_0
import code.api.Constant.{GET_DYNAMIC_RESOURCE_DOCS_TTL, GET_STATIC_RESOURCE_DOCS_TTL, PARAM_LOCALE}
import code.api.Constant.{GET_DYNAMIC_RESOURCE_DOCS_TTL, GET_STATIC_RESOURCE_DOCS_TTL, PARAM_LOCALE, HostName}
import code.api.OBPRestHelper
import code.api.cache.Caching
import code.api.util.APIUtil._
@ -828,7 +828,8 @@ trait ResourceDocsAPIMethods extends MdcLoggable with APIMethods220 with APIMeth
private def convertResourceDocsToOpenAPI31JvalueAndSetCache(cacheKey: String, requestedApiVersionString: String, resourceDocsJson: List[JSONFactory1_4_0.ResourceDocJson]) : JValue = {
logger.debug(s"Generating OpenAPI 3.1-convertResourceDocsToOpenAPI31JvalueAndSetCache requestedApiVersion is $requestedApiVersionString")
val openApiDoc = code.api.ResourceDocs1_4_0.OpenAPI31JSONFactory.createOpenAPI31Json(resourceDocsJson, requestedApiVersionString)
val hostname = HostName
val openApiDoc = code.api.ResourceDocs1_4_0.OpenAPI31JSONFactory.createOpenAPI31Json(resourceDocsJson, requestedApiVersionString, hostname)
val openApiJValue = code.api.ResourceDocs1_4_0.OpenAPI31JSONFactory.OpenAPI31JsonFormats.toJValue(openApiDoc)
val jsonString = json.compactRender(openApiJValue)