springfox: 2.6.0 : Properties are not read anymore (regression)

Values from property file are not read when including @EnableSwagger2 I’ve added a /test endpoint in this commit to show the issue

curl "http://localhost:8081/springfox/test"
8080

Response should be 8081.

Downgrading to 2.5.0 solves the issue.

Probably linked to https://github.com/springfox/springfox/commit/e545b61e46513c131a009bf82ab2879ca4cc58d0

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 18 (12 by maintainers)

Commits related to this issue

Most upvoted comments

@jayanderson Within the next week

Ok, Good news. I traced down our issue and it seems that the current behaviour is fine, whereas up to version 2.5.0 Swagger was masking some errors we had in our code. We had some properties defined as such:

@Value("${defaults.whatever}")
private String defaultWhatever;

This placeholder has no default value, so it means the property is mandatory. Up to 2.5.0, I’m presuming Swagger was doing something and providing a default value for those properties. Using 2.6.X, Swagger does not provide a default value and SpringBoot complains, rightly so, that it cannot resolve ${defaults.whatever}.

So, in this case, it was a misconfiguration in our side that had been masked. Once we specified that the properties are optional with the colon at the end, everything worked.

@Value("${defaults.whatever:}")

Cheers!

@dilipkrish It works like a charm. Thanks for your quick answer ! I’ll upgrade to 2.6.1 as soon as it’s released.