ng-swagger-gen icon indicating copy to clipboard operation
ng-swagger-gen copied to clipboard

Text plain type generated as json

Open Lui92 opened this issue 4 years ago • 2 comments

Hi,

I would like to ask why text plain media type is generated as a json? Or maybe there is something wrong with it. I have this class:

@Path("/translations")
@Api(value = "/translations", produces = MediaType.TEXT_PLAIN)
public interface TranslationRestService {

	@GET
	@Path("/")
	@Produces(MediaType.TEXT_PLAIN)
	@ApiOperation(produces = MediaType.TEXT_PLAIN, value = "Get translations by language", code = 200)
	Response getTranslations(@QueryParam("lang") String lang);
}

And when running ng-swagger-gen it generates like that:

// rest of generated service
      {
        headers: __headers,
        params: __params,
        responseType: 'json'
      });

In swagger it's normally available as text/plain. I'm using the newest version.

Lui92 avatar Jul 16 '21 11:07 Lui92

It depends on your source swagger definition. Posting it can help...

luisfpg avatar Jul 16 '21 13:07 luisfpg

@luisfpg Sorry for the delay... I've totally forgot about it...

{
  "swagger" : "2.0",
  "info" : {
    "description" : "This document contains the Rest service definition\n\t\t\t\t\t\t\t\t\tfor XXX application",
    "version" : "1.0.0",
    "title" : "XXX RESTful Service",
    "license" : {
      "name" : "XXX"
    }
  },
  "basePath" : "/XXX/zzz/",
  "tags" : [ {
    "name" : "translations"
  } ],
  "schemes" : [ "http", "https" ],
  "paths" : {
	"/translations" : {
      "get" : {
        "tags" : [ "translations" ],
        "summary" : "Get translations by language",
        "description" : "",
        "operationId" : "getTranslations",
        "produces" : [ "text/plain" ],
        "parameters" : [ {
          "name" : "lang",
          "in" : "query",
          "required" : false,
          "type" : "string"
        } ],
        "responses" : {
          "default" : {
            "description" : "successful operation"
          }
        }
      }
    },
  },
}

Lui92 avatar Nov 18 '21 13:11 Lui92