kpramesh2212 / openapi-merger-plugin

A plugin to merge openapi v3 files
Apache License 2.0
20 stars 8 forks source link

Feature Request: Ability to override servers block #5

Closed EdHowe closed 3 years ago

EdHowe commented 3 years ago

It would be useful to be able to override the 'servers' block during merge.

kpramesh2212 commented 3 years ago

Could you please add more info

A sample example files showing

The unmerged files and final merged files.

EdHowe commented 3 years ago

When the plugin performs the merge, it basically throws out the 'info' block from each of the specs being merged, and replaces them with one specified in the openApiMerge extension's openApi { info { ... } } block. I'd like to be able to do the same for the servers block.

So, given a.yaml:

openapi: 3.0.1
info:
  title: API A
  version: 1.0.0
servers:
- url: "http://a.example.com"
paths: ...

and b.yaml:

openapi: 3.0.1
info:
  title: API B
  version: 1.0.0
servers:
- url: "http://b.example.com"
paths: ...

and perhaps something in my build.gradle that looks like the following:

openApiMerger {
    inputDirectory = new File("${buildDir}/api-specs")
    output {
        directory = new File("${buildDir}/openapi")
        fileName = 'openapi3'
        fileExtension = 'yaml'
    }
    openApi {
        openApiVersion = "3.0.1"
        info {
            title = "My API"
            version = "1.0.0"
        }
        servers [ "http://some.other.host.com" ]
    }
}

Then I would have ${buildDir}/openapi/openapi3.yaml containing:

openapi: 3.0.1
info:
  title: API B
  version: 1.0.0
servers:
- url: "http://some.other.host.com"
paths: ...
kpramesh2212 commented 3 years ago

@EdHowe

Very sorry for a delayed response.

I will try and provide an implementation within end of this week.

Thank you Regards Ramesh

kpramesh2212 commented 3 years ago

Hi

This feature should be avilable in the newer version.

Can you please check and provide feedback?

Regards Ramesh

kpramesh2212 commented 3 years ago

Implemented in 1.0.4