Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4057,4 +4057,37 @@ public void testOneOfInterfaceWithAnnotation() {
.isInterface()
.assertTypeAnnotations().containsWithName("SuppressWarnings");
}

@Test
public void testApiComponentNamedLocale() {
final Map<String, Object> properties = new HashMap<>();
properties.put("additionalModelTypeAnnotations",
"@SuppressWarnings(\"all\") @com.fasterxml.jackson.annotation.JsonIgnoreProperties(ignoreUnknown = true)");
properties.put("enumUnknownDefaultCase", "true");
properties.put("java8", "true");
properties.put("dateLibrary", "java8");
properties.put("failOnUnknownProperties", "false");
properties.put("sortModelPropertiesByRequiredFlag", "false");
properties.put("sortParamsByRequiredFlag", "false");
properties.put("skipSortingOperations", "true");
properties.put("generateClientAsBean", "false");
properties.put("useJakartaEe", "true");
properties.put("generateModelTests", "false");
properties.put("generateApiTests", "false");
properties.put("skipOverwrite", "false");
properties.put("removeOperationIdPrefix", "false");
properties.put("skipValidateSpec", "false");
properties.put("strictSpec", "true");

final Map<String, File> files = generateFromContract(
"src/test/resources/3_0/java/locale.yaml", RESTTEMPLATE, properties, configurator -> {
configurator.setVerbose(true);
});

JavaFileAssert.assertThat(files.get("Locale.java")).isNormalClass()
.hasNoImports("java.util.Locale");
JavaFileAssert.assertThat(files.get("GetProductLocalizationsResult.java")).isNormalClass()
.assertProperty("requestedLocales")
.withType("List<org.openapitools.client.model.Locale>");
}
}
259 changes: 259 additions & 0 deletions modules/openapi-generator/src/test/resources/3_0/java/locale.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
openapi: 3.0.1
info:
version: '1.27'
title: Example to show effects with Locale
description: This definition was taken from a real world api which was working until 7.15.0.
paths:
/api/v1/brain/product/localizations/{productId}/{version}:
post:
operationId: getProductLocalizations
summary: Get localization data for a product.
parameters:
- name: productId
in: path
description: Provide the id of the product.
required: true
schema:
type: string
minLength: 1
example: 1LE1X
- name: version
in: path
description: Provide the version of the product. Could be 'LATEST' to retrieve the newest version.
required: true
schema:
type: string
minLength: 1
example: LATEST
requestBody:
description: Required payload for the request.
required: true
content:
application/json:
examples:
0 - Only language 'en':
description: Language 'en' without country.
summary: Only language 'en'
value:
locales:
- language: en
1 - Multiple locales:
description: Locale 'EN_en' and 'DE_de'.
summary: Multiple locales
value:
locales:
- country: EN
language: en
- country: DE
language: de
schema:
$ref: '#/components/schemas/GetProductLocalizationsPayload'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/GetProductLocalizationsResult'
'400':
description: Bad Request
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetail'
'401':
description: Unauthorized
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetail'
'403':
description: Forbidden
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetail'
'404':
description: Not found
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetail'
'500':
description: Internal Server Error
content:
application/problem+json:
schema:
$ref: '#/components/schemas/ProblemDetail'
security:
- basicScheme: []
tags:
- service
- read
- v1.24
components:
schemas:
CsticLocalization:
description: Localization data of a Cstic.
type: object
properties:
longText:
type: string
name:
type: string
numberPattern:
type: string
taggedTexts:
$ref: '#/components/schemas/TaggedTexts'
text:
type: string
unit:
type: string
values:
type: array
items:
$ref: '#/components/schemas/Localization'
ElementLocalization:
description: Localization data of an Element.
type: object
properties:
cstics:
type: array
items:
$ref: '#/components/schemas/CsticLocalization'
longText:
type: string
name:
type: string
taggedTexts:
$ref: '#/components/schemas/TaggedTexts'
text:
type: string
GetProductLocalizationsPayload:
description: Container for locales.
type: object
properties:
locales:
type: array
items:
$ref: '#/components/schemas/Locale'
GetProductLocalizationsResult:
description: Result for product localization.
type: object
properties:
error:
type: string
localizations:
type: array
items:
$ref: '#/components/schemas/ProductLocalization'
productId:
type: string
requestedLocales:
type: array
items:
$ref: '#/components/schemas/Locale'
returnedFailedLocales:
type: array
items:
$ref: '#/components/schemas/Locale'
returnedSuccessfulLocales:
type: array
items:
$ref: '#/components/schemas/Locale'
version:
type: string
Locale:
description: Locale for localization.
type: object
properties:
country:
type: string
language:
type: string
Localization:
description: Localization data.
type: object
properties:
longText:
type: string
name:
type: string
taggedTexts:
$ref: '#/components/schemas/TaggedTexts'
text:
type: string
ProblemDetail:
type: object
properties:
detail:
type: string
instance:
type: string
format: uri
properties:
type: object
additionalProperties:
type: object
status:
type: integer
format: int32
title:
type: string
type:
type: string
format: uri
ProductLocalization:
description: Localization data of a Product.
type: object
properties:
elements:
type: array
items:
$ref: '#/components/schemas/ElementLocalization'
globalCstics:
type: array
items:
$ref: '#/components/schemas/CsticLocalization'
locale:
$ref: '#/components/schemas/Locale'
longText:
type: string
messages:
type: array
items:
$ref: '#/components/schemas/Localization'
name:
type: string
taggedTexts:
$ref: '#/components/schemas/TaggedTexts'
text:
type: string
TaggedText:
description: A text with free useable tags. See TextTag enum for known tags.
type: object
properties:
tags:
type: array
items:
type: string
text:
type: string
TaggedTexts:
type: object
properties:
texts:
type: array
items:
$ref: '#/components/schemas/TaggedText'
securitySchemes:
basicScheme:
scheme: basic
type: http
tags:
- description: Commmon service operations
name: service
- description: Write operations
name: write
- description: Read operations
name: read