nerdErg / swagger4jaxrs

This is a Grails plugin that adds Swagger support to document REST APIs of any Grails projects that use the Grails JAX-RS (JSR 311) plugin.
Apache License 2.0
10 stars 10 forks source link

updated readme to use resources.groovy instead of applicationContext to ... #9

Closed michaelrice closed 10 years ago

michaelrice commented 10 years ago

updated readme to use resources.groovy instead of applicationContext to define bean

michaelrice commented 10 years ago

I guess I should mention this fixes issue #8

pherris commented 10 years ago

yes, it did... might I suggest adding comments about updating Config.groovy to the readme since it appears that this property is not set by default.

michaelrice commented 10 years ago

You shouldnt need to set it. Normally not setting it is better. Since grails 2.x grails does a really great job of figuring out that value on its own. I only have 1 application where we have to use it and its due to some fancy proxy passing we do to hide where it really is.

If you dont define it in your config is it getting the value wrong?

michaelrice commented 10 years ago

Just for some reference: http://stackoverflow.com/questions/8933356/how-do-i-set-grails-serverurl-in-an-enterprise-environment-when-i-dont-know-the

Burt Beckwith explains in his answer.

Its also mentioned in the upgrading from previous versions of grails guide: http://grails.org/doc/2.0.x/guide/single.html#upgradingFromPreviousVersionsOfGrails

aruizca commented 10 years ago

Awesome work @michaelrice. Thanks!! ;-)

pherris commented 10 years ago

Without the changes to Config.groovy I get the following exception when running

grails run-app

Exception:

| Error 2013-10-25 14:56:01,815 [localhost-startStop-1] ERROR context.GrailsContextLoader  - Error initializing the application: Error creating bean with name 'swaggerConfig': Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'groovy.util.ConfigObject' to required type 'java.lang.String' for property 'basePath'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [groovy.util.ConfigObject] to required type [java.lang.String] for property 'basePath': no matching editors or conversion strategy found

If I try to build with maven

mvn clean install 

without the following in Config.groovy (with the changes below mvn clean install works)

test {
    grails.serverURL = "http://localhost:8080"
}

I get the error:

|Environment set to test
..............................................................
|Running 5 unit tests...
|Completed 0 unit test, 0 failed in 0m 1s
........Error
|
Fatal error running tests: Error creating bean with name 'swaggerConfig': Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'groovy.util.ConfigObject' to required type 'java.lang.String' for property 'basePath'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [groovy.util.ConfigObject] to required type [java.lang.String] for property 'basePath': no matching editors or conversion strategy found (Use --stacktrace to see the full trace)
.Tests FAILED
michaelrice commented 10 years ago

@pherris That is rather annoying. I didnt even realize I had this defined for development. I was looking through the swagger sources and it looks like there really isnt going to be a way to avoid defining that value which is a big downer for me.

Ill update the readme again to include the note about the config. Thanks for your feedback.