[Java][Microprofile] Fix #17526: enumOuterClass missing JSON-B (de)serializer (#18951)

* GH-17526/microprofile: Fix enumOuterClass missing JSON-B (de)serializer

* Add microprofile-rest-client-outer-enum to jdk17 samples workflow

* Regenerate samples
This commit is contained in:
DielN
2024-07-08 12:30:22 +02:00
committed by GitHub
parent 0820edee5d
commit a3912b7239
23 changed files with 1181 additions and 1 deletions

View File

@@ -0,0 +1,34 @@
/**
* Petstore API
* API for managing pets in a pet store
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.api;
import javax.ws.rs.core.Response;
public class ApiException extends Exception {
private static final long serialVersionUID = 1L;
private Response response;
public ApiException() {
super();
}
public ApiException(Response response) {
super("Api response has status code " + response.getStatus());
this.response = response;
}
public Response getResponse() {
return this.response;
}
}

View File

@@ -0,0 +1,33 @@
/**
* Petstore API
* API for managing pets in a pet store
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.api;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.Provider;
import org.eclipse.microprofile.rest.client.ext.ResponseExceptionMapper;
@Provider
public class ApiExceptionMapper
implements ResponseExceptionMapper<ApiException> {
@Override
public boolean handles(int status, MultivaluedMap<String, Object> headers) {
return status >= 400;
}
@Override
public ApiException toThrowable(Response response) {
return new ApiException(response);
}
}

View File

@@ -0,0 +1,61 @@
/**
* Petstore API
* API for managing pets in a pet store
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.api;
import org.openapitools.client.model.Cat;
import org.openapitools.client.model.Dog;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.MediaType;
import org.apache.cxf.jaxrs.ext.multipart.*;
import org.eclipse.microprofile.rest.client.annotation.RegisterProvider;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
/**
* Petstore API
*
* <p>API for managing pets in a pet store
*
*/
@RegisterRestClient(configKey="default-api")
@RegisterProvider(ApiExceptionMapper.class)
@Path("")
public interface DefaultApi {
/**
* List all cats
*
*/
@GET
@Path("/cats")
@Produces({ "application/json" })
List<Cat> listCats() throws ApiException, ProcessingException;
/**
* List all dogs
*
*/
@GET
@Path("/dogs")
@Produces({ "application/json" })
List<Dog> listDogs() throws ApiException, ProcessingException;
}

View File

@@ -0,0 +1,126 @@
/**
* Petstore API
* API for managing pets in a pet store
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.model;
import org.openapitools.client.model.Status;
import java.lang.reflect.Type;
import javax.json.bind.annotation.JsonbTypeDeserializer;
import javax.json.bind.annotation.JsonbTypeSerializer;
import javax.json.bind.serializer.DeserializationContext;
import javax.json.bind.serializer.JsonbDeserializer;
import javax.json.bind.serializer.JsonbSerializer;
import javax.json.bind.serializer.SerializationContext;
import javax.json.stream.JsonGenerator;
import javax.json.stream.JsonParser;
import javax.json.bind.annotation.JsonbProperty;
public class Cat {
@JsonbProperty("id")
private Long id;
@JsonbProperty("name")
private String name;
@JsonbProperty("status")
private Status status;
/**
* Get id
* @return id
**/
public Long getId() {
return id;
}
/**
* Set id
*/
public void setId(Long id) {
this.id = id;
}
public Cat id(Long id) {
this.id = id;
return this;
}
/**
* Get name
* @return name
**/
public String getName() {
return name;
}
/**
* Set name
*/
public void setName(String name) {
this.name = name;
}
public Cat name(String name) {
this.name = name;
return this;
}
/**
* Get status
* @return status
**/
public Status getStatus() {
return status;
}
/**
* Set status
*/
public void setStatus(Status status) {
this.status = status;
}
public Cat status(Status status) {
this.status = status;
return this;
}
/**
* Create a string representation of this pojo.
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Cat {\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" status: ").append(toIndentedString(status)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private static String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@@ -0,0 +1,126 @@
/**
* Petstore API
* API for managing pets in a pet store
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.model;
import org.openapitools.client.model.Status;
import java.lang.reflect.Type;
import javax.json.bind.annotation.JsonbTypeDeserializer;
import javax.json.bind.annotation.JsonbTypeSerializer;
import javax.json.bind.serializer.DeserializationContext;
import javax.json.bind.serializer.JsonbDeserializer;
import javax.json.bind.serializer.JsonbSerializer;
import javax.json.bind.serializer.SerializationContext;
import javax.json.stream.JsonGenerator;
import javax.json.stream.JsonParser;
import javax.json.bind.annotation.JsonbProperty;
public class Dog {
@JsonbProperty("id")
private Long id;
@JsonbProperty("name")
private String name;
@JsonbProperty("status")
private Status status;
/**
* Get id
* @return id
**/
public Long getId() {
return id;
}
/**
* Set id
*/
public void setId(Long id) {
this.id = id;
}
public Dog id(Long id) {
this.id = id;
return this;
}
/**
* Get name
* @return name
**/
public String getName() {
return name;
}
/**
* Set name
*/
public void setName(String name) {
this.name = name;
}
public Dog name(String name) {
this.name = name;
return this;
}
/**
* Get status
* @return status
**/
public Status getStatus() {
return status;
}
/**
* Set status
*/
public void setStatus(Status status) {
this.status = status;
}
public Dog status(Status status) {
this.status = status;
return this;
}
/**
* Create a string representation of this pojo.
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Dog {\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" status: ").append(toIndentedString(status)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private static String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@@ -0,0 +1,74 @@
/**
* Petstore API
* API for managing pets in a pet store
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.model;
import java.lang.reflect.Type;
import javax.json.bind.annotation.JsonbTypeDeserializer;
import javax.json.bind.annotation.JsonbTypeSerializer;
import javax.json.bind.serializer.DeserializationContext;
import javax.json.bind.serializer.JsonbDeserializer;
import javax.json.bind.serializer.JsonbSerializer;
import javax.json.bind.serializer.SerializationContext;
import javax.json.stream.JsonGenerator;
import javax.json.stream.JsonParser;
import javax.json.bind.annotation.JsonbProperty;
/**
* Gets or Sets Status
*/
@JsonbTypeSerializer(Status.Serializer.class)
@JsonbTypeDeserializer(Status.Deserializer.class)
public enum Status {
AVAILABLE("available"),
PENDING("pending"),
SOLD("sold");
private String value;
Status(String value) {
this.value = value;
}
@Override
public String toString() {
return String.valueOf(value);
}
public static final class Deserializer implements JsonbDeserializer<Status> {
@Override
public Status deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) {
return fromValue(parser.getString());
}
}
public static final class Serializer implements JsonbSerializer<Status> {
@Override
public void serialize(Status obj, JsonGenerator generator, SerializationContext ctx) {
generator.write(obj.value);
}
}
public static Status fromValue(String text) {
for (Status b : Status.values()) {
if (String.valueOf(b.value).equals(text)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + text + "'");
}
}

