forked from loafle/openapi-generator-original
* 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:
parent
0820edee5d
commit
a3912b7239
3
.github/workflows/samples-jdk17.yaml
vendored
3
.github/workflows/samples-jdk17.yaml
vendored
@ -9,6 +9,7 @@ on:
|
||||
- samples/client/petstore/spring-http-interface-reactive/**
|
||||
- samples/client/petstore/spring-http-interface/**
|
||||
- samples/client/petstore/java/webclient-jakarta/**
|
||||
- samples/client/petstore/java/microprofile-rest-client-outer-enum/**
|
||||
# servers
|
||||
- samples/openapi3/server/petstore/springboot-3/**
|
||||
- samples/server/petstore/java-camel/**
|
||||
@ -23,6 +24,7 @@ on:
|
||||
- samples/client/petstore/spring-http-interface-reactive/**
|
||||
- samples/client/petstore/spring-http-interface/**
|
||||
- samples/client/petstore/java/webclient-jakarta/**
|
||||
- samples/client/petstore/java/microprofile-rest-client-outer-enum/**
|
||||
# servers
|
||||
- samples/openapi3/server/petstore/springboot-3/**
|
||||
- samples/server/petstore/java-camel/**
|
||||
@ -43,6 +45,7 @@ jobs:
|
||||
- samples/client/petstore/spring-http-interface-reactive
|
||||
- samples/client/petstore/spring-http-interface
|
||||
- samples/client/petstore/java/webclient-jakarta
|
||||
- samples/client/petstore/java/microprofile-rest-client-outer-enum
|
||||
# servers
|
||||
- samples/openapi3/server/petstore/springboot-3
|
||||
- samples/server/petstore/java-camel/
|
||||
|
@ -0,0 +1,8 @@
|
||||
generatorName: java
|
||||
outputDir: samples/client/petstore/java/microprofile-rest-client-outer-enum
|
||||
library: microprofile
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/outerEnum.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/Java
|
||||
additionalProperties:
|
||||
artifactId: microprofile-rest-client
|
||||
configKeyFromClassName: true
|
@ -9,6 +9,10 @@ import java.net.URI;
|
||||
/**
|
||||
* {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}}
|
||||
*/
|
||||
{{#jsonb}}
|
||||
@JsonbTypeSerializer({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.Serializer.class)
|
||||
@JsonbTypeDeserializer({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.Deserializer.class)
|
||||
{{/jsonb}}
|
||||
{{>additionalEnumTypeAnnotations}}public enum {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} {
|
||||
{{#gson}}
|
||||
{{#allowableValues}}{{#enumVars}}
|
||||
@ -36,6 +40,22 @@ import java.net.URI;
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
{{#jsonb}}
|
||||
public static final class Deserializer implements JsonbDeserializer<{{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}> {
|
||||
@Override
|
||||
public {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) {
|
||||
return fromValue(parser.getString());
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Serializer implements JsonbSerializer<{{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}> {
|
||||
@Override
|
||||
public void serialize({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} obj, JsonGenerator generator, SerializationContext ctx) {
|
||||
generator.write(obj.value{{#isUri}}.toASCIIString(){{/isUri}});
|
||||
}
|
||||
}
|
||||
|
||||
{{/jsonb}}
|
||||
{{#jackson}}
|
||||
@JsonCreator
|
||||
{{/jackson}}
|
||||
@ -47,5 +67,4 @@ import java.net.URI;
|
||||
}
|
||||
{{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + text + "'");{{/useNullForUnknownEnumValue}}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,68 @@
|
||||
openapi: 3.0.0
|
||||
info:
|
||||
title: Petstore API
|
||||
description: API for managing pets in a pet store
|
||||
version: 1.0.0
|
||||
paths:
|
||||
/dogs:
|
||||
get:
|
||||
summary: List all dogs
|
||||
operationId: listDogs
|
||||
responses:
|
||||
'200':
|
||||
description: A list of dogs
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Dog'
|
||||
/cats:
|
||||
get:
|
||||
summary: List all cats
|
||||
operationId: listCats
|
||||
responses:
|
||||
'200':
|
||||
description: A list of cats
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Cat'
|
||||
components:
|
||||
schemas:
|
||||
Dog:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
name:
|
||||
type: string
|
||||
status:
|
||||
$ref: '#/components/schemas/Status'
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
- status
|
||||
Cat:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
name:
|
||||
type: string
|
||||
status:
|
||||
$ref: '#/components/schemas/Status'
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
- status
|
||||
Status:
|
||||
type: string
|
||||
enum:
|
||||
- available
|
||||
- pending
|
||||
- sold
|
@ -0,0 +1,23 @@
|
||||
# OpenAPI Generator Ignore
|
||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
@ -0,0 +1,12 @@
|
||||
README.md
|
||||
docs/Cat.md
|
||||
docs/DefaultApi.md
|
||||
docs/Dog.md
|
||||
docs/Status.md
|
||||
pom.xml
|
||||
src/main/java/org/openapitools/client/api/ApiException.java
|
||||
src/main/java/org/openapitools/client/api/ApiExceptionMapper.java
|
||||
src/main/java/org/openapitools/client/api/DefaultApi.java
|
||||
src/main/java/org/openapitools/client/model/Cat.java
|
||||
src/main/java/org/openapitools/client/model/Dog.java
|
||||
src/main/java/org/openapitools/client/model/Status.java
|
@ -0,0 +1 @@
|
||||
7.8.0-SNAPSHOT
|
@ -0,0 +1,9 @@
|
||||
# Petstore API - MicroProfile Rest Client & MicroProfile Server
|
||||
|
||||
API for managing pets in a pet store
|
||||
|
||||
## Overview
|
||||
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project.
|
||||
[MicroProfile Rest Client](https://github.com/eclipse/microprofile-rest-client) is a type-safe way of calling
|
||||
REST services. The generated client contains an interface which acts as the client, you can inject it into dependent classes.
|
||||
|
@ -0,0 +1,15 @@
|
||||
|
||||
|
||||
# Cat
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
| Name | Type | Description | Notes |
|
||||
|------------ | ------------- | ------------- | -------------|
|
||||
|**id** | **Long** | | |
|
||||
|**name** | **String** | | |
|
||||
|**status** | **Status** | | |
|
||||
|
||||
|
||||
|
@ -0,0 +1,130 @@
|
||||
# DefaultApi
|
||||
|
||||
All URIs are relative to *http://localhost*
|
||||
|
||||
| Method | HTTP request | Description |
|
||||
|------------- | ------------- | -------------|
|
||||
| [**listCats**](DefaultApi.md#listCats) | **GET** /cats | List all cats |
|
||||
| [**listDogs**](DefaultApi.md#listDogs) | **GET** /dogs | List all dogs |
|
||||
|
||||
|
||||
|
||||
## listCats
|
||||
|
||||
> List<Cat> listCats()
|
||||
|
||||
List all cats
|
||||
|
||||
### Example
|
||||
|
||||
```java
|
||||
// Import classes:
|
||||
import org.openapitools.client.ApiClient;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.Configuration;
|
||||
import org.openapitools.client.models.*;
|
||||
import org.openapitools.client.api.DefaultApi;
|
||||
|
||||
public class Example {
|
||||
public static void main(String[] args) {
|
||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||
defaultClient.setBasePath("http://localhost");
|
||||
|
||||
DefaultApi apiInstance = new DefaultApi(defaultClient);
|
||||
try {
|
||||
List<Cat> result = apiInstance.listCats();
|
||||
System.out.println(result);
|
||||
} catch (ApiException e) {
|
||||
System.err.println("Exception when calling DefaultApi#listCats");
|
||||
System.err.println("Status code: " + e.getCode());
|
||||
System.err.println("Reason: " + e.getResponseBody());
|
||||
System.err.println("Response headers: " + e.getResponseHeaders());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
[**List<Cat>**](Cat.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json
|
||||
|
||||
|
||||
### HTTP response details
|
||||
| Status code | Description | Response headers |
|
||||
|-------------|-------------|------------------|
|
||||
| **200** | A list of cats | - |
|
||||
|
||||
|
||||
## listDogs
|
||||
|
||||
> List<Dog> listDogs()
|
||||
|
||||
List all dogs
|
||||
|
||||
### Example
|
||||
|
||||
```java
|
||||
// Import classes:
|
||||
import org.openapitools.client.ApiClient;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.Configuration;
|
||||
import org.openapitools.client.models.*;
|
||||
import org.openapitools.client.api.DefaultApi;
|
||||
|
||||
public class Example {
|
||||
public static void main(String[] args) {
|
||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||
defaultClient.setBasePath("http://localhost");
|
||||
|
||||
DefaultApi apiInstance = new DefaultApi(defaultClient);
|
||||
try {
|
||||
List<Dog> result = apiInstance.listDogs();
|
||||
System.out.println(result);
|
||||
} catch (ApiException e) {
|
||||
System.err.println("Exception when calling DefaultApi#listDogs");
|
||||
System.err.println("Status code: " + e.getCode());
|
||||
System.err.println("Reason: " + e.getResponseBody());
|
||||
System.err.println("Response headers: " + e.getResponseHeaders());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
[**List<Dog>**](Dog.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json
|
||||
|
||||
|
||||
### HTTP response details
|
||||
| Status code | Description | Response headers |
|
||||
|-------------|-------------|------------------|
|
||||
| **200** | A list of dogs | - |
|
||||
|
@ -0,0 +1,15 @@
|
||||
|
||||
|
||||
# Dog
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
| Name | Type | Description | Notes |
|
||||
|------------ | ------------- | ------------- | -------------|
|
||||
|**id** | **Long** | | |
|
||||
|**name** | **String** | | |
|
||||
|**status** | **Status** | | |
|
||||
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
|
||||
|
||||
# Status
|
||||
|
||||
## Enum
|
||||
|
||||
|
||||
* `AVAILABLE` (value: `"available"`)
|
||||
|
||||
* `PENDING` (value: `"pending"`)
|
||||
|
||||
* `SOLD` (value: `"sold"`)
|
||||
|
||||
|
||||
|
@ -0,0 +1,177 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>microprofile-rest-client</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>microprofile-rest-client</name>
|
||||
<description>API for managing pets in a pet store</description>
|
||||
<version>1.0.0</version>
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jboss.jandex</groupId>
|
||||
<artifactId>jandex-maven-plugin</artifactId>
|
||||
<version>${jandex.maven.plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-index</id>
|
||||
<goals>
|
||||
<goal>jandex</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>${maven.failsafe.plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>integration-test</goal>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>${build.helper.maven.plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add-source</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>add-source</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>src/gen/java</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- Eclipse MicroProfile Rest Client -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse.microprofile.rest.client</groupId>
|
||||
<artifactId>microprofile-rest-client-api</artifactId>
|
||||
<version>${microprofile.rest.client.api.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- JAX-RS -->
|
||||
<dependency>
|
||||
<groupId>jakarta.ws.rs</groupId>
|
||||
<artifactId>jakarta.ws.rs-api</artifactId>
|
||||
<version>${jakarta.ws.rs.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.smallrye</groupId>
|
||||
<artifactId>smallrye-rest-client</artifactId>
|
||||
<version>${smallrye.rest.client.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.smallrye</groupId>
|
||||
<artifactId>smallrye-config</artifactId>
|
||||
<version>${smallrye.config.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-rs-extension-providers</artifactId>
|
||||
<version>${cxf.rt.rs.extension.providers.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.json.bind</groupId>
|
||||
<artifactId>jakarta.json.bind-api</artifactId>
|
||||
<version>${jakarta.json.bind.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.json</groupId>
|
||||
<artifactId>jakarta.json-api</artifactId>
|
||||
<version>${jakarta.json.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.xml.bind</groupId>
|
||||
<artifactId>jakarta.xml.bind-api</artifactId>
|
||||
<version>${jakarta.xml.bind.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-core</artifactId>
|
||||
<version>${jaxb.core.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
<version>${jaxb.impl.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.activation</groupId>
|
||||
<artifactId>jakarta.activation-api</artifactId>
|
||||
<version>${jakarta.activation.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
<version>${jackson.jaxrs.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.annotation</groupId>
|
||||
<artifactId>jakarta.annotation-api</artifactId>
|
||||
<version>${jakarta.annotation.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>sonatype-snapshots</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||
<swagger.core.version>1.5.18</swagger.core.version>
|
||||
<jetty.version>9.2.9.v20150224</jetty.version>
|
||||
<junit.version>5.10.2</junit.version>
|
||||
<logback.version>1.4.14</logback.version>
|
||||
<cxf.version>3.2.7</cxf.version>
|
||||
<jackson.jaxrs.version>2.17.1</jackson.jaxrs.version>
|
||||
<jakarta.activation.version>1.2.2</jakarta.activation.version>
|
||||
<jakarta.annotation.version>1.3.5</jakarta.annotation.version>
|
||||
<jakarta.json.bind.version>1.0.2</jakarta.json.bind.version>
|
||||
<jakarta.json.version>1.1.6</jakarta.json.version>
|
||||
<jakarta.ws.rs.version>2.1.6</jakarta.ws.rs.version>
|
||||
<jakarta.xml.bind.version>2.3.3</jakarta.xml.bind.version>
|
||||
<microprofile.rest.client.api.version>2.0</microprofile.rest.client.api.version>
|
||||
<smallrye.rest.client.version>1.2.1</smallrye.rest.client.version>
|
||||
<smallrye.config.version>1.3.5</smallrye.config.version>
|
||||
<cxf.rt.rs.extension.providers.version>3.2.6</cxf.rt.rs.extension.providers.version>
|
||||
<jaxb.core.version>2.2.11</jaxb.core.version>
|
||||
<jaxb.impl.version>2.2.11</jaxb.impl.version>
|
||||
<hibernate.validator.version>5.2.2.Final</hibernate.validator.version>
|
||||
<jandex.maven.plugin.version>1.1.0</jandex.maven.plugin.version>
|
||||
<maven.failsafe.plugin.version>2.6</maven.failsafe.plugin.version>
|
||||
<build.helper.maven.plugin.version>1.9.1</build.helper.maven.plugin.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
</project>
|
@ -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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
@ -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 ");
|
||||
}
|
||||
}
|
||||
|
@ -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 ");
|
||||
}
|
||||
}
|
||||
|
@ -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 + "'");
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -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
|
||||
}
|
||||
|
||||
}
|
@ -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
|
||||
}
|
||||
|
||||
}
|
@ -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
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user