Skip to content

Fix for Jaxrs file upload missing param in service class #1882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class {{classname}} {

public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}},{{/allParams}}@Context SecurityContext securityContext)
throws NotFoundException {
return delegate.{{nickname}}({{#allParams}}{{#isFile}}fileDetail{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}},{{/allParams}}securityContext);
return delegate.{{nickname}}({{#allParams}}{{#isFile}}inputStream, fileDetail{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}},{{/allParams}}securityContext);
}
{{/operation}}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{#isFormParam}}{{#notFile}}{{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}FormDataContentDisposition fileDetail{{/isFile}}{{/isFormParam}}
{{#isFormParam}}{{#notFile}}{{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}InputStream inputStream, FormDataContentDisposition fileDetail{{/isFile}}{{/isFormParam}}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.swagger.api;

@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-05T15:00:28.637+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-14T21:37:36.074Z")
public class ApiException extends Exception{
private int code;
public ApiException (int code, String msg) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;

@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-05T15:00:28.637+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-14T21:37:36.074Z")
public class ApiOriginFilter implements javax.servlet.Filter {
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import javax.xml.bind.annotation.XmlTransient;

@javax.xml.bind.annotation.XmlRootElement
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-05T15:00:28.637+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-14T21:37:36.074Z")
public class ApiResponseMessage {
public static final int ERROR = 1;
public static final int WARNING = 2;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.swagger.api;

@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-05T15:00:28.637+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-14T21:37:36.074Z")
public class NotFoundException extends ApiException {
private int code;
public NotFoundException (int code, String msg) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@


@io.swagger.annotations.Api(description = "the pet API")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-05T15:00:28.637+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-14T21:37:36.074Z")
public class PetApi {
private final PetApiService delegate = PetApiServiceFactory.getPetApi();

Expand Down Expand Up @@ -169,13 +169,31 @@ public Response deletePet(@ApiParam(value = "Pet id to delete",required=true) @P
@io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
@io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets")
})
}, tags={ "pet" })
}, tags={ "pet", })
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) })

public Response uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathParam("petId") Long petId,@ApiParam(value = "Additional data to pass to server")@FormParam("additionalMetadata") String additionalMetadata, @FormDataParam("file") InputStream inputStream,
@FormDataParam("file") FormDataContentDisposition fileDetail,@Context SecurityContext securityContext)
throws NotFoundException {
return delegate.uploadFile(petId,additionalMetadata,fileDetail,securityContext);
return delegate.uploadFile(petId,additionalMetadata,inputStream, fileDetail,securityContext);
}
@GET
@Path("/{petId}?testing_byte_array=true")

@Produces({ "application/json", "application/xml" })
@io.swagger.annotations.ApiOperation(value = "Fake endpoint to test byte array return by 'Find pet by ID'", notes = "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", response = byte[].class, authorizations = {
@io.swagger.annotations.Authorization(value = "api_key")
}, tags={ "pet" })
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = byte[].class),

@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = byte[].class),

@io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found", response = byte[].class) })

public Response getPetByIdWithByteArray(@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathParam("petId") Long petId,@Context SecurityContext securityContext)
throws NotFoundException {
return delegate.getPetByIdWithByteArray(petId,securityContext);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;

@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-05T15:00:28.637+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-14T21:37:36.074Z")
public abstract class PetApiService {

public abstract Response updatePet(Pet body,SecurityContext securityContext)
Expand All @@ -43,7 +43,10 @@ public abstract Response updatePetWithForm(String petId,String name,String statu
public abstract Response deletePet(Long petId,String apiKey,SecurityContext securityContext)
throws NotFoundException;

public abstract Response uploadFile(Long petId,String additionalMetadata,FormDataContentDisposition fileDetail,SecurityContext securityContext)
public abstract Response uploadFile(Long petId,String additionalMetadata,InputStream inputStream, FormDataContentDisposition fileDetail,SecurityContext securityContext)
throws NotFoundException;

public abstract Response getPetByIdWithByteArray(Long petId,SecurityContext securityContext)
throws NotFoundException;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package io.swagger.api;

import io.swagger.model.*;
import io.swagger.api.PettestingByteArraytrueApiService;
import io.swagger.api.factories.PettestingByteArraytrueApiServiceFactory;

import io.swagger.annotations.ApiParam;

import com.sun.jersey.multipart.FormDataParam;


import java.util.List;
import io.swagger.api.NotFoundException;

import java.io.InputStream;

import com.sun.jersey.core.header.FormDataContentDisposition;
import com.sun.jersey.multipart.FormDataParam;

import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
import javax.ws.rs.*;

@Path("/pet?testing_byte_array=true")


@io.swagger.annotations.Api(description = "the pet?testing_byte_array=true API")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-14T21:37:36.074Z")
public class PettestingByteArraytrueApi {
private final PettestingByteArraytrueApiService delegate = PettestingByteArraytrueApiServiceFactory.getPettestingByteArraytrueApi();

@POST

@Consumes({ "application/json", "application/xml" })
@Produces({ "application/json", "application/xml" })
@io.swagger.annotations.ApiOperation(value = "Fake endpoint to test byte array in body parameter for adding a new pet to the store", notes = "", response = Void.class, authorizations = {
@io.swagger.annotations.Authorization(value = "petstore_auth", scopes = {
@io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
@io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets")
})
}, tags={ "pet" })
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input", response = Void.class) })

public Response addPetUsingByteArray(@ApiParam(value = "Pet object in the form of byte array" ) byte[] body,@Context SecurityContext securityContext)
throws NotFoundException {
return delegate.addPetUsingByteArray(body,securityContext);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.swagger.api;

import io.swagger.api.*;
import io.swagger.model.*;

import com.sun.jersey.multipart.FormDataParam;


import java.util.List;
import io.swagger.api.NotFoundException;

import java.io.InputStream;

import com.sun.jersey.core.header.FormDataContentDisposition;
import com.sun.jersey.multipart.FormDataParam;

import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;

@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-14T21:37:36.074Z")
public abstract class PettestingByteArraytrueApiService {

public abstract Response addPetUsingByteArray(byte[] body,SecurityContext securityContext)
throws NotFoundException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@


@io.swagger.annotations.Api(description = "the store API")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-05T15:00:28.637+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-14T21:37:36.074Z")
public class StoreApi {
private final StoreApiService delegate = StoreApiServiceFactory.getStoreApi();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;

@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-05T15:00:28.637+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-14T21:37:36.074Z")
public abstract class StoreApiService {

public abstract Response getInventory(SecurityContext securityContext)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package io.swagger.api;

@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-14T21:37:36.074Z")
public class StringUtil {
/**
* Check if the given array contains the given value (with case-insensitive comparison).
*
* @param array The array
* @param value The value to search
* @return true if the array contains the value
*/
public static boolean containsIgnoreCase(String[] array, String value) {
for (String str : array) {
if (value == null && str == null) return true;
if (value != null && value.equalsIgnoreCase(str)) return true;
}
return false;
}

/**
* Join an array of strings with the given separator.
* <p>
* Note: This might be replaced by utility method from commons-lang or guava someday
* if one of those libraries is added as dependency.
* </p>
*
* @param array The array of strings
* @param separator The separator
* @return the resulting string
*/
public static String join(String[] array, String separator) {
int len = array.length;
if (len == 0) return "";

StringBuilder out = new StringBuilder();
out.append(array[0]);
for (int i = 1; i < len; i++) {
out.append(separator).append(array[i]);
}
return out.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@


@io.swagger.annotations.Api(description = "the user API")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-05T15:00:28.637+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-14T21:37:36.074Z")
public class UserApi {
private final UserApiService delegate = UserApiServiceFactory.getUserApi();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;

@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-05T15:00:28.637+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-14T21:37:36.074Z")
public abstract class UserApiService {

public abstract Response createUser(User body,SecurityContext securityContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@



@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-05T15:00:28.637+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-14T21:37:36.074Z")
public class Category {

private Long id = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@



@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-05T15:00:28.637+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-14T21:37:36.074Z")
public class Order {

private Long id = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@



@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-05T15:00:28.637+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-14T21:37:36.074Z")
public class Pet {

private Long id = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@



@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-05T15:00:28.637+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-14T21:37:36.074Z")
public class Tag {

private Long id = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@



@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-05T15:00:28.637+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-14T21:37:36.074Z")
public class User {

private Long id = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import io.swagger.api.PetApiService;
import io.swagger.api.impl.PetApiServiceImpl;

@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-11-05T22:31:25.130-08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-14T21:37:36.074Z")
public class PetApiServiceFactory {

private final static PetApiService service = new PetApiServiceImpl();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.swagger.api.factories;

import io.swagger.api.PettestingByteArraytrueApiService;
import io.swagger.api.impl.PettestingByteArraytrueApiServiceImpl;

@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-14T21:37:36.074Z")
public class PettestingByteArraytrueApiServiceFactory {

private final static PettestingByteArraytrueApiService service = new PettestingByteArraytrueApiServiceImpl();

public static PettestingByteArraytrueApiService getPettestingByteArraytrueApi()
{
return service;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import io.swagger.api.StoreApiService;
import io.swagger.api.impl.StoreApiServiceImpl;

@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-11-05T22:31:25.130-08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-14T21:37:36.074Z")
public class StoreApiServiceFactory {

private final static StoreApiService service = new StoreApiServiceImpl();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import io.swagger.api.UserApiService;
import io.swagger.api.impl.UserApiServiceImpl;

@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-11-05T22:31:25.130-08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-14T21:37:36.074Z")
public class UserApiServiceFactory {

private final static UserApiService service = new UserApiServiceImpl();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;

@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-11-23T10:25:42.314Z")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-01-14T21:37:36.074Z")
public class PetApiServiceImpl extends PetApiService {

@Override
Expand Down Expand Up @@ -72,7 +72,14 @@ public Response deletePet(Long petId,String apiKey,SecurityContext securityConte
}

@Override
public Response uploadFile(Long petId,String additionalMetadata,FormDataContentDisposition fileDetail,SecurityContext securityContext)
public Response uploadFile(Long petId,String additionalMetadata,InputStream inputStream, FormDataContentDisposition fileDetail,SecurityContext securityContext)
throws NotFoundException {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}

@Override
public Response getPetByIdWithByteArray(Long petId,SecurityContext securityContext)
throws NotFoundException {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
Expand Down
Loading