Change generated MP server return type from Response to the document-indicated type (#72)

Signed-off-by: tim.quinn@oracle.com <tim.quinn@oracle.com>

Signed-off-by: tim.quinn@oracle.com <tim.quinn@oracle.com>
This commit is contained in:
Tim Quinn 2022-10-13 11:39:59 -05:00 committed by GitHub
parent 700f01dbf8
commit 048f78e0c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 170 additions and 64 deletions

View File

@ -24,8 +24,11 @@ import java.util.Locale;
import java.util.Set;
import java.util.stream.Collectors;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.servers.Server;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.languages.features.BeanValidationFeatures;
import org.openapitools.codegen.languages.features.PerformBeanValidationFeatures;
@ -52,6 +55,8 @@ public abstract class JavaHelidonCommonCodegen extends AbstractJavaCodegen
static final String MICROPROFILE_ROOT_PACKAGE = "rootJavaEEPackage";
static final String MICROPROFILE_ROOT_DEP_PREFIX = "x-helidon-rootJavaEEDepPrefix";
static final String X_HAS_RETURN_TYPE = "x-helidon-hasReturnType";
static final String X_RETURN_TYPE_EXAMPLE_VALUE = "x-helidon-exampleReturnTypeValue";
static final String MICROPROFILE_ROOT_PACKAGE_DESC = "Root package name for Java EE";
static final String MICROPROFILE_ROOT_PACKAGE_JAVAX = "javax";
static final String MICROPROFILE_ROOT_PACKAGE_JAKARTA = "jakarta";
@ -125,6 +130,14 @@ public abstract class JavaHelidonCommonCodegen extends AbstractJavaCodegen
setEEPackageAndDependencies(helidonVersion);
}
@Override
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, List<Server> servers) {
CodegenOperation op = super.fromOperation(path, httpMethod, operation, servers);
op.vendorExtensions.put(X_HAS_RETURN_TYPE, op.returnType != null && !op.returnType.equals("void"));
op.vendorExtensions.put(X_RETURN_TYPE_EXAMPLE_VALUE, chooseExampleReturnTypeValue(op));
return op;
}
/**
* Remove set of options not currently used by any Helidon generator. Should be
* called during construction but only on leaf classes.
@ -257,4 +270,49 @@ public abstract class JavaHelidonCommonCodegen extends AbstractJavaCodegen
.collect(Collectors.toSet());
forRemoval.forEach(cliOptions::remove);
}
private String chooseExampleReturnTypeValue(CodegenOperation op) {
// See DefaultCodegen#handleMethodResponse to see how the various op fields related to the return type are set.
if (op.returnType == null) {
return ""; // won't be used anyway in the templates
}
if (op.isMap) {
return "java.util.Collections.emptyMap()";
}
if (op.isArray) {
return "java.util.Collections.emptyList()";
}
switch (op.returnType) {
case "Integer":
return "new Integer(0)";
case "byte[]":
return "new byte[0]";
case "Float":
return "new Float(0.0f)";
case "boolean":
return "false";
case "Long":
return "new Long(0L)";
case "Object":
return "new Object()";
case "String":
return "\"\"";
case "Boolean":
return "new Boolean(false)";
case "Double":
return "new Double(0.0d)";
default:
return "null";
}
}
}

View File

@ -5,8 +5,9 @@ package {{package}};
{{/imports}}
import {{rootJavaEEPackage}}.ws.rs.*;
{{#returnResponse}}
import {{rootJavaEEPackage}}.ws.rs.core.Response;
{{/returnResponse}}
{{#supportAsync}}
import java.util.concurrent.CompletionStage;
import java.util.concurrent.CompletableFuture;

View File

@ -2,4 +2,4 @@
@Path("{{{path}}}"){{/subresourceOperation}}{{#hasConsumes}}
@Consumes({ {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} }){{/hasConsumes}}{{#hasProduces}}
@Produces({ {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} }){{/hasProduces}}
abstract {{#supportAsync}}{{>returnAsyncTypeInterface}}{{/supportAsync}}{{^supportAsync}}Response{{/supportAsync}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>cookieParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{^-last}}, {{/-last}}{{/allParams}});
{{#useAbstractClass}}abstract {{/useAbstractClass}}{{#supportAsync}}{{>returnAsyncTypeInterface}}{{/supportAsync}}{{^supportAsync}}{{>returnTypes}}{{/supportAsync}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>cookieParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{^-last}}, {{/-last}}{{/allParams}});

View File

@ -5,7 +5,9 @@ package {{package}};
{{/imports}}
import {{rootJavaEEPackage}}.ws.rs.*;
{{#returnResponse}}
import {{rootJavaEEPackage}}.ws.rs.core.Response;
{{/returnResponse}}
{{#supportAsync}}
import java.util.concurrent.CompletionStage;

View File

@ -2,6 +2,21 @@
@Path("{{{path}}}"){{/subresourceOperation}}{{#hasConsumes}}
@Consumes({ {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} }){{/hasConsumes}}{{#hasProduces}}
@Produces({ {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} }){{/hasProduces}}
public {{#supportAsync}}CompletionStage<{{/supportAsync}}Response{{#supportAsync}}>{{/supportAsync}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>cookieParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{^-last}},{{/-last}}{{/allParams}}) {
return {{#supportAsync}}CompletableFuture.supplyAsync(() -> {{/supportAsync}}Response.ok().entity("magic!").build(){{#supportAsync}}){{/supportAsync}};
public {{#supportAsync}}{{>returnAsyncTypeInterface}}{{/supportAsync}}{{^supportAsync}}{{>returnTypes}}{{/supportAsync}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>cookieParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{^-last}},{{/-last}}{{/allParams}}) {
{{#returnResponse}}
return {{#supportAsync}}CompletableFuture.supplyAsync(() -> {{/supportAsync}}Response.ok({{#vendorExtensions.x-helidon-hasReturnType}}/* Pass {{{returnType}}} entity payload */{{/vendorExtensions.x-helidon-hasReturnType}}).build(){{#supportAsync}}){{/supportAsync}}; // Replace with correct business logic.
{{/returnResponse}}
{{^returnResponse}}
{{#vendorExtensions.x-helidon-hasReturnType}}
{{{returnType}}} result = {{{vendorExtensions.x-helidon-exampleReturnTypeValue}}}; // Replace with correct business logic.
{{/vendorExtensions.x-helidon-hasReturnType}}
{{#supportAsync}}
return CompletableFuture.supplyAsync(() -> {{#vendorExtensions.x-helidon-hasReturnType}}result{{/vendorExtensions.x-helidon-hasReturnType}}{{^vendorExtensions.x-helidon-hasReturnType}}null{{/vendorExtensions.x-helidon-hasReturnType}});
{{/supportAsync}}
{{^supportAsync}}
{{#vendorExtensions.x-helidon-hasReturnType}}
return result;
{{/vendorExtensions.x-helidon-hasReturnType}}
{{/supportAsync}}
{{/returnResponse}}
}

View File

@ -0,0 +1 @@
CompletionStage<{{#returnResponse}}Response{{/returnResponse}}{{^returnResponse}}{{#returnContainer}}{{#isMap}}Map<String, {{{returnBaseType}}}>{{/isMap}}{{#isArray}}{{{returnContainer}}}<{{{returnBaseType}}}>{{/isArray}}{{/returnContainer}}{{^returnContainer}}{{{returnBaseType}}}{{/returnContainer}}{{/returnResponse}}>

View File

@ -1 +1 @@
{{#returnContainer}}{{#isMap}}Map<String, {{{returnType}}}>{{/isMap}}{{#isArray}}{{{returnContainer}}}<{{{returnType}}}>{{/isArray}}{{/returnContainer}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}}
{{#returnResponse}}Response{{/returnResponse}}{{^returnResponse}}{{#returnContainer}}{{#isMap}}Map<String, {{{returnBaseType}}}>{{/isMap}}{{#isArray}}{{{returnContainer}}}<{{{returnBaseType}}}>{{/isArray}}{{/returnContainer}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}}{{/returnResponse}}

View File

@ -29,6 +29,7 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
@ -111,13 +112,13 @@ public class JavaHelidonMpServerCodegenTest {
.fileContains("public abstract class StoreService")
.assertMethod("placeOrder", "Order")
.doesNotHaveImplementation()
.hasReturnType("Response");
.hasReturnType("Order");
JavaFileAssert.assertThat(Paths.get(apiPackage + "/StoreServiceImpl.java"))
.fileContains("public class StoreServiceImpl extends StoreService")
.assertMethod("placeOrder", "Order")
.hasReturnType("Response")
.bodyContainsLines("return Response.ok().entity(\"magic!\").build();");
.hasReturnType("Order")
.bodyContainsLines("Order result = null; // Replace with correct business logic.", "return result;");
}
@Test
@ -131,7 +132,7 @@ public class JavaHelidonMpServerCodegenTest {
JavaFileAssert.assertThat(Paths.get(apiPackage + "/StoreService.java"))
.fileContains("public interface StoreService")
.assertMethod("placeOrder", "Order")
.hasReturnType("Response");
.hasReturnType("Order");
}
@Test
@ -206,4 +207,46 @@ public class JavaHelidonMpServerCodegenTest {
TestUtils.assertFileNotExists(Paths.get(outputPath + "/pom.xml"));
}
@Test
public void testReturnResponse() {
generate(createConfigurator().addAdditionalProperty("returnResponse", "true"));
JavaFileAssert.assertThat(Paths.get(apiPackage + "/PetService.java"))
.fileContains("public interface PetService")
.assertMethod("addPet", "Pet")
.hasReturnType("Response");
JavaFileAssert.assertThat(Paths.get(apiPackage + "/PetService.java"))
.fileContains("public interface PetService")
.assertMethod("deletePet", "Long", "String", "Long", "String", "Integer", "List<Integer>", "List<String>")
.hasReturnType("Response");
JavaFileAssert.assertThat(Paths.get(apiPackage + "/PetServiceImpl.java"))
.fileContains("public class PetServiceImpl implements PetService")
.assertMethod("addPet", "Pet")
.hasReturnType("Response")
.bodyContainsLines("return Response.ok(/* Pass Pet entity payload */).build(); "
+ "// Replace with correct business logic.");
}
@Test
public void testSupportAsync() {
generate(createConfigurator().addAdditionalProperty("supportAsync", "true"));
JavaFileAssert.assertThat(Paths.get(apiPackage + "/PetService.java"))
.fileContains("public interface PetService")
.assertMethod("addPet", "Pet")
.hasReturnType("CompletionStage<Pet>");
JavaFileAssert.assertThat(Paths.get(apiPackage + "/PetService.java"))
.fileContains("public interface PetService")
.assertMethod("deletePet", "Long", "String", "Long", "String", "Integer", "List<Integer>", "List<String>")
.hasReturnType("CompletionStage<Void>");
JavaFileAssert.assertThat(Paths.get(apiPackage + "/PetServiceImpl.java"))
.fileContains("public class PetServiceImpl implements PetService")
.assertMethod("addPet", "Pet")
.hasReturnType("CompletionStage<Pet>")
.bodyContainsLines("Pet result = null; // Replace with correct business logic.",
"return CompletableFuture.supplyAsync(() -> result);");
}
}

View File

@ -15,8 +15,6 @@ package org.openapitools.server.api;
import org.openapitools.server.model.Client;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.Response;
import java.io.InputStream;
import java.util.Map;
@ -31,5 +29,5 @@ public interface AnotherFakeService {
@PATCH
@Consumes({ "application/json" })
@Produces({ "application/json" })
abstract Response call123testSpecialTags(@Valid @NotNull Client client);
Client call123testSpecialTags(@Valid @NotNull Client client);
}

View File

@ -15,8 +15,6 @@ package org.openapitools.server.api;
import org.openapitools.server.model.FooGetDefaultResponse;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.Response;
import java.io.InputStream;
import java.util.Map;
@ -30,5 +28,5 @@ public interface DefaultService {
@GET
@Produces({ "application/json" })
abstract Response fooGet();
FooGetDefaultResponse fooGet();
}

View File

@ -15,8 +15,6 @@ package org.openapitools.server.api;
import org.openapitools.server.model.Client;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.Response;
import java.io.InputStream;
import java.util.Map;
@ -31,5 +29,5 @@ public interface FakeClassnameTags123Service {
@PATCH
@Consumes({ "application/json" })
@Produces({ "application/json" })
abstract Response testClassname(@Valid @NotNull Client client);
Client testClassname(@Valid @NotNull Client client);
}

View File

@ -27,8 +27,6 @@ import org.openapitools.server.model.Pet;
import org.openapitools.server.model.User;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.Response;
import java.io.InputStream;
import java.util.Map;
@ -43,85 +41,85 @@ public interface FakeService {
@GET
@Path("/health")
@Produces({ "application/json" })
abstract Response fakeHealthGet();
HealthCheckResult fakeHealthGet();
@GET
@Path("/http-signature-test")
@Consumes({ "application/json", "application/xml" })
abstract Response fakeHttpSignatureTest(@Valid @NotNull Pet pet, @QueryParam("query_1") String query1, @HeaderParam("header_1") String header1);
void fakeHttpSignatureTest(@Valid @NotNull Pet pet, @QueryParam("query_1") String query1, @HeaderParam("header_1") String header1);
@POST
@Path("/outer/boolean")
@Consumes({ "application/json" })
@Produces({ "*/*" })
abstract Response fakeOuterBooleanSerialize(@Valid Boolean body);
Boolean fakeOuterBooleanSerialize(@Valid Boolean body);
@POST
@Path("/outer/composite")
@Consumes({ "application/json" })
@Produces({ "*/*" })
abstract Response fakeOuterCompositeSerialize(@Valid OuterComposite outerComposite);
OuterComposite fakeOuterCompositeSerialize(@Valid OuterComposite outerComposite);
@POST
@Path("/outer/number")
@Consumes({ "application/json" })
@Produces({ "*/*" })
abstract Response fakeOuterNumberSerialize(@Valid BigDecimal body);
BigDecimal fakeOuterNumberSerialize(@Valid BigDecimal body);
@POST
@Path("/outer/string")
@Consumes({ "application/json" })
@Produces({ "*/*" })
abstract Response fakeOuterStringSerialize(@Valid String body);
String fakeOuterStringSerialize(@Valid String body);
@POST
@Path("/property/enum-int")
@Consumes({ "application/json" })
@Produces({ "*/*" })
abstract Response fakePropertyEnumIntegerSerialize(@Valid @NotNull OuterObjectWithEnumProperty outerObjectWithEnumProperty);
OuterObjectWithEnumProperty fakePropertyEnumIntegerSerialize(@Valid @NotNull OuterObjectWithEnumProperty outerObjectWithEnumProperty);
@PUT
@Path("/body-with-binary")
@Consumes({ "image/png" })
abstract Response testBodyWithBinary(@Valid File body);
void testBodyWithBinary(@Valid File body);
@PUT
@Path("/body-with-file-schema")
@Consumes({ "application/json" })
abstract Response testBodyWithFileSchema(@Valid @NotNull FileSchemaTestClass fileSchemaTestClass);
void testBodyWithFileSchema(@Valid @NotNull FileSchemaTestClass fileSchemaTestClass);
@PUT
@Path("/body-with-query-params")
@Consumes({ "application/json" })
abstract Response testBodyWithQueryParams(@QueryParam("query") @NotNull String query, @Valid @NotNull User user);
void testBodyWithQueryParams(@QueryParam("query") @NotNull String query, @Valid @NotNull User user);
@PATCH
@Consumes({ "application/json" })
@Produces({ "application/json" })
abstract Response testClientModel(@Valid @NotNull Client client);
Client testClientModel(@Valid @NotNull Client client);
@POST
@Consumes({ "application/x-www-form-urlencoded" })
abstract Response testEndpointParameters(@FormParam(value = "number") BigDecimal number, @FormParam(value = "double") Double _double, @FormParam(value = "pattern_without_delimiter") String patternWithoutDelimiter, @FormParam(value = "byte") byte[] _byte, @FormParam(value = "integer") Integer integer, @FormParam(value = "int32") Integer int32, @FormParam(value = "int64") Long int64, @FormParam(value = "float") Float _float, @FormParam(value = "string") String string, @FormParam(value = "binary") InputStream binaryInputStream, @FormParam(value = "date") LocalDate date, @FormParam(value = "dateTime") OffsetDateTime dateTime, @FormParam(value = "password") String password, @FormParam(value = "callback") String paramCallback);
void testEndpointParameters(@FormParam(value = "number") BigDecimal number, @FormParam(value = "double") Double _double, @FormParam(value = "pattern_without_delimiter") String patternWithoutDelimiter, @FormParam(value = "byte") byte[] _byte, @FormParam(value = "integer") Integer integer, @FormParam(value = "int32") Integer int32, @FormParam(value = "int64") Long int64, @FormParam(value = "float") Float _float, @FormParam(value = "string") String string, @FormParam(value = "binary") InputStream binaryInputStream, @FormParam(value = "date") LocalDate date, @FormParam(value = "dateTime") OffsetDateTime dateTime, @FormParam(value = "password") String password, @FormParam(value = "callback") String paramCallback);
@GET
@Consumes({ "application/x-www-form-urlencoded" })
abstract Response testEnumParameters(@HeaderParam("enum_header_string_array") List<String> enumHeaderStringArray, @HeaderParam("enum_header_string") @DefaultValue("-efg") String enumHeaderString, @QueryParam("enum_query_string_array") List<String> enumQueryStringArray, @QueryParam("enum_query_string") @DefaultValue("-efg") String enumQueryString, @QueryParam("enum_query_integer") Integer enumQueryInteger, @QueryParam("enum_query_double") Double enumQueryDouble, @QueryParam("enum_query_model_array") List<EnumClass> enumQueryModelArray, @FormParam(value = "enum_form_string_array") List<String> enumFormStringArray, @FormParam(value = "enum_form_string") String enumFormString);
void testEnumParameters(@HeaderParam("enum_header_string_array") List<String> enumHeaderStringArray, @HeaderParam("enum_header_string") @DefaultValue("-efg") String enumHeaderString, @QueryParam("enum_query_string_array") List<String> enumQueryStringArray, @QueryParam("enum_query_string") @DefaultValue("-efg") String enumQueryString, @QueryParam("enum_query_integer") Integer enumQueryInteger, @QueryParam("enum_query_double") Double enumQueryDouble, @QueryParam("enum_query_model_array") List<EnumClass> enumQueryModelArray, @FormParam(value = "enum_form_string_array") List<String> enumFormStringArray, @FormParam(value = "enum_form_string") String enumFormString);
@DELETE
abstract Response testGroupParameters(@QueryParam("required_string_group") @NotNull Integer requiredStringGroup, @HeaderParam("required_boolean_group") @NotNull Boolean requiredBooleanGroup, @QueryParam("required_int64_group") @NotNull Long requiredInt64Group, @QueryParam("string_group") Integer stringGroup, @HeaderParam("boolean_group") Boolean booleanGroup, @QueryParam("int64_group") Long int64Group);
void testGroupParameters(@QueryParam("required_string_group") @NotNull Integer requiredStringGroup, @HeaderParam("required_boolean_group") @NotNull Boolean requiredBooleanGroup, @QueryParam("required_int64_group") @NotNull Long requiredInt64Group, @QueryParam("string_group") Integer stringGroup, @HeaderParam("boolean_group") Boolean booleanGroup, @QueryParam("int64_group") Long int64Group);
@POST
@Path("/inline-additionalProperties")
@Consumes({ "application/json" })
abstract Response testInlineAdditionalProperties(@Valid @NotNull Map<String, String> requestBody);
void testInlineAdditionalProperties(@Valid @NotNull Map<String, String> requestBody);
@GET
@Path("/jsonFormData")
@Consumes({ "application/x-www-form-urlencoded" })
abstract Response testJsonFormData(@FormParam(value = "param") String param, @FormParam(value = "param2") String param2);
void testJsonFormData(@FormParam(value = "param") String param, @FormParam(value = "param2") String param2);
@PUT
@Path("/test-query-parameters")
abstract Response testQueryParameterCollectionFormat(@QueryParam("pipe") @NotNull List<String> pipe, @QueryParam("ioutil") @NotNull List<String> ioutil, @QueryParam("http") @NotNull List<String> http, @QueryParam("url") @NotNull List<String> url, @QueryParam("context") @NotNull List<String> context, @QueryParam("allowEmpty") @NotNull String allowEmpty, @QueryParam("language") Map<String, String> language);
void testQueryParameterCollectionFormat(@QueryParam("pipe") @NotNull List<String> pipe, @QueryParam("ioutil") @NotNull List<String> ioutil, @QueryParam("http") @NotNull List<String> http, @QueryParam("url") @NotNull List<String> url, @QueryParam("context") @NotNull List<String> context, @QueryParam("allowEmpty") @NotNull String allowEmpty, @QueryParam("language") Map<String, String> language);
}

View File

@ -18,8 +18,6 @@ import org.openapitools.server.model.Pet;
import java.util.Set;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.Response;
import java.io.InputStream;
import java.util.Map;
@ -34,46 +32,46 @@ public interface PetService {
@POST
@Path("/pet")
@Consumes({ "application/json", "application/xml" })
abstract Response addPet(@Valid @NotNull Pet pet);
void addPet(@Valid @NotNull Pet pet);
@DELETE
@Path("/pet/{petId}")
abstract Response deletePet(@PathParam("petId") Long petId, @HeaderParam("api_key") String apiKey);
void deletePet(@PathParam("petId") Long petId, @HeaderParam("api_key") String apiKey);
@GET
@Path("/pet/findByStatus")
@Produces({ "application/xml", "application/json" })
abstract Response findPetsByStatus(@QueryParam("status") @NotNull List<String> status);
List<Pet> findPetsByStatus(@QueryParam("status") @NotNull List<String> status);
@GET
@Path("/pet/findByTags")
@Produces({ "application/xml", "application/json" })
abstract Response findPetsByTags(@QueryParam("tags") @NotNull Set<String> tags);
Set<Pet> findPetsByTags(@QueryParam("tags") @NotNull Set<String> tags);
@GET
@Path("/pet/{petId}")
@Produces({ "application/xml", "application/json" })
abstract Response getPetById(@PathParam("petId") Long petId);
Pet getPetById(@PathParam("petId") Long petId);
@PUT
@Path("/pet")
@Consumes({ "application/json", "application/xml" })
abstract Response updatePet(@Valid @NotNull Pet pet);
void updatePet(@Valid @NotNull Pet pet);
@POST
@Path("/pet/{petId}")
@Consumes({ "application/x-www-form-urlencoded" })
abstract Response updatePetWithForm(@PathParam("petId") Long petId, @FormParam(value = "name") String name, @FormParam(value = "status") String status);
void updatePetWithForm(@PathParam("petId") Long petId, @FormParam(value = "name") String name, @FormParam(value = "status") String status);
@POST
@Path("/pet/{petId}/uploadImage")
@Consumes({ "multipart/form-data" })
@Produces({ "application/json" })
abstract Response uploadFile(@PathParam("petId") Long petId, @FormParam(value = "additionalMetadata") String additionalMetadata, @FormParam(value = "file") InputStream _fileInputStream);
ModelApiResponse uploadFile(@PathParam("petId") Long petId, @FormParam(value = "additionalMetadata") String additionalMetadata, @FormParam(value = "file") InputStream _fileInputStream);
@POST
@Path("/fake/{petId}/uploadImageWithRequiredFile")
@Consumes({ "multipart/form-data" })
@Produces({ "application/json" })
abstract Response uploadFileWithRequiredFile(@PathParam("petId") Long petId, @FormParam(value = "requiredFile") InputStream requiredFileInputStream, @FormParam(value = "additionalMetadata") String additionalMetadata);
ModelApiResponse uploadFileWithRequiredFile(@PathParam("petId") Long petId, @FormParam(value = "requiredFile") InputStream requiredFileInputStream, @FormParam(value = "additionalMetadata") String additionalMetadata);
}

View File

@ -16,8 +16,6 @@ import java.util.Map;
import org.openapitools.server.model.Order;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.Response;
import java.io.InputStream;
import java.util.Map;
@ -31,21 +29,21 @@ public interface StoreService {
@DELETE
@Path("/order/{order_id}")
abstract Response deleteOrder(@PathParam("order_id") String orderId);
void deleteOrder(@PathParam("order_id") String orderId);
@GET
@Path("/inventory")
@Produces({ "application/json" })
abstract Response getInventory();
Map<String, Integer> getInventory();
@GET
@Path("/order/{order_id}")
@Produces({ "application/xml", "application/json" })
abstract Response getOrderById(@PathParam("order_id") @Min(1L) @Max(5L) Long orderId);
Order getOrderById(@PathParam("order_id") @Min(1L) @Max(5L) Long orderId);
@POST
@Path("/order")
@Consumes({ "application/json" })
@Produces({ "application/xml", "application/json" })
abstract Response placeOrder(@Valid @NotNull Order order);
Order placeOrder(@Valid @NotNull Order order);
}

View File

@ -17,8 +17,6 @@ import java.time.OffsetDateTime;
import org.openapitools.server.model.User;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.Response;
import java.io.InputStream;
import java.util.Map;
@ -32,38 +30,38 @@ public interface UserService {
@POST
@Consumes({ "application/json" })
abstract Response createUser(@Valid @NotNull User user);
void createUser(@Valid @NotNull User user);
@POST
@Path("/createWithArray")
@Consumes({ "application/json" })
abstract Response createUsersWithArrayInput(@Valid @NotNull List<User> user);
void createUsersWithArrayInput(@Valid @NotNull List<User> user);
@POST
@Path("/createWithList")
@Consumes({ "application/json" })
abstract Response createUsersWithListInput(@Valid @NotNull List<User> user);
void createUsersWithListInput(@Valid @NotNull List<User> user);
@DELETE
@Path("/{username}")
abstract Response deleteUser(@PathParam("username") String username);
void deleteUser(@PathParam("username") String username);
@GET
@Path("/{username}")
@Produces({ "application/xml", "application/json" })
abstract Response getUserByName(@PathParam("username") String username);
User getUserByName(@PathParam("username") String username);
@GET
@Path("/login")
@Produces({ "application/xml", "application/json" })
abstract Response loginUser(@QueryParam("username") @NotNull String username, @QueryParam("password") @NotNull String password);
String loginUser(@QueryParam("username") @NotNull String username, @QueryParam("password") @NotNull String password);
@GET
@Path("/logout")
abstract Response logoutUser();
void logoutUser();
@PUT
@Path("/{username}")
@Consumes({ "application/json" })
abstract Response updateUser(@PathParam("username") String username, @Valid @NotNull User user);
void updateUser(@PathParam("username") String username, @Valid @NotNull User user);
}