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

issue-665: fix example when using json=",string" #677

Merged
merged 2 commits into from Apr 16, 2020

Conversation

tcarreira
Copy link

Describe the PR
Fix the json example when a struct field has the json:",string" tag.

Relation issue
#665

Additional context
encoding/json states:

The "string" option signals that a field is stored as JSON inside a JSON-encoded string. It applies only to fields of string, floating point, integer, or boolean types. This extra level of encoding is sometimes used when communicating with JavaScript programs:


Before this fix, the provided example would fail json.Unmarshal:
Screenshot_20200414_215316

After fix:
Screenshot_20200414_215541

@codecov-io
Copy link

codecov-io commented Apr 15, 2020

Codecov Report

Merging #677 into master will increase coverage by 0.29%.
The diff coverage is 90.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #677      +/-   ##
==========================================
+ Coverage   85.00%   85.29%   +0.29%     
==========================================
  Files           7        7              
  Lines        1807     1823      +16     
==========================================
+ Hits         1536     1555      +19     
+ Misses        172      171       -1     
+ Partials       99       97       -2     
Impacted Files Coverage Δ
parser.go 80.42% <90.00%> (+0.63%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dc90151...fa78550. Read the comment docs.

Copy link
Member

@sdghchj sdghchj left a comment

Choose a reason for hiding this comment

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

structField.schemaType = "string"

parser.go Show resolved Hide resolved
Copy link
Member

@sdghchj sdghchj left a comment

Choose a reason for hiding this comment

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

LGTM

@sdghchj sdghchj merged commit 93e5f15 into swaggo:master Apr 16, 2020
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.

None yet

3 participants