swagger-core icon indicating copy to clipboard operation
swagger-core copied to clipboard

Invalid swagger generated

Open sschwell opened this issue 11 years ago • 2 comments

Dropwizard 0.7.1, Jersey 1.18.1

The following method signature:

@POST
@Consumes(UTF8MediaType.MULTIPART_FORM_DATA)
@Path("/document/uploadAttachAndParse/user/{userId}/{slug}/{documentName}/{type}.json") @Timed @UnitOfWork
@ApiOperation(value="uploadAttachAndParseUserDocument", notes="Uploads, parses, and attaches the document to the user's job application.", response=DocumentAndInfo.class, position=509)
public DocumentAndInfo uploadAttachAndParseUserDocument(@PathParam("userId") @ApiParam(required = true) final String userId,
                                                                                                      @PathParam("slug") final String slug,
                                                                                                      @PathParam("type") String type,
                                                                                                      @PathParam("documentName") final String documentName,
                                                                                           @HeaderParam(ClientDAO.HEADER_NAME) final String clientCode,
                                                                                                      @QueryParam("uploadToken") final String uploadToken,
                                                                                                      @FormDataParam("document") final InputStream input,
                                                                                                      @FormDataParam("document") final FormDataContentDisposition detail,
                                                                                                      @FormDataParam("document") final FormDataBodyPart bodyPart,
                                                                                                      @Context final HttpServletRequest request) throws Exception

generates swagger.json which gets the following from the validator:

    [{"level":"error","domain":"validation","keyword":"oneOf","message":"instance failed to match exactly one schema (matched 0 out of 2)","schema":{"loadingURI":"http://swagger.io/v2/schema.json#","pointer":"/definitions/parametersList/items"},"instance":{"pointer":"/paths/~1questions~1document~1uploadAttach~1user~1{userId}~1{slug}~1{documentName}~1{type}.json/post/parameters/7"}}]

See https://groups.google.com/forum/#!topic/swagger-swaggersocket/rgljt090enw

sschwell avatar Jun 22 '15 13:06 sschwell

Some more information for whoever is going to fix it - the problem is that FormDataBodyPart is not ignored when generating the Swagger document even though it should be. FormDataContentDisposition is ignored properly. This is true for both the Jersey and Jersey 2 implementations.

webron avatar Jun 22 '15 13:06 webron

Fixed in develop_2.0.

webron avatar Jul 31 '15 18:07 webron