Document how to configure API Versioning media-type-parameter in YAML config
Closed this issue · 2 comments
j0hnc0yne commented
I'm trying out the new API Versioning for Spring Framework 7 and using the 'media-type-parameter' with YAML config that seems to have a problem parsing it.
I tried
spring:
mvc:
apiversion:
use:
media-type-parameter:
'application/json': versionand
spring:
mvc:
apiversion:
use:
media-type-parameter:
[application/json]: versionbut the parsing seems to be dropping the forward slash as the error message during initialization is:
Description:
Failed to bind properties under 'spring.mvc.apiversion.use.media-type-parameter' to java.util.Map<org.springframework.http.MediaType, java.lang.String>:
Reason: failed to convert java.lang.String to org.springframework.http.MediaType (caused by org.springframework.util.InvalidMimeTypeException: Invalid mime type "applicationjson": does not contain '/')
j0hnc0yne commented
Sorry, got this working had to make it
spring:
mvc:
apiversion:
use:
media-type-parameter:
'[application/json]': versionThis might be worth documenting somewhere, did not see it anywhere unless I missed it
wilkinsona commented
This is documented in the section on binding maps. The examples show the use of quotes:
my:
map:
"[/key1]": "value1"
"[/key2]": "value2"
"/key3": "value3"And there's a note:
NOTE: For YAML files, the brackets need to be surrounded by quotes for the keys to be parsed properly.