View File

@@ -0,0 +1,81 @@
/**
* Petstore API
* API for managing pets in a pet store
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.api;
import org.openapitools.client.model.Cat;
import org.openapitools.client.model.Dog;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;
import org.eclipse.microprofile.rest.client.RestClientBuilder;
import java.net.URL;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Petstore API Test
*
* API tests for DefaultApi
*/
public class DefaultApiTest {
private DefaultApi client;
private String baseUrl = "http://localhost:9080";
@BeforeEach
public void setup() throws MalformedURLException {
client = RestClientBuilder.newBuilder()
.baseUrl(new URL(baseUrl))
.register(ApiException.class)
.build(DefaultApi.class);
}
/**
* List all cats
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void listCatsTest() {
// TODO: test validations
//List<Cat> response = api.listCats();
//Assertions.assertNotNull(response);
}
/**
* List all dogs
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void listDogsTest() {
// TODO: test validations
//List<Dog> response = api.listDogs();
//Assertions.assertNotNull(response);
}
}

View File

@@ -0,0 +1,59 @@
/**
* Petstore API
* API for managing pets in a pet store
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.model;
import org.openapitools.client.model.Status;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
* Model tests for Cat
*/
class CatTest {
private final Cat model = new Cat();
/**
* Model tests for Cat
*/
@Test
void testCat() {
// TODO: test Cat
}
/**
* Test the property 'id'
*/
@Test
void idTest() {
// TODO: test id
}
/**
* Test the property 'name'
*/
@Test
void nameTest() {
// TODO: test name
}
/**
* Test the property 'status'
*/
@Test
void statusTest() {
// TODO: test status
}
}

View File

@@ -0,0 +1,59 @@
/**
* Petstore API
* API for managing pets in a pet store
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.model;
import org.openapitools.client.model.Status;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
* Model tests for Dog
*/
class DogTest {
private final Dog model = new Dog();
/**
* Model tests for Dog
*/
@Test
void testDog() {
// TODO: test Dog
}
/**
* Test the property 'id'
*/
@Test
void idTest() {
// TODO: test id
}
/**
* Test the property 'name'
*/
@Test
void nameTest() {
// TODO: test name
}
/**
* Test the property 'status'
*/
@Test
void statusTest() {
// TODO: test status
}
}

View File

@@ -0,0 +1,32 @@
/**
* Petstore API
* API for managing pets in a pet store
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.model;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
* Model tests for Status
*/
class StatusTest {
/**
* Model tests for Status
*/
@Test
void testStatus() {
// TODO: test Status
}
}