mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 11:27:05 +00:00
feature/Add instance url at OpenAPI 3.1 Spec
This commit is contained in:
parent
bb2f7b76b6
commit
9973288ca5
20
README.md
20
README.md
@ -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,
|
||||
|
||||
@ -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")
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user