-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add API Gateway #1572
Add API Gateway #1572
Conversation
JaCoCo Test Coverage
|
@@ -11,9 +11,6 @@ plugins { | |||
dependencies { | |||
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310' | |||
|
|||
// Added | |||
implementation 'javax.validation:validation-api' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to import this for all java projects, plus Spring Boot 3 uses jakarta
instead.
@@ -17,7 +17,6 @@ plugins { | |||
id 'starter.java.deps-springdoc-conventions' | |||
|
|||
// Use our `local` container variants | |||
id 'local.java.container-conventions' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
local.java.container-spring-conventions
already includes local.java.container-conventions
url: /app/v3/api-docs | ||
- name: Contention Classification API | ||
# Use the route defined under spring.cloud.gateway below | ||
url: /contention-classification/openapi.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lukey-luke If you the location of the openapi.json
changes, please update this line.
filters: | ||
- RewritePath=/app/(?<path>.*), /$\{path} | ||
- id: contention-classification-tenant | ||
# TODO: add Swagger servers such that /contention-classification is used as the prefix for requests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1 @@ | |||
spring_boot_version=3.0.6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Spring Boot 3. The rest of VRO is using Spring Boot 2.
c8afd39
to
5feb2d9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would love to see included a README file and automated tests. In a README, it would be useful to be able to find out what exactly this api gateway does. Is it just url-mapping? Authentication? Throttling? I'm pretty sure api gateways have been known to do a variety of things like this.
@Configuration | ||
public class OpenApiConfiguration { | ||
@Autowired | ||
private final OpenApiProperties openApiProperties = new OpenApiProperties(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it a little unusual to initialize @autowired
member of a class? Seems to mildly defeat the purpose of dependency injection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was copied from
@Autowired private final OpenApiProperties openApiProperties = new OpenApiProperties(); |
I removed @Autowired
and added @RequiredArgsConstructor
.
.title(info.getTitle()) | ||
.description(info.getDescription()) | ||
.version(info.getVersion()) | ||
.license(new License().name(license.getName()).url(license.getUrl())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to not just pass existing contact and license objects? It would make the code simpler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They're different object types:
io.swagger.v3.oas.models.info.Contact
- what is expectedgov.va.vro.propmodel.Contact
- what we create as a result of parsing theapplication.yaml
file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this ain't being used right now, i'm good with testing being included in another PR once it is potentially better exposed through docker containers and helm charts like mentioned in the PR description
Yeah, there's barely any code for unit testing. The API Gateway can be tested in an integration or end-to-end test. |
What was the problem?
VRO currently serves up its API using Spring MVC. This constrains implementations of new APIs to be written using Spring MVC and Java.
How does this fix it?
To support serving up APIs implemented in other languages (i.e., Python used by the CC Team), implement a VRO Gateway that acts as a proxy to forward requests to the specified tenant API, as determined by the URI prefix.
Referring to https://piotrminkowski.com/2020/02/20/microservices-api-documentation-with-springdoc-openapi/, implement using Spring Boot 3 and Spring Cloud Gateway.
Creating a docker image and enabling Helm deployment will be done in a separate PR
How to test this PR
./gradlew :api-gateway:bootRun