Skip to content

feat(swagger): support wrapCodeMsgMapping #4996

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

jaronnie
Copy link
Contributor

If wrapCodeMsg is configured, the swagger response has the fields code, data, and msg by default. Now it supports custom configuration mapping. The default is: {"code":"code", "data":"data", "msg":"msg"}. Based on this, a new field wrapCodeMsgMapping is added, such as:

info (
  wrapCodeMsg: "true"
  wrapCodeMsgMapping: `{"code":"statusCode", "data": "data", "msg": "comments"}`
)

Copy link

codecov bot commented Jul 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.92%. Comparing base (8690859) to head (e3affdf).
Report is 377 commits behind head on master.

Additional details and impacted files

see 21 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

globalCodeDesc := ctx.BizCodeEnumDescription
methodCodeDesc := getStringFromKVOrDefault(atDoc.Properties, propertyKeyBizCodeEnumDescription, globalCodeDesc)
return spec.SchemaProps{
Type: []string{swaggerTypeObject},
Properties: spec.SchemaProperties{
"code": {
wrapCodeMsgMapping.Code: {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls ignore this operation if the value of wrapCodeMsgMapping.Code is empty, and the same operation withwrapCodeMsgMapping.Data, wrapCodeMsgMapping.Msg too.

@jaronnie jaronnie force-pushed the feat/goctl_api_wrapCodeMsg branch from e3affdf to abb75d7 Compare July 14, 2025 02:40
@jaronnie jaronnie requested a review from kesonan July 14, 2025 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants