Skip to content

[Java][CXF] Some names of properties of JSON objects do not match the definition in the YAML #6693

Closed
@gustavoapaz

Description

@gustavoapaz
Description

For some names used to define Data types properties in a YAML, the JSON objects that the Java CXF Server expects and/or produces do not match the definition in the YAML.

Swagger-codegen version

2.3.0

Swagger declaration file content or url

For example an attribute defined in the YAML like this:

      EX_TYPE:
        type: "integer"

Generates the following Java server code:

public Integer getEXTYPE() {

This causes that the object corresponds to another JSON representation rather than the one intended.

Intended JSON:

EX_TYPE: 1

Obtained JSON:

EXTYPE: 1
Command line used for generation

..

Steps to reproduce

..

Related issues/PRs

..

Suggest a fix/enhancement

The CXF generation template for Data types could add the JsonProperty anotation to include the real name of the property.

By adding the following line to the pojo.mustache of JavaJaxRS/cxf

@JsonProperty("{{name}}")

The resulting Java code works without the above mentioned issue:

@JsonProperty("EX_TYPE")
public Integer getEXTYPE() {

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