Added OpenAPI / Swagger option

This commit is contained in:
jkv
2021-11-10 20:57:31 +01:00
parent eaffce0d42
commit ea3f10ec86
4 changed files with 22 additions and 0 deletions

View File

@@ -112,6 +112,12 @@
<artifactId>hapi-fhir-jpaserver-mdm</artifactId> <artifactId>hapi-fhir-jpaserver-mdm</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<!-- This dependency includes the OpenAPI Server -->
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-server-openapi</artifactId>
<version>${project.version}</version>
</dependency>
<!-- This dependency is used for the "FHIR Tester" web app overlay --> <!-- This dependency is used for the "FHIR Tester" web app overlay -->
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>

View File

@@ -22,6 +22,7 @@ import java.util.Objects;
public class AppProperties { public class AppProperties {
private Boolean cql_enabled = false; private Boolean cql_enabled = false;
private Boolean openapi_enabled = false;
private Boolean mdm_enabled = false; private Boolean mdm_enabled = false;
private Boolean allow_cascading_deletes = false; private Boolean allow_cascading_deletes = false;
private Boolean allow_contains_searches = true; private Boolean allow_contains_searches = true;
@@ -75,6 +76,14 @@ public class AppProperties {
private Boolean use_apache_address_strategy = false; private Boolean use_apache_address_strategy = false;
private Boolean use_apache_address_strategy_https = false; private Boolean use_apache_address_strategy_https = false;
public Boolean getOpenapi_enabled() {
return openapi_enabled;
}
public void setOpenapi_enabled(Boolean openapi_enabled) {
this.openapi_enabled = openapi_enabled;
}
public Boolean getUse_apache_address_strategy() { public Boolean getUse_apache_address_strategy() {
return use_apache_address_strategy; return use_apache_address_strategy;
} }

View File

@@ -28,6 +28,7 @@ import ca.uhn.fhir.mdm.provider.MdmProviderLoader;
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator; import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
import ca.uhn.fhir.narrative.INarrativeGenerator; import ca.uhn.fhir.narrative.INarrativeGenerator;
import ca.uhn.fhir.narrative2.NullNarrativeGenerator; import ca.uhn.fhir.narrative2.NullNarrativeGenerator;
import ca.uhn.fhir.rest.openapi.OpenApiInterceptor;
import ca.uhn.fhir.rest.server.ApacheProxyAddressStrategy; import ca.uhn.fhir.rest.server.ApacheProxyAddressStrategy;
import ca.uhn.fhir.rest.server.ETagSupportEnum; import ca.uhn.fhir.rest.server.ETagSupportEnum;
import ca.uhn.fhir.rest.server.HardcodedServerAddressStrategy; import ca.uhn.fhir.rest.server.HardcodedServerAddressStrategy;
@@ -357,6 +358,10 @@ public class BaseJpaRestfulServer extends RestfulServer {
daoConfig.setDeferIndexingForCodesystemsOfSize(appProperties.getDefer_indexing_for_codesystems_of_size()); daoConfig.setDeferIndexingForCodesystemsOfSize(appProperties.getDefer_indexing_for_codesystems_of_size());
if (appProperties.getOpenapi_enabled()) {
registerInterceptor(new OpenApiInterceptor());
}
// Bulk Export // Bulk Export
if (appProperties.getBulk_export_enabled()) { if (appProperties.getBulk_export_enabled()) {
registerProvider(bulkDataExportProvider); registerProvider(bulkDataExportProvider);

View File

@@ -36,6 +36,8 @@ spring:
allow-bean-definition-overriding: true allow-bean-definition-overriding: true
hapi: hapi:
fhir: fhir:
### This enables the swagger-ui at /fhir/swagger-ui/index.html as well as the /fhir/api-docs (see https://hapifhir.io/hapi-fhir/docs/server_plain/openapi.html)
openapi_enabled: true
### This is the FHIR version. Choose between, DSTU2, DSTU3, R4 or R5 ### This is the FHIR version. Choose between, DSTU2, DSTU3, R4 or R5
fhir_version: R4 fhir_version: R4
### enable to use the ApacheProxyAddressStrategy which uses X-Forwarded-* headers ### enable to use the ApacheProxyAddressStrategy which uses X-Forwarded-* headers