Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: API doc via SwaggerUI #54

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions adapter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ dependencies {
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-csv'
implementation 'org.postgresql:postgresql'

compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.jvalue.ods.adapterservice.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no support for OpenAPI3 yet, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I think there is but it requires another library / mechanism. Probably makes sense to do so?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it make sense to use the newest version of the specification if it is included in a spring boot plugin. If we need some kind of workaround or a lot of effort I would rather wait until the spring boot compatible version is updated to the new spec.

.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
}
2 changes: 2 additions & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.postgresql:postgresql'

compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.jvalue.ods.coreservice.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
}
17 changes: 12 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,6 @@ services:
DATABASE_USER: ods_admin
DATABASE_PW: ods_pw

storage-swagger: # API documentation for storage service
image: swaggerapi/swagger-ui
environment:
API_URL: http://localhost:9400/

# ----------------- TRANSFORMATION SERVICE (/transformation) --------------------
transformation:
image: ${DOCKER_REGISTRY}/transformation
Expand Down Expand Up @@ -197,3 +192,15 @@ services:
- "9001:8080" # The Web UI (enabled by --api)
volumes:
- /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events

# --------------------- SWAGGER UI -----------------------------------------
swagger:
image: swaggerapi/swagger-ui
environment:
API_URLS: "[{ url: '/api/storage', name: 'storage' }, { url: '/api/core/v2/api-docs', name: 'core' }, { url: '/api/adapter/v2/api-docs', name: 'adapter' }, { url: '/api/scheduler/api-docs', name: 'scheduler' }, { url: '/api/transformation/api-docs', name: 'transformation' }]"
labels:
- "traefik.enable=true"
- "traefik.http.routers.to-swagger.rule=PathPrefix(`/api/docs`)"
- "traefik.http.routers.to-swagger.middlewares=swagger-stripprefix@docker"
- "traefik.http.middlewares.swagger-stripprefix.stripprefix.prefixes=/api/docs/" # without last slash: api/docs does not work, only api/docs/
- "traefik.http.services.swagger.loadbalancer.server.port=8080"
Loading