diff --git a/README.md b/README.md index c045d4540f..a63ff29305 100644 --- a/README.md +++ b/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, diff --git a/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/OpenAPI31JSONFactory.scala b/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/OpenAPI31JSONFactory.scala index 6dcc228bd6..5a42e13631 100644 --- a/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/OpenAPI31JSONFactory.scala +++ b/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/OpenAPI31JSONFactory.scala @@ -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") ) ) diff --git a/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/ResourceDocsAPIMethods.scala b/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/ResourceDocsAPIMethods.scala index 8faa6e83ed..5f74148a7c 100644 --- a/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/ResourceDocsAPIMethods.scala +++ b/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/ResourceDocsAPIMethods.scala @@ -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)