swagger-api / swagger-api/swagger-core

Field with first letter lower case not recognized

Open
#2,961 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

backlog
Dominant language
Java
Stars
7.5k
Forks
2.3k
Avg merge
18h 1m
Merged PRs (30d)
10

Description

According to java spec (http://download.oracle.com/otn-pub/jcp/7224-javabeans-1.01-fr-spec-oth-JSpec/beans.101.pdf p. 57) the getter for a field like aField (first character in lower case and second character in upper case) is getaField with first letter not modified.
In ModelResolver due to #415 the method getaField is treated like an alternative name for the field and the resulting yaml is:

....
    properties:
      getaField:
        type: "string"
....

I can of course annotate getter with ApiModelProperty but IMO this is a bug.
You can take advantage of java.beans.Introspector#decapitalize to fix the issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in ModelResolver and reproduce the schema generation for a field named aField with a getter named getaField. Read the JavaBeans Introspector#decapitalize behavior and verify that the generated YAML uses aField rather than getaField; done means the getter is no longer treated as an alternative property name.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.