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

Add key filter support in openapi asyncapi mapping #851

Merged
merged 5 commits into from
Mar 14, 2024

Conversation

akrambek
Copy link
Contributor

Description

Add key filter support in openapi asyncapi mapping.

@@ -119,6 +122,8 @@ private <C> BindingConfigBuilder<C> injectHttpKafkaRoutes(
final AsyncapiChannelView channel = AsyncapiChannelView
.of(asyncapi.channels, asyncapiOperation.channel);

final boolean includeKey = pathId.reset(item).find();
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 this should not depend on the name of the parameter being id, for example taxiId should be fine too.

Also, the terminology includeKey is describing anticipated usage of the parameter, which is leaking the abstraction a bit. Instead, lets call this hasParam, or perhaps even passing the parameter name(s) so we are not so dependent on it being {id} in the path vs {taxiId} for example.

if (includeKey)
{
fetch.filters(List.of(HttpKafkaWithFetchFilterConfig.builder()
.key("${params.id}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
.key("${params.id}")
.key(String.format("${params.%s}", paramName))

"fixed-tag")))))
.filters(singletonList(HttpKafkaWithFetchFilterConfig.builder()
.key("fixed-key")
.headers(singletonList(HttpKafkaWithFetchFilterHeaderConfig.builder()
Copy link
Contributor

Choose a reason for hiding this comment

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

There should also be a .header(String name, String value) method on the builder that lazily instantiates the headers list and adds the header config.

@@ -49,8 +51,10 @@
public final class OpenapiAsyncCompositeBindingAdapter implements CompositeBindingAdapterSpi
{
private static final Pattern JSON_CONTENT_TYPE = Pattern.compile("^application/(?:.+\\+)?json$");
private static final Pattern PARAMETER_PATTERN = Pattern.compile("\\{([^}]*)\\}");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
private static final Pattern PARAMETER_PATTERN = Pattern.compile("\\{([^}]*)\\}");
private static final Pattern PARAMETER_PATTERN = Pattern.compile("\\{([^}]+)\\}");

We require at least one character for parameter name, agree?

jfallows
jfallows previously approved these changes Mar 14, 2024
@jfallows jfallows merged commit 8d49a4c into aklivity:develop Mar 14, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants