Skip to content

Commit

Permalink
[plugins/asyncapi-spring-cloud-streams3] adds support for `modelNameP…
Browse files Browse the repository at this point in the history
…refix` and `modelNameSuffix`
  • Loading branch information
ivangsa committed Sep 1, 2024
1 parent 37e4ebc commit 5dfb6ab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions plugins/asyncapi-spring-cloud-streams3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ jbang zw -p io.zenwave360.sdk.plugins.SpringCloudStreams3Plugin --help
| `exposeMessage` | Whether to expose underlying spring Message to consumers or not. | boolean | false | |
| `apiPackage` | Java API package name for producerApiPackage and consumerApiPackage if not specified. | String | | |
| `modelPackage` | Java Models package name | String | | |
| `modelNamePrefix` | Sets the prefix for model classes and enums | String | | |
| `modelNameSuffix` | Sets the suffix for model classes and enums | String | | |
| `producerApiPackage` | Java API package name for outbound (producer) services. It can override apiPackage for producers. | String | {{apiPackage}} | |
| `consumerApiPackage` | Java API package name for inbound (consumer) services. It can override apiPackage for consumer. | String | {{apiPackage}} | |
| `bindingTypes` | Binding names to include in code generation. Generates code for ALL bindings if left empty | List | | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ public String getSchemaFormat(String asyncApiVersion) {

}

@DocumentedOption(description = "Sets the prefix for model classes and enums")
public String modelNamePrefix;

@DocumentedOption(description = "Sets the suffix for model classes and enums")
public String modelNameSuffix;

@DocumentedOption(description = "AsyncAPI extension property name for runtime autoconfiguration of headers.")
public String runtimeHeadersProperty = "x-runtime-expression";

Expand Down Expand Up @@ -226,7 +232,7 @@ public void calculateMessageParamType(Map<String, Object> apiModel, Map<String,
if ("asyncapi".equals(schemaFormat) || "openapi".equals(schemaFormat)) {
javaType = normalizeTagName(JSONPath.getFirst(message, "$.payload.schema.x--schema-name", "$.payload.x--schema-name"));
if (javaType == null) {
javaType = normalizeTagName((String) message.getOrDefault("x-javaType", message.getOrDefault("messageId", message.get("name"))));
javaType = modelNamePrefix + normalizeTagName((String) message.getOrDefault("x-javaType", message.getOrDefault("messageId", message.get("name")))) + modelNameSuffix;
}
}

Expand Down

0 comments on commit 5dfb6ab

Please sign in to comment.