Skip to content
Snippets Groups Projects
Commit 01b3bf25 authored by Lawrence Chan's avatar Lawrence Chan Committed by Thulasi Dass Subramanian
Browse files

Use full URL instead of relative path

parent 6a01d26e
No related branches found
No related tags found
1 merge request!621Use full URL instead of relative path
......@@ -83,8 +83,8 @@ The following software have components provided under the terms of this license:
- Byte Buddy (without dependencies) (from https://repo1.maven.org/maven2/net/bytebuddy/byte-buddy)
- Byte Buddy Java agent (from https://repo1.maven.org/maven2/net/bytebuddy/byte-buddy-agent)
- ClassMate (from http://github.com/cowtowncoder/java-classmate)
- Cloud Key Management Service (KMS) API (from https://repo1.maven.org/maven2/com/google/apis/google-api-services-cloudkms)
- Cloud Storage JSON API v1-rev20240105-2.0.0 (from https://repo1.maven.org/maven2/com/google/apis/google-api-services-storage)
- Cloud Key Management Service (KMS) API v1-rev20231212-2.0.0 (from https://repo1.maven.org/maven2/com/google/apis/google-api-services-cloudkms)
- Cloud Storage JSON API v1-rev20240202-2.0.0 (from https://repo1.maven.org/maven2/com/google/apis/google-api-services-storage)
- Collections (from https://repo1.maven.org/maven2/commons-collections/commons-collections)
- Commons Digester (from http://commons.apache.org/digester/)
- Converter: Jackson (from https://github.com/square/retrofit, https://repo1.maven.org/maven2/com/squareup/retrofit2/converter-jackson)
......@@ -450,6 +450,7 @@ The following software have components provided under the terms of this license:
- Guava: Google Core Libraries for Java (from http://code.google.com/p/guava-libraries, https://github.com/google/guava, https://repo1.maven.org/maven2/com/google/guava/guava)
- HdrHistogram (from http://hdrhistogram.github.io/HdrHistogram/)
- Hibernate Validator (from https://repo1.maven.org/maven2/org/hibernate/hibernate-validator, https://repo1.maven.org/maven2/org/hibernate/validator/hibernate-validator)
- LatencyUtils (from http://latencyutils.github.io/LatencyUtils/)
- MongoDB Java Driver (from http://mongodb.org/, http://www.mongodb.org, https://www.mongodb.com/)
- Netty/Common (from https://repo1.maven.org/maven2/io/netty/netty-common)
......@@ -627,7 +628,6 @@ The following software have components provided under the terms of this license:
- AWS Java SDK for AWS Lambda (from https://aws.amazon.com/sdkforjava)
- Animal Sniffer Annotations (from https://repo1.maven.org/maven2/org/codehaus/mojo/animal-sniffer-annotations)
- Apache HttpClient Cache (from http://hc.apache.org/httpcomponents-client, http://hc.apache.org/httpcomponents-client-ga)
- Apache Log4j API (from https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-api)
- Apache Log4j SLF4J Binding (from https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-slf4j-impl)
- Apache Log4j to SLF4J Adapter (from https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-to-slf4j)
......@@ -681,7 +681,6 @@ The following software have components provided under the terms of this license:
- SLF4J API Module (from http://www.slf4j.org)
- Spongy Castle (from http://rtyley.github.io/spongycastle/)
- Spring Data for Azure Cosmos DB SQL API (from https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/cosmos/azure-spring-data-cosmos, https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/spring/azure-spring-data-cosmos)
- ThreeTen backport (from https://github.com/ThreeTen/threetenbp, https://www.threeten.org/threetenbp)
- adal4j (from https://github.com/AzureAD/azure-activedirectory-library-for-java)
- botocore (from https://github.com/boto/botocore)
- micrometer-core (from https://github.com/micrometer-metrics/micrometer)
......
......@@ -43,6 +43,12 @@ Instructions for running and testing this service can be found [here](./provider
All the Swagger and OpenAPI related common properties are managed here [swagger.properties](./schema-core/src/main/resources/swagger.properties)
#### Server Url(full path vs relative path) configuration
- `api.server.fullUrl.enabled=true` It will generate full server url in the OpenAPI swagger
- `api.server.fullUrl.enabled=false` It will generate only the contextPath only
- default value is false (Currently only in Azure it is enabled)
[Reference]:(https://springdoc.org/faq.html#_how_is_server_url_generated)
## License
Copyright 2017-2020, Schlumberger
......
......@@ -88,4 +88,7 @@ osdu.azure.system.cosmosDBAccountKeyName=system-cosmos-endpoint
osdu.azure.system.cosmosPrimaryKeyName=system-cosmos-primary-key
osdu.azure.system.cosmosConnectionStringKeyName=system-cosmos-connection
osdu.azure.system.storageAccountNameKeyName=system-storage
osdu.azure.system.storageKeyKeyName=system-storage-key
\ No newline at end of file
osdu.azure.system.storageKeyKeyName=system-storage-key
# To enable the full server path url in OpenAPI Swagger
api.server.fullUrl.enabled=${swaggerFullUrlEnabled:true}
\ No newline at end of file
package org.opengroup.osdu.schema.swagger;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Getter
@Setter
@Component
@ConfigurationProperties(prefix = "swagger")
public class SwaggerConfigurationProperties {
private String apiTitle;
private String apiDescription;
private String apiVersion;
private String apiContactName;
private String apiContactEmail;
private String apiLicenseName;
private String apiLicenseUrl;
private String apiServerUrl;
private boolean apiServerFullUrlEnabled;
}
\ No newline at end of file
......@@ -14,34 +14,69 @@ limitations under the License.*/
package org.opengroup.osdu.schema.swagger;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
import io.swagger.v3.oas.annotations.info.Contact;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.info.License;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.security.SecurityScheme;
import io.swagger.v3.oas.annotations.servers.Server;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import io.swagger.v3.oas.models.servers.Server;
import io.swagger.v3.oas.models.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@OpenAPIDefinition(
info = @Info(
title = "${api.title}",
description = "${api.description}",
version = "${api.version}",
contact = @Contact(name = "${api.contact.name}", email = "${api.contact.email}"),
license = @License(name = "${api.license.name}", url = "${api.license.url}")),
servers = @Server(url = "${api.server.url}"),
security = @SecurityRequirement(name = "Authorization"),
tags = {
@Tag(name = "schema-api", description = "Schema API - Core Schema related endpoints"),
@Tag(name = "system-schema-api", description = "System Schema API - System Schema related endpoints"),
@Tag(name = "info", description = "Version info endpoint")
}
)
@SecurityScheme(name = "Authorization", scheme = "bearer", bearerFormat = "Authorization", type = SecuritySchemeType.HTTP)
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@Configuration
public class SwaggerDocumentationConfig {
@Autowired
private SwaggerConfigurationProperties configurationProperties;
@Bean
public OpenAPI customOpenAPI() {
SecurityScheme securityScheme = new SecurityScheme()
.type(SecurityScheme.Type.HTTP)
.scheme("bearer")
.bearerFormat("Authorization")
.in(SecurityScheme.In.HEADER)
.name("Authorization");
final String securitySchemeName = "Authorization";
SecurityRequirement securityRequirement = new SecurityRequirement().addList(securitySchemeName);
Components components = new Components().addSecuritySchemes(securitySchemeName, securityScheme);
OpenAPI openAPI = new OpenAPI()
.addSecurityItem(securityRequirement)
.components(components)
.info(apiInfo())
.tags(tags());
if (configurationProperties.isApiServerFullUrlEnabled())
return openAPI;
return openAPI
.servers(Arrays.asList(new Server().url(configurationProperties.getApiServerUrl())));
}
private List<Tag> tags() {
List<Tag> tags = new ArrayList<>();
tags.add(new Tag().name("schema-api").description("Schema API - Core Schema related endpoints"));
tags.add(new Tag().name("system-schema-api").description("System Schema API - System Schema related endpoints"));
tags.add(new Tag().name("info").description("Version info endpoint"));
return tags;
}
private Info apiInfo() {
return new Info()
.title(configurationProperties.getApiTitle())
.description(configurationProperties.getApiDescription())
.version(configurationProperties.getApiVersion())
.license(new License().name(configurationProperties.getApiLicenseName()).url(configurationProperties.getApiLicenseUrl()))
.contact(new Contact().name(configurationProperties.getApiContactName()).email(configurationProperties.getApiContactEmail()));
}
}
......@@ -9,15 +9,16 @@ springdoc.swagger-ui.displayOperationId=true
springdoc.api-docs.path=/api-docs
#OpenAPI 3.0 - Schema Service properties
api.title=Schema Service
api.description=Schema Service enables a centralized governance and management of schema in the Data Ecosystem. It offers an implementation of the schema standard. \
swagger.apiTitle=Schema Service
swagger.apiDescription=Schema Service enables a centralized governance and management of schema in the Data Ecosystem. It offers an implementation of the schema standard. \
<p>Schema Service provides all necessary APIs to Fetch, create, update and mark a schema obsolete.</p>
api.version=1.0
api.contact.name=OSDU Data Platform Team
api.contact.email=dps@OSDU.org
api.license.name=Apache 2.0
api.license.url=https://www.apache.org/licenses/LICENSE-2.0.html
api.server.url=${server.servlet.context-path}
swagger.apiVersion=1.0
swagger.apiContactName=OSDU Data Platform Team
swagger.apiContactEmail=dps@OSDU.org
swagger.apiLicenseName=Apache 2.0
swagger.apiLicenseUrl=https://www.apache.org/licenses/LICENSE-2.0.html
swagger.apiServerUrl=${server.servlet.context-path:/}
swagger.apiServerFullUrlEnabled=${api.server.fullUrl.enabled:false}
#Schema API related properties
schemaApi.createSchema.summary=Adds a schema to the schema repository.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment