Skip to content

Commit

Permalink
Wildcard tag support for openapi tags config (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
slutmaker committed Jul 24, 2023
1 parent e908f3b commit cd6470e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
24 changes: 17 additions & 7 deletions mkdocs/docs/features/openapi-codegen.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,13 @@ Maven:
<configOptions>
<mode>java_client</mode>
<tags>{
"common": {
"httpClientTag": "some.tag.CanonicalName.class",
"telemetryTag": "some.tag.CanonicalName.class"
"*": { // применится для всех тегов, кроме явно указанных (в данном случае instrument)
"httpClientTag": "some.tag.Common.class",
"telemetryTag": "some.tag.Common.class"
}
"instrument": { // применится для instrument
"httpClientTag": "some.tag.Instrument.class",
"telemetryTag": "some.tag.Instrument.class"
}
}
</tags>
Expand All @@ -86,11 +90,17 @@ Gradle:
configOptions = [
mode: "java_client",
tags: """
"common": {
"httpClientTag": "some.tag.CanonicalName.class",
"telemetryTag": "some.tag.CanonicalName.class"
{
"*": { // применится для всех тегов, кроме явно указанных (в данном случае instrument)
"httpClientTag": "some.tag.Common.class",
"telemetryTag": "some.tag.Common.class"
},
"instrument": { // применится для instrument
"httpClientTag": "some.tag.Instrument.class",
"telemetryTag": "some.tag.Instrument.class"
}
}
"""
"""
]
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1243,18 +1243,24 @@ record AuthMethodGroup(String name, List<CodegenSecurity> methods) {}
}
}

TagData tagData = null;
for (var entry : this.tags.entrySet()) {
if (op.tags.stream().anyMatch(t -> t.getName().equals(entry.getKey()))) {
var tagData = entry.getValue();
if (tagData.httpClientTag != null) {
httpClientAnnotationParams.put("httpClientTag", tagData.httpClientTag);
}
if (tagData.telemetryTag != null) {
httpClientAnnotationParams.put("telemetryTag", tagData.telemetryTag);
}
tagData = entry.getValue();
break;
}
}
if (tagData == null) {
tagData = this.tags.get("*");
}
if (tagData != null) {
if (tagData.httpClientTag != null) {
httpClientAnnotationParams.put("httpClientTag", tagData.httpClientTag);
}
if (tagData.telemetryTag != null) {
httpClientAnnotationParams.put("telemetryTag", tagData.telemetryTag);
}
}

op.vendorExtensions.put("x-java-import", operationImports);
var multipartForm = op.consumes != null && op.consumes.stream()
Expand Down

0 comments on commit cd6470e

Please sign in to comment.