diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/core/OpenAPIService.java b/springdoc-openapi-common/src/main/java/org/springdoc/core/OpenAPIService.java index 9470a78d2..bec01a774 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/core/OpenAPIService.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/core/OpenAPIService.java @@ -729,7 +729,7 @@ public Map getControllerAdviceMap() { * @return the cached open api */ public OpenAPI getCachedOpenAPI(Locale locale) { - return cachedOpenAPI.get(locale.getLanguage()); + return cachedOpenAPI.get(locale.toLanguageTag()); } /** @@ -739,7 +739,7 @@ public OpenAPI getCachedOpenAPI(Locale locale) { * @param cachedOpenAPI the cached open api */ public void setCachedOpenAPI(OpenAPI cachedOpenAPI, Locale locale) { - this.cachedOpenAPI.put(locale.getLanguage(), cachedOpenAPI); + this.cachedOpenAPI.put(locale.toLanguageTag(), cachedOpenAPI); } /** diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app171/SpringDocApp171Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app171/SpringDocApp171Test.java index 59a505446..9c6394d9a 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app171/SpringDocApp171Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app171/SpringDocApp171Test.java @@ -48,6 +48,7 @@ public void testApp() throws Exception { Locale.setDefault(Locale.US); testApp(Locale.US); testApp(Locale.FRANCE); + testApp(Locale.UK); } private void testApp(Locale locale) throws Exception { @@ -57,7 +58,7 @@ private void testApp(Locale locale) throws Exception { mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL).locale(locale).header(HttpHeaders.ACCEPT_LANGUAGE, locale.toLanguageTag())).andExpect(status().isOk()) .andExpect(jsonPath("$.openapi", is("3.0.1"))).andReturn(); String result = mockMvcResult.getResponse().getContentAsString(); - String expected = getContent("results/app" + testNumber + "-" + locale.getLanguage() + ".json"); + String expected = getContent("results/app" + testNumber + "-" + locale.toLanguageTag() + ".json"); assertEquals(expected, result, true); } } \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/resources/messages_en_GB.properties b/springdoc-openapi-webmvc-core/src/test/resources/messages_en_GB.properties new file mode 100644 index 000000000..408cbad44 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/resources/messages_en_GB.properties @@ -0,0 +1,6 @@ +greeting=Hello! Welcome to our website![EN_GB] +lang.change=Change the language[EN_GB] +lang.eng=English[EN_GB] +lang.fr=French[EN_GB] +mySample=toto[EN_GB] +test=This is a test message[EN_GB] \ No newline at end of file diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app171-en-GB.json b/springdoc-openapi-webmvc-core/src/test/resources/results/app171-en-GB.json new file mode 100644 index 000000000..0f4cf0cc0 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/resources/results/app171-en-GB.json @@ -0,0 +1,65 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Hello! Welcome to our website![EN_GB]", + "description": "This is a test message[EN_GB]" + } + ], + "paths": { + "/test": { + "get": { + "tags": [ + "Hello! Welcome to our website![EN_GB]" + ], + "operationId": "demo2", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/persons": { + "get": { + "tags": [ + "Hello! Welcome to our website![EN_GB]" + ], + "operationId": "persons", + "parameters": [ + { + "name": "name", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app171-en.json b/springdoc-openapi-webmvc-core/src/test/resources/results/app171-en-US.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app171-en.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/app171-en-US.json diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app171-fr.json b/springdoc-openapi-webmvc-core/src/test/resources/results/app171-fr-FR.json similarity index 100% rename from springdoc-openapi-webmvc-core/src/test/resources/results/app171-fr.json rename to springdoc-openapi-webmvc-core/src/test/resources/results/app171-fr-FR.json