swagger-core icon indicating copy to clipboard operation
swagger-core copied to clipboard

A property named "aFoo" use the method name instead of property name in specification.

Open nithiium opened this issue 4 years ago • 1 comments

I have a property named "aFoo" and the generated specification is not correct.

private boolean aFoo;
public boolean isaFoo() { return aFoo; } 
public void setaFoo(boolean aFoo) { this.aFoo = aFoo; }
{
    "allOf": [
        {
            "type": "object",
            "properties": {
                "isaFoo": {
                    "type": "boolean"
                }
            }
        }
    ],
    "type": "object"
}

The class ModelResolver choose the name of the method instead of the name of the property. The method name is choosed because the first letter after the prefix is not an uppercase but according to the java beans specification the naming is correct and the name of the property should be used.

http://download.oracle.com/otn-pub/jcp/7224-javabeans-1.01-fr-spec-oth-JSpec/beans.101.pdf 8.8 Capitalization of inferred names.

Expected :

{
    "allOf": [
        {
            "type": "object",
            "properties": {
                "aFoo": {
                    "type": "boolean"
                }
            }
        }
    ],
    "type": "object"
}

nithiium avatar Aug 17 '21 08:08 nithiium

Indeed this is the same problem as in #4164, the issues can be linked. The solution (or workaround) is to use @Schema(name="aFoo"), also @JsonProperty("aFoo") should work

gcatanese avatar Apr 15 '22 07:04 gcatanese