Process multiple OpenAPI yaml files in Gradle #137
-
I have a project in which we have two different OpenAPI specs (one for the main API and another is a private tenant admin API that we want to keep separate from the main API for reasons). I want to have a single Java project that contains the codebase for both of these specs, is there a way in which we can configure the gradle plugin to process two separate yaml files? I would like to essentially have two different input yaml files that generate code to differently configured output directories. Any suggestions would be appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Quick answer, I have to check if this really works. :-) In theory something like this could work: openapiProcessor {
spring {
apiPath "${projectDir}/src/api/openapi.yaml"
processor 'io.openapiprocessor:openapi-processor-spring:<version>'
targetDir "${projectDir}/build/openapi"
mapping "${projectDir}/src/api/mapping.yaml"
}
spring2 {
apiPath "${projectDir}/src/api/openapi2.yaml"
processor 'io.openapiprocessor:openapi-processor-spring:<version>'
targetDir "${projectDir}/build/openapi2"
mapping "${projectDir}/src/api/mapping2.yaml"
}
} you would also have to add a second
may be best to have distinct folders for the |
Beta Was this translation helpful? Give feedback.
-
My original suggestion wasn't too far off. It was missing the It is fixed in the new plugin version 2022.1 . However, it requires gradle 7+. I hope that is not an issue. openapiProcessor {
spring2 {
processorName 'spring'
/// ....
}
} |
Beta Was this translation helpful? Give feedback.
My original suggestion wasn't too far off. It was missing the
name
override. Unfortunately there was a small bug that broke it at another place. :-(It is fixed in the new plugin version 2022.1 . However, it requires gradle 7+. I hope that is not an issue.