swagger-core icon indicating copy to clipboard operation
swagger-core copied to clipboard

Overriding Models

Open akoshman opened this issue 9 years ago • 2 comments

Since Wiki's page "Overriding Models" https://github.com/swagger-api/swagger-core/wiki/overriding-models is obsolete, I tried up-to-date technique https://github.com/swagger-api/swagger-core/issues/1274#issuecomment-217916279 : I used the SamplePropertyConverter from https://github.com/swagger-api/swagger-core/blob/master/modules/swagger-core/src/test/java/io/swagger/model/override/SamplePropertyConverter.java and then registered this converter as

ModelConverters.getInstance().addConverter(new SamplePropertyConverter());

But ModelConverters is a signleton which means all the converters will be registered for all swagger applications (I use BeanConfig) in one JVM. Is there any way to bind BeanConfig instance with converters?

Also can anyone tell me what's the difference and what's the point of having two methods in ModelConverter -> resolveProperty and resolve?

Thanks

akoshman avatar Mar 29 '17 14:03 akoshman

For what sake at all was that ModelConverters made a static singleton? Why not to have single ModelConverterContext per Reader object, for example?

At the moment we have several JAX-RS applications running in the same container and there is no way to set different ModelConverter-s for different JAX-RS applications since they all share the same ModelConverters.INSTANCE. The only hack is in controlling ModelConverters state and reinitializing it appropriately before the initialization of the particular Swagger instance but it's thread unsafe, obscure and error-prone approach.

daniil-dubin avatar Apr 04 '17 16:04 daniil-dubin

Closing this issue as part of our backlog cleanup effort.
This issue is outdated and/or inactive for a long time, and we’re not able to revisit it meaningfully.

If this problem is still relevant, please open a new issue and reference this one for context.
Thank you for your understanding!

MichakrawSB avatar Mar 08 '26 19:03 MichakrawSB