File tree Expand file tree Collapse file tree 4 files changed +34
-22
lines changed
src/main/kotlin/com/cosmotech/api Expand file tree Collapse file tree 4 files changed +34
-22
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import java.io.BufferedReader
1111import org.springframework.beans.factory.annotation.Value
1212import org.springframework.context.annotation.Bean
1313import org.springframework.context.annotation.Configuration
14+ import com.cosmotech.api.utils.getAboutInfo
1415
1516@Configuration
1617open class CsmOpenAPIConfiguration (val csmPlatformProperties : CsmPlatformProperties ) {
@@ -38,12 +39,8 @@ open class CsmOpenAPIConfiguration(val csmPlatformProperties: CsmPlatformPropert
3839
3940 openAPI.info.version = apiVersion
4041
41- if (! csmPlatformProperties.vcsRef.isNullOrBlank()) {
42- openAPI.info.description + = " / ${csmPlatformProperties.vcsRef} "
43- }
44- if (! csmPlatformProperties.commitId.isNullOrBlank()) {
45- openAPI.info.description + = " / ${csmPlatformProperties.commitId} "
46- }
42+ val fullVersion = getAboutInfo().getJSONObject(" version" ).getString(" full" )
43+ openAPI.info.description + = " ($fullVersion )"
4744
4845 // Remove any set of servers already defined in the input openapi.yaml,
4946 // so as to have the base URL auto-generated based on the incoming requests
Original file line number Diff line number Diff line change @@ -9,22 +9,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties
99/* * Configuration Properties for the Cosmo Tech Platform */
1010@ConfigurationProperties(prefix = " csm.platform" )
1111data class CsmPlatformProperties (
12-
13- /* * Platform summary */
14- val summary : String? ,
15-
16- /* * Platform description */
17- val description : String? ,
18-
19- /* * Platform version (MAJOR.MINOR.PATCH) */
20- val version : String? ,
21-
22- /* * Platform exact commit ID */
23- val commitId : String? = null ,
24-
25- /* * Platform exact Version-Control System reference */
26- val vcsRef : String? = null ,
27-
2812 /* * API Configuration */
2913 val api : Api ,
3014
Original file line number Diff line number Diff line change @@ -162,6 +162,15 @@ internal fun endpointSecurityReaders(
162162 customOrganizationViewer : String
163163) =
164164 listOf (
165+ CsmSecurityEndpointsRolesReader (
166+ paths = listOf (" /about" ),
167+ roles =
168+ arrayOf(
169+ ROLE_ORGANIZATION_USER ,
170+ ROLE_ORGANIZATION_VIEWER ,
171+ customOrganizationUser,
172+ customOrganizationViewer),
173+ customAdmin = customOrganizationAdmin),
165174 CsmSecurityEndpointsRolesReader (
166175 paths = PATHS_CONNECTORS ,
167176 roles =
Original file line number Diff line number Diff line change 1+ // Copyright (c) Cosmo Tech.
2+ // Licensed under the MIT license.
3+ package com.cosmotech.api.utils
4+
5+ import java.io.BufferedReader
6+ import org.json.JSONException
7+ import org.json.JSONObject
8+
9+ fun getAboutInfo (): JSONObject {
10+ val aboutJsonInputStream =
11+ object {}::class .java.getResourceAsStream(" /about.json" )
12+ ? : throw IllegalStateException (" Unable to read about info data from 'classpath:/about.json'" )
13+ val aboutJsonContent = aboutJsonInputStream.use { it.bufferedReader().use(BufferedReader ::readText) }
14+
15+ try {
16+ return JSONObject (aboutJsonContent)
17+ }
18+ catch (e: JSONException )
19+ {
20+ throw IllegalStateException (" Unable to parse about info from 'classpath:/about.json'" , e)
21+ }
22+ }
You can’t perform that action at this time.
0 commit comments