swagger-inflector
swagger-inflector copied to clipboard
Configuration not loaded from resources in EAR
In my case 'inflector.yaml' file located inside WAR file, which is inside EAR file.
In Configuration.read() method:
Configuration.class.getClassLoader().getResource("inflector.yaml") returns URL like this:
vfs:/C:/Programs/wildfly-10.0.0.Final/bin/content/app-ear.ear/app-web.war/WEB-INF/classes/inflector.yaml
and Yaml.mapper().readValue(new File(url.getFile()), Configuration.class) can't find file.
May be it will be better to load it using following?
Yaml.mapper().readValue(Configuration.class.getClassLoader().getResourceAsStream("inflector.yaml"), Configuration.class)
As a workaround I am using following class instead of io.swagger.inflector.SwaggerInflector in web.xml:
public class Inflector extends SwaggerInflector {
public Inflector(@Context ServletContext ctx) throws IOException {
super(Yaml.mapper().readValue(Inflector.class.getClassLoader().getResourceAsStream("inflector.yaml"), Configuration.class));
}
}
Hi, you can provide the configuration many different ways, did you try passing the config location when starting your app?
https://github.com/swagger-api/swagger-inflector#configuration
Hi, configuration using inflector.yaml in class resources is most convenient for me. I don't like an idea to specify inflector config in swagger.yaml. Another option is -Dconfig=/path/to/config not suitable for me too. Please take a look on this thread https://developer.jboss.org/thread/202208, seems getResourceAsStream method is more correct in this place