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

fix: parseField skips not-exported (encoding/json-like) #675

Merged
merged 3 commits into from
Apr 15, 2020

Conversation

tcarreira
Copy link

Describe the PR
In order to match encoding/json behaviour for Marshaling struct into JSON, we should not parse non-exported fields (aka: fields starting with a lower letter)

Relation issue
#666

Additional context
With this commit, I had to apply a small fix to a test. I really think it's ok, but please, verify it.

@sdghchj
Copy link
Member

sdghchj commented Apr 14, 2020

So you dropped backward compatibility, though it's not a big trouble.

@sergeydobrodey
Copy link

This feature is very useful when structures are generated using new version of protoc-gen-go: https://blog.golang.org/protobuf-apiv2

Generated structures have technical fields without json:"-" annotation. Maybe you can add run flag if backward compatibility is obligatory?

@easonlin404
Copy link
Member

Although causing non-backward compatibility, it makes sense that not-exported fields don't need to parse for marshaling struct into JSON.

@easonlin404 easonlin404 requested a review from a team April 14, 2020 16:27
@easonlin404 easonlin404 requested a review from a team April 14, 2020 16:28
@easonlin404
Copy link
Member

What's your guys thought on it? @swaggo/swaggo-core-team

@codecov-io
Copy link

Codecov Report

Merging #675 into master will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #675      +/-   ##
==========================================
+ Coverage   84.98%   85.00%   +0.01%     
==========================================
  Files           7        7              
  Lines        1805     1807       +2     
==========================================
+ Hits         1534     1536       +2     
  Misses        172      172              
  Partials       99       99              
Impacted Files Coverage Δ
parser.go 79.79% <100.00%> (+0.04%) ⬆️

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 ac5b59a...6f65efc. Read the comment docs.

@sdghchj sdghchj merged commit dc90151 into swaggo:master Apr 15, 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.

5 participants