Always add model disputePrefix
Closed this issue · 2 comments
Moved from: https://bitbucket.org/echo_rm/openapi-merge-cli/issues/15/add-model-prefix-always
Initial Post
Hey mate
Would it be possible to use the disputePrefix ALWAYS for the Models and Components?
Maybe by adding a further configOption: alwaysUseDisputePrefix
That would really fit my need.
Thanks
Robert Response
Everything is possible but can you expand a bit more on why you want this feature? 🙂
For example, why not just put in the prefixes in the original schema file? Also, do you still expect deduplication to occur if you use a fixed prefix?
Daniel Response
Thanks for your Answer!
I am mergin a couple of API-Specs together and serving it in one place, at my gateway api.
So i have api-doc A which has Models like (Device, Measurement, Customer, Contact), with disputePrefix A
And i have api-doc B which has Modles like (Weather, Measurement, Customer, Location) with disputePrefix B
Obviously Measurement and Customer will conflict.
Device, Weather and Location will not conflict.
Having that i merge my Api-doc and create via codegen ONE client. There now i Have These Models:
Device, AMeasurement, BMeasurement, ACustomer, BCustomer, Weather, Contact, Location
So far so good. i implement and work with the models on my client.
BUT now i add a third api-doc to my Gateway-api-doc:
api-doc C which has Models like (Contact) with disputePrefix C
After the merge i end UP with my former Contact Model from Api-Doc A is renamed to AContact and is breaking my code in the client. (Because the ModelName changed, because API-doc C has also a Model called Contact → resolving into CContact).
In order to prevent those changes i would like to Prefix each Model from the very beginning, not only in conflict. This will prevent a rename of the model in the future in case of conflict.
So my answer to Question 1)
Because i do not have the power to change the Schema-Files in the server, nor do i want to “parse” and “prefix” models myself in the json-api-doc
To Question 2)
If i use a fixed prefix i would suppose no deduplication is necessary anymore, except the case i would give two input-sources the same prefix, but then… well. then it’s my fault 😉
Could I clarify?
Daniel follow up
hello Robert
Any news on this?
Kind regards
Daniel
This has been fixed in:
- openapi-merge: 1.3.0
- openapi-merge-cli: 1.3.0
Please read the documentation for more details: https://github.com/robertmassaioli/openapi-merge/wiki/configuration-definitions-dispute