Skip to content

[JAVA SPRING] error: constant string too long #9055

@drej1

Description

@drej1
Description

The swagger-codegen generates for spring server an interface where there is a too long string constant based on the swagger definition.

...
default ResponseEntity<List<Customer>> customerFind(@ApiParam(value = "") @Valid @RequestParam(value = "relatedPartyId", required = false) String relatedPartyId,@ApiParam(value = "") @Valid @RequestParam(value = "relatedPartyRole", required = false) String relatedPartyRole,@ApiParam(value = "") @Valid @RequestParam(value = "fields", required = false) String fields,@ApiParam(value = "") @Valid @RequestParam(value = "query", required = false) String query,@ApiParam(value = "Defines page") @Valid @RequestParam(value = "page", required = false) BigDecimal page,@ApiParam(value = "Limits the number of results for paging") @Valid @RequestParam(value = "size", required = false) BigDecimal size,@ApiParam(value = "Entity ordering") @Valid @RequestParam(value = "sort", required = false) String sort) {
        if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
            if (getAcceptHeader().get().contains("application/json")) {
                try {
                    return new ResponseEntity<>(getObjectMapper().get().readValue("[ {  \"characteristics\" : [ .................... too long string constant

It ends with compilation error:

...\build\generated-sources\swagger\src\main\java\sk\telekom\oneapp\hal\api\CustomersApi.java:71: error: constant string too long
                    return new ResponseEntity<>(getObjectMapper().get().readValue("[ {  \"charact
Swagger-codegen version

2.4.0

Swagger declaration file content or url

https://gist.github.com/drej1/418d1dfa7924471a664fcd4e6fb6b3d2

Command line used for generation

used created gradle task using swagger-codegen with:

config.setLang("spring")
config.setAdditionalProperties([
    "modelPackage"     : modelPackage,
    "apiPackage"       : apiPackage,
    "java8"            : true,
    "serializableModel": true,
    "interfaceOnly"    : true
])
Steps to reproduce
  1. generate spring API server interfaces for yaml with a really complex type definition
Suggest a fix/enhancement

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions