Skip to content

ApiListingResource doesn't respect pretty print support #2320

@alexandrebrasil

Description

@alexandrebrasil

I configured Swagger using BeanConfig on my Application start up to use pretty print, but when I retrieve the API from swagger.json endpoint it's all on a single line.

I've tracked the issue down to the ApiListingResource. When this resource processes the API, it doesn't return a Swagger object on the Response (that would be then converted by SwaggerSerializers), but returns a text string instead.

If ApiListingResource responds with the Swagger object instead, the serialization works fine and respect the pretty print request. Could the getListing() code be changed from

        if (StringUtils.isNotBlank(type) && type.trim().equalsIgnoreCase("yaml")) {
            return getListingYamlResponse(app, context, sc, headers, uriInfo);
        } else {
            return getListingJsonResponse(app, context, sc, headers, uriInfo);
        }

to

		Swagger swagger = process(app, context, sc, headers, uriInfo);
		if(swagger == null) {
			return Response.status(Status.NOT_FOUND).build();
		} else {
			return Response.ok(swagger, "json".equals(type) ? MediaType.APPLICATION_JSON_TYPE : new MediaType("application", "yaml")).build();
		}

or would it affect some functionality I'm not aware of?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions