Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lost import for inner enums #1731

Merged
merged 1 commit into from
Sep 4, 2024
Merged
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 @@ -8,6 +8,7 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;
import java.util.Objects;
import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
{{#useOptional}}
import java.util.Optional;
{{/useOptional}}
Expand Down Expand Up @@ -69,7 +70,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
{{#models}}
{{#model}}
{{#isEnum}}
import java.util.function.Function;

{{>common/model/enum}}
{{/isEnum}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,4 +613,14 @@ void testImplicitHeadersRegex() {
"@Header(name = \"Content-Type\", defaultValue = \"application/json\") @Nullable String contentType"
);
}

@Test
void testInnerEnum() {

var codegen = new JavaMicronautClientCodegen();
String outputPath = generateFiles(codegen, "src/test/resources/3_0/inner-enum.yml", CodegenConstants.MODELS);
String path = outputPath + "src/main/java/org/openapitools/";

assertFileContains(path + "model/CustomerCreateDTO.java", "import java.util.function.Function;");
}
}
124 changes: 124 additions & 0 deletions openapi-generator/src/test/resources/3_0/inner-enum.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
openapi: "3.0.0"
info:
version: 1.0.0
title: Compute API
description: API for the Compute Service
servers:
- url: localhost:8000/api
description: The api server

paths:
/sendEnum:
get:
operationId: sendEnum
tags: [ parameters ]
parameters:
- name: name
in: query
required: true
schema:
$ref: "#/components/schemas/StringEnum"
- name: intEnum
in: query
required: true
schema:
$ref: "#/components/schemas/IntEnum"
- name: longEnum
in: query
required: true
schema:
$ref: "#/components/schemas/LongEnum"
- name: boolEnum
in: query
required: true
schema:
$ref: "#/components/schemas/BooleanEnum"
- name: decimalEnum
in: query
required: true
schema:
$ref: "#/components/schemas/DecimalEnum"
responses:
200:
description: Success
components:
schemas:
CustomerCreateDTO:
type: object
required:
- profile
- nip
allOf:
- $ref: '#/components/schemas/CustomerUpdateDTO'
- type: object
properties:
profile:
type: string
enum:
- individual
- corporate
nip:
type: string
maxLength: 128
minLength: 8
CustomerUpdateDTO:
type: object
required:
- street
- buildingNumber
- postalCode
- city
- email
- parking
- licensePlate
properties:
firstName:
type: string
maxLength: 128
lastName:
type: string
maxLength: 128
companyName:
type: string
maxLength: 256
street:
type: string
maxLength: 512
buildingNumber:
type: string
maxLength: 64
apartmentNumber:
type: string
maxLength: 32
postalCode:
type: string
maxLength: 16
city:
type: string
maxLength: 256
email:
type: string
maxLength: 256
format: email
licensePlate:
type: string
maxLength: 64
notes:
type: string
maxLength: 512
StringEnum:
type: string
enum: ['starting', 'running', 'stopped', 'deleted']
IntEnum:
type: integer
enum: [1, 2, 3, 4, 5]
LongEnum:
type: integer
format: int64
enum: [1, 2, 3, 4, 5]
BooleanEnum:
type: boolean
enum: ['true', 'false']
DecimalEnum:
type: number
enum: [1.23, 2.45, 34.10]
Loading