maxdome / swagger-combine

Combines multiple Swagger schemas into one dereferenced schema.
MIT License
132 stars 36 forks source link

Enable automatic OperationID conflicts resolving #122

Open Bohdan-Kalynovskyi opened 2 years ago

Bohdan-Kalynovskyi commented 2 years ago

I'm trying to merge several swagger files from similar APIs. Each swagger file contains the ping endpoint having the same OperationID:

"/ping": { "get": { "operationId": "getPing",

This results in a conflict. --continueOnError does not help, the combined file is not generated.

IMHO, my use case is rather common, so can I open a PR that would automatically rename getPing to getPing1 or fix it in any other way?

Suggestions appreciated

odupuy commented 2 years ago

In our case, we have conflicts on operation Ids, so we simply removed them before merging

    # Swagger specification https://swagger.io/specification/
    # - the operationId field must be unique, it used for the code generation but does not matter here, get rid of it
    sed -i -e "/^.*operationId:.*$/d" tmp/src/*.yaml

Look at "Renaming Path OperationIds" in https://www.npmjs.com/package/swagger-combine

if you cannot track all the conflict an automatic renaming option could be nice.