Skip to content

Commit

Permalink
fixes #361 add openapi-inject into the map with key adm in multiple s…
Browse files Browse the repository at this point in the history
…pecs
  • Loading branch information
stevehu committed Apr 4, 2024
1 parent 4967445 commit ff98822
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,16 @@ public OpenApiHandler(OpenApiHandlerConfig cfg) {
// multiple specifications in the same handler.
Map<String, Object> pathSpecMapping = config.getPathSpecMapping();
helperMap = new HashMap<>();

// add adm helper to the helperMap
if(inject != null) {
try {
OpenApiHelper h = new OpenApiHelper(Config.getInstance().getMapper().writeValueAsString(inject));
helperMap.put("/adm", h);
} catch (JsonProcessingException e) {
logger.error("parse inject failed for adm");
throw new RuntimeException("parse inject failed for adm");
}
}
// iterate the mapping to load the specifications.
for (Map.Entry<String, Object> entry : pathSpecMapping.entrySet()) {

Expand All @@ -98,7 +107,9 @@ public OpenApiHandler(OpenApiHandlerConfig cfg) {

this.validateSpec(openapi, inject, entry.getKey());

openapi = OpenApiHelper.merge(openapi, inject);
// no need to merge the inject as the path is not the same as the openapi
// openapi = OpenApiHelper.merge(openapi, inject);

try {
OpenApiHelper h = new OpenApiHelper(Config.getInstance().getMapper().writeValueAsString(openapi));
helperMap.put(entry.getKey(), h);
Expand Down

0 comments on commit ff98822

Please sign in to comment.