Skip to content

Commit

Permalink
Fixed request body enum
Browse files Browse the repository at this point in the history
  • Loading branch information
altro3 committed Dec 6, 2024
1 parent c231aa0 commit 516c3f3
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class JavaMicronautClientCodegenTest extends AbstractMicronautCodegenTest {

@Test
void clientOptsUnicity() {
void clientOptsUniqueness() {
var codegen = new JavaMicronautClientCodegen();
codegen.cliOptions()
.stream()
Expand Down Expand Up @@ -557,7 +557,7 @@ void testParamsWithDefaultValue() {

assertFileContains(path + "api/DefaultApi.java",
"@QueryValue(\"ids\") @Nullable List<@NotNull Integer> ids",
"@PathVariable(name = \"apiVersion\", defaultValue = \"v5\") @Nullable BrowseSearchOrdersApiVersionParameter apiVersio",
"@PathVariable(name = \"apiVersion\", defaultValue = \"v5\") @Nullable BrowseSearchOrdersApiVersionParameter apiVersion",
"@Header(name = \"Content-Type\", defaultValue = \"application/json\") @Nullable String contentType"
);
}
Expand Down Expand Up @@ -1460,4 +1460,31 @@ public int hashCode() {
}
""");
}

@Test
void testBodyEnum() {

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

// assertFileNotContains(path + "model/SalesInvoiceCreateDto.java", "@JsonPropertyOrder");
// assertFileContains(path + "model/SalesInvoiceCreateDto.java", """
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
// return super.equals(o);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(super.hashCode());
// }
// """);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class JavaMicronautServerCodegenTest extends AbstractMicronautCodegenTest {
static String MULTI_TAGS_TEST_PATH = "src/test/resources/3_0/micronaut/multi-tags-test.yaml";

@Test
void clientOptsUnicity() {
void clientOptsUniqueness() {
var codegen = new JavaMicronautServerCodegen();
codegen.cliOptions()
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class KotlinMicronautClientCodegenTest extends AbstractMicronautCodegenTest {

@Test
void clientOptsUnicity() {
void clientOptsUniqueness() {
var codegen = new KotlinMicronautClientCodegen();
codegen.cliOptions()
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class KotlinMicronautServerCodegenTest extends AbstractMicronautCodegenTest {
static String MULTI_TAGS_TEST_PATH = "src/test/resources/3_0/micronaut/multi-tags-test.yaml";

@Test
void clientOptsUnicity() {
void clientOptsUniqueness() {
var codegen = new KotlinMicronautServerCodegen();
codegen.cliOptions()
.stream()
Expand Down
38 changes: 38 additions & 0 deletions openapi-generator/src/test/resources/3_0/body-enum.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
openapi: 3.1.0
info:
version: '1.0.0'
title: 'OpenAPI BUG REST API'
servers:
- url: 'localhost:3000'

paths:
/api/v1/colors:
post:
tags: [ my-custom ]
operationId: "selectColor"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/Color"
responses:
"200":
description: "OK"

components:
schemas:

Color:
type: string
enum:
- GREEN
- RED
- WHITE
- BLACK
- YELLOW
- BLUE

tags:
- name: my-custom
description: 'All API operations'

0 comments on commit 516c3f3

Please sign in to comment.