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

Support primitive type with format in response #1754

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

Conversation

sdghchj
Copy link
Member

@sdghchj sdghchj commented Feb 6, 2024

Describe the PR
Support primitive type with format in response

Relation issue
#1714

Signed-off-by: sdghchj <sdghchj@qq.com>
Signed-off-by: sdghchj <sdghchj@qq.com>
Signed-off-by: sdghchj <sdghchj@qq.com>
Copy link

codecov bot commented Feb 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.38%. Comparing base (7147984) to head (045542b).
Report is 26 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1754      +/-   ##
==========================================
- Coverage   83.40%   83.38%   -0.03%     
==========================================
  Files          16       16              
  Lines        3868     3875       +7     
==========================================
+ Hits         3226     3231       +5     
- Misses        544      545       +1     
- Partials       98       99       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sdghchj sdghchj requested a review from ubogdan February 6, 2024 03:02
NUMBER: {"float": true, "double": true},
STRING: {"byte": true, "binary": true, "date": true, "date-time": true, "password": true},
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't use the reverse way

var validPrimitiveFormat = map[string]string{
   "int32": "INTEGER"
   "int64": "INTEGER"
   "float": "NUMBER"
    ....
}

and the condition from operations.go

if !validPrimitiveFormat[refType] != schemaType {

err := operation.ParseComment(comment, nil)
assert.Error(t, err)

comment = `@Success 200 {integer} int32 "response with format"`
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a stupid corner case , Can you show me an example how you send and receive an int32 over an HTTP request ? :)
Usually the response is a JSON object, not a string value 🔦

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