Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ✨ Add support for Map with enum type keys #870

Merged

Conversation

linwumingshi
Copy link
Collaborator

@linwumingshi linwumingshi commented Aug 8, 2024

#387

Examle Demo

/**
 * @author yu 2021/7/11.
 */
public enum Sex {

    /**
     * male
     */
    MALE,
    /**
     * female
     */
    FEMALE
}
@RestController
@RequestMapping("map/")
public class MapController {

    /**
     * Test Map with enum type keys
     *
     * @param param map
     * @return Map
     */
    @PostMapping("/some/path")
    public Map<Sex, Name> query(@RequestBody Map<Sex, Name> param) {
        return param;
    }
    /**
     * Test Map Value
     */
    @Data
    public static class Name {
        /**
         * name
         */
        private String name;
    }
}

Before the PR:

Body-parameters:

Parameter Type Required Description Since
name string false name -

Request-example:

curl -X POST -H "Content-Type: application/json" -H "token:kk" -i 'http://127.0.0.1:8080/map/some/path' --data '{
  "mapKey": {
    "name": ""
  }
}'

Response-fields:

Field Type Description Since
└─name string name -

Response-example:

{
  "mapKey": {
    "name": ""
  }
}

After the PR:

Body-parameters:

Parameter Type Required Description Since
MALE object false Test Map Value -
└─name string false name -
FEMALE object false Test Map Value -
└─name string false name -

Request-example:

curl -X POST -H "Content-Type: application/json" -H "token:kk" -i 'http://127.0.0.1:8080/map/some/path' --data '{
  "MALE": {
    "name": ""
  },
  "FEMALE": {
    "name": ""
  }
}'

Response-fields:

Field Type Description Since
MALE object Test Map Value -
└─name string name -
FEMALE object Test Map Value -
└─name string name -

Response-example:

{
  "MALE": {
    "name": ""
  },
  "FEMALE": {
    "name": ""
  }
}

@shalousun shalousun added this to the 3.0.7 milestone Aug 9, 2024
@shalousun shalousun added the enhancement New feature or request label Aug 9, 2024
@shalousun shalousun merged commit c62f935 into TongchengOpenSource:master Aug 9, 2024
7 checks passed
@linwumingshi linwumingshi deleted the feature/map-key-enum branch August 9, 2024 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants