forked from loafle/openapi-generator-original
[jaxrs-resteasy] multiple values for @Produces annotation are separated by a comma (#445)
* fix: The values for @Produces annotation were not separated by a comma. * Add test case for #443
This commit is contained in:
parent
960412a9b4
commit
d6e950f681
@ -4033,6 +4033,11 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
mediaType.put("hasMore", null);
|
||||
}
|
||||
|
||||
if (!codegenOperation.produces.isEmpty()) {
|
||||
final Map<String, String> lastMediaType = codegenOperation.produces.get(codegenOperation.produces.size() - 1);
|
||||
lastMediaType.put("hasMore", "true");
|
||||
}
|
||||
|
||||
codegenOperation.produces.add(mediaType);
|
||||
codegenOperation.hasProduces = Boolean.TRUE;
|
||||
}
|
||||
|
@ -21,11 +21,14 @@ import io.swagger.parser.OpenAPIParser;
|
||||
import io.swagger.v3.oas.models.Components;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Content;
|
||||
import io.swagger.v3.oas.models.media.MediaType;
|
||||
import io.swagger.v3.oas.models.media.ObjectSchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.parameters.RequestBody;
|
||||
import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.models.responses.ApiResponses;
|
||||
|
||||
import io.swagger.v3.parser.core.models.ParseOptions;
|
||||
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
@ -153,6 +156,15 @@ public class DefaultCodegenTest {
|
||||
Assert.assertTrue(coJson.hasProduces);
|
||||
Assert.assertEquals(coJson.produces.size(), 1);
|
||||
Assert.assertEquals(coJson.produces.get(0).get("mediaType"), "application/json");
|
||||
|
||||
Operation issue443Operation = openAPI.getPaths().get("/other/issue443").getGet();
|
||||
CodegenOperation coIssue443 = codegen.fromOperation("/other/issue443", "get", issue443Operation, ModelUtils.getSchemas(openAPI), openAPI);
|
||||
Assert.assertTrue(coIssue443.hasProduces);
|
||||
Assert.assertEquals(coIssue443.produces.size(), 2);
|
||||
Assert.assertEquals(coIssue443.produces.get(0).get("mediaType"), "application/json");
|
||||
Assert.assertEquals(coIssue443.produces.get(0).get("hasMore"), "true");
|
||||
Assert.assertEquals(coIssue443.produces.get(1).get("mediaType"), "application/text");
|
||||
Assert.assertEquals(coIssue443.produces.get(1).get("hasMore"), null);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -33,3 +33,30 @@ paths:
|
||||
timestamp:
|
||||
type: string
|
||||
example: '{ "message": "Hello world", "timestamp": "2018-06-29T07:32:23Z"}'
|
||||
/other/issue443:
|
||||
get:
|
||||
operationId: issue443
|
||||
responses:
|
||||
'200':
|
||||
description: Expected response to a valid request
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/LocationData'
|
||||
default:
|
||||
description: Unexpected error
|
||||
content:
|
||||
application/text:
|
||||
schema:
|
||||
type: string
|
||||
components:
|
||||
schemas:
|
||||
LocationData:
|
||||
type: object
|
||||
properties:
|
||||
xPos:
|
||||
type: integer
|
||||
format: int32
|
||||
yPos:
|
||||
type: integer
|
||||
format: int32
|
||||
|
Loading…
x
Reference in New Issue
Block a user