-
Notifications
You must be signed in to change notification settings - Fork 49
Add OpenAPI task implementation #804
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Dmitrii Tikhomirov <[email protected]>
Signed-off-by: Dmitrii Tikhomirov <[email protected]>
Signed-off-by: Dmitrii Tikhomirov <[email protected]>
I'm gonna add more tests soon |
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 class is already defined here https://github.com/serverlessworkflow/sdk-java/blob/main/impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/HttpExecutor.java#L207-L218
I think we should make it public and reuse here
WorkflowContext workflowContext, TaskContext taskContext, WorkflowModel input) { | ||
String operationId = task.getWith().getOperationId(); | ||
URI openAPIEndpoint = targetSupplier.apply(workflowContext, taskContext, input); | ||
OpenAPIProcessor processor = new OpenAPIProcessor(operationId, openAPIEndpoint); | ||
OperationDefinition operation = processor.parse(); | ||
|
||
OperationPathResolver pathResolver = | ||
new OperationPathResolver( | ||
operation.getPath(), | ||
application, | ||
task.getWith().getParameters().getAdditionalProperties()); |
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 think all this stuff should be moved to init method (thy are always the same for different executions, so they only need to be processed once)
HttpCallAdapter httpCallAdapter = | ||
new HttpCallAdapter() | ||
.auth(task.getWith().getAuthentication()) | ||
.body(operation.getBody()) | ||
.contentType(operation.getContentType()) | ||
.headers( | ||
operation.getParameters().stream() | ||
.filter(p -> "header".equals(p.getIn())) | ||
.collect(Collectors.toUnmodifiableSet())) | ||
.method(operation.getMethod()) | ||
.query( | ||
operation.getParameters().stream() | ||
.filter(p -> "query".equals(p.getIn())) | ||
.collect(Collectors.toUnmodifiableSet())) | ||
.redirect(task.getWith().isRedirect()) | ||
.target(pathResolver.resolve(workflowContext, taskContext, input)) | ||
.workflowParams(task.getWith().getParameters().getAdditionalProperties()); | ||
|
||
WorkflowException workflowException = null; | ||
|
||
for (var server : operation.getServers()) { | ||
CallHTTP callHTTP = httpCallAdapter.server(server).build(); | ||
HttpExecutor executor = new HttpExecutor(); | ||
executor.init(callHTTP, workflow, application, resourceLoader); |
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.
Same hre the HttpExecutor,init should be called on OpenApiExecutor.init.
The idea is to keep the apply method as minimum as possible
[Many thanks for submitting your Pull Request ❤️!
What this PR does / why we need it:
Fix #477
Special notes for reviewers:
Additional information (if needed):]