From 483b013bece9d460cb3d761d3781ec0d2485d0a7 Mon Sep 17 00:00:00 2001 From: Ralf Ueberfuhr Date: Tue, 18 Jun 2024 10:38:37 +0200 Subject: [PATCH] Rename birthdate to birth_date. --- .../src/main/java/de/schulung/sample/quarkus/Customer.java | 4 +++- .../java/de/schulung/sample/quarkus/CustomerApiTests.java | 6 +++--- openapi.yml | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/customer-api-provider/src/main/java/de/schulung/sample/quarkus/Customer.java b/customer-api-provider/src/main/java/de/schulung/sample/quarkus/Customer.java index d118c4b..ae2fb12 100644 --- a/customer-api-provider/src/main/java/de/schulung/sample/quarkus/Customer.java +++ b/customer-api-provider/src/main/java/de/schulung/sample/quarkus/Customer.java @@ -1,5 +1,6 @@ package de.schulung.sample.quarkus; +import jakarta.json.bind.annotation.JsonbProperty; import jakarta.json.bind.annotation.JsonbTransient; import lombok.AllArgsConstructor; import lombok.Getter; @@ -19,7 +20,8 @@ public class Customer { @Setter(onMethod_ = @JsonbTransient) private UUID uuid; private String name; - private LocalDate birthdate; // TODO birth_date? + @JsonbProperty("birth_date") // TODO -> use snake_case globally? + private LocalDate birthdate; private String state; } diff --git a/customer-api-provider/src/test/java/de/schulung/sample/quarkus/CustomerApiTests.java b/customer-api-provider/src/test/java/de/schulung/sample/quarkus/CustomerApiTests.java index 55af7ec..6a9e068 100644 --- a/customer-api-provider/src/test/java/de/schulung/sample/quarkus/CustomerApiTests.java +++ b/customer-api-provider/src/test/java/de/schulung/sample/quarkus/CustomerApiTests.java @@ -64,7 +64,7 @@ void shouldCreateCustomer() { .body(""" { "name": "Tom", - "birthdate": "2000-10-04", + "birth_date": "2000-10-04", "state": "active" } """) @@ -76,7 +76,7 @@ void shouldCreateCustomer() { .header("Location", startsWith("http")) .contentType(ContentType.JSON) .body("name", is(equalTo("Tom"))) - .body("birthdate", is(equalTo("2000-10-04"))) + .body("birth_date", is(equalTo("2000-10-04"))) .body("uuid", is(notNullValue())) .extract() .header("Location"); @@ -88,7 +88,7 @@ void shouldCreateCustomer() { .then() .statusCode(200) .body("name", is(equalTo("Tom"))) - .body("birthdate", is(equalTo("2000-10-04"))); + .body("birth_date", is(equalTo("2000-10-04"))); } } diff --git a/openapi.yml b/openapi.yml index 213c56b..94b7fbd 100644 --- a/openapi.yml +++ b/openapi.yml @@ -246,7 +246,7 @@ components: - disabled Customer: required: - - birthdate + - birth_date - name type: object properties: @@ -259,7 +259,7 @@ components: maxLength: 100 type: string example: Tom Mayer - birthdate: + birth_date: type: string format: date state: