Hi, thanks for the follow-up. Could you please add some notes to the README in a pull request so others can refer to it?
> On Feb 21, 2017, at 1:02 AM, Abdullah Mourad <[email protected]> wrote: > > For posterity's sake: > > I ended up solving this by creating a separate context holder class which > implemented ApplicationContextAware and had a static method which would > return the application context. I ended up just calling that static method to > get my spring loaded application context and then I used that to retrieve the > relevant controller beans. > > Super simple solution to a problem that plagued me for a few days :) > > On Monday, February 20, 2017 at 10:28:53 AM UTC-8, Abdullah Mourad wrote: > Thanks, Tony! > > Thanks to your tip, I was able to use my own ControllerFactory by setting > controllerFactoryClass in inflector.yaml. I also made it implement > ApplicationContextAware and wired in my ApplicationContext successfully. > However, Inflector also tries to instantiate my controllerFacotry in > Configuration.java: > > controllerFactory = > Class.forName(controllerFactoryClass).asSubclass(ControllerFactory.class).newInstance(); > > This creates a new instance of my ControllerFactory which obviously doesn't > have my ApplicationContext. > > I tried browsing through the springboot sample code to understand how the > spring instance is wired into swagger, but it is not clear to me what is > going on. At this point I want to understand how to get Swagger to use the > same instance that I am creating via spring. > > > On Thursday, February 16, 2017 at 9:05:28 AM UTC-8, tony tam wrote: > I believe you can implement your own ControllerFactory to do this. See here: > > https://github.com/swagger-api/swagger-inflector/blob/master/src/main/java/io/swagger/inflector/config/ControllerFactory.java > > <https://github.com/swagger-api/swagger-inflector/blob/master/src/main/java/io/swagger/inflector/config/ControllerFactory.java> > >> On Feb 15, 2017, at 5:16 PM, Abdullah Mourad <[email protected] <>> wrote: >> >> To clarify, my initial instance that is created by spring is created >> correctly, but it appears that inflector creates a new instance for each >> operation - In this case my controller has 2 operations, so I end up with 3 >> separate instances of my controller. The 2 non-spring created instances do >> not have the proper fields initialized (as expected since they are not >> created via spring). >> >> On Wednesday, February 15, 2017 at 5:14:16 PM UTC-8, Abdullah Mourad wrote: >> I am using codegen to generate my controllers and inflector to route to >> them. I would like to use Spring to populate some managers in my controllers >> but inflector creates a new instance of the controller each time and those >> don't get the managers injected properly. Is there any way around this? Is >> it possible to use a single instance of my controller? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Swagger" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <>. >> For more options, visit https://groups.google.com/d/optout >> <https://groups.google.com/d/optout>. > > > -- > You received this message because you are subscribed to the Google Groups > "Swagger" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- You received this message because you are subscribed to the Google Groups "Swagger" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
