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 response model composition #651

Merged
merged 8 commits into from
Mar 23, 2020
Merged

Support response model composition #651

merged 8 commits into from
Mar 23, 2020

Conversation

whunmr
Copy link
Contributor

@whunmr whunmr commented Mar 22, 2020

Describe the PR
Add support for inheritance/Model Composition in Response with allOf and ref.

syntax:

// @success 200 {object} jsonresult.JSONResult{data=proto.Order} "desc"
// @success 200 {object} jsonresult.JSONResult{data=[]proto.Order} "desc"
// @success 200 {object} jsonresult.JSONResult{data=string} "desc"
// @success 200 {object} jsonresult.JSONResult{data=[]string} "desc"

please see generated result in testcases of this PR.

Relation issue
#650

@codecov-io
Copy link

codecov-io commented Mar 22, 2020

Codecov Report

Merging #651 into master will decrease coverage by 0.69%.
The diff coverage is 97.67%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #651      +/-   ##
==========================================
- Coverage   85.74%   85.05%   -0.70%     
==========================================
  Files           7        7              
  Lines        1726     1800      +74     
==========================================
+ Hits         1480     1531      +51     
- Misses        154      171      +17     
- Partials       92       98       +6     
Impacted Files Coverage Δ
operation.go 89.25% <97.67%> (-1.22%) ⬇️
schema.go 96.61% <0.00%> (-3.39%) ⬇️
parser.go 79.91% <0.00%> (-0.72%) ⬇️
gen/gen.go 96.85% <0.00%> (+0.02%) ⬆️

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 8e8a052...e1b41ed. Read the comment docs.

README.md Show resolved Hide resolved
@whunmr whunmr requested a review from sdghchj March 23, 2020 06:31
code optimization
code optimization
code optimization
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

operation.go Outdated Show resolved Hide resolved
operation.go Outdated Show resolved Hide resolved
@sdghchj sdghchj merged commit 8e21f4c into swaggo:master Mar 23, 2020
@sdghchj
Copy link
Member

sdghchj commented Mar 23, 2020

Thank you for your contribution.

@wujie1993
Copy link

awsome!!!

@sdghchj
Copy link
Member

sdghchj commented Mar 27, 2020

There is a bug for int, int32, int64 etc. which should be replaced with integer.
@whunmr Hope you fix it, please.

// @success 200 {object} jsonresult.JSONResult{data=int} "desc"
// @success 200 {object} jsonresult.JSONResult{data=[]int} "desc"

doc for data=int:

"responses": {
        "200": {
            "description": "desc",
            "schema": {
                "allOf": [
                    {
                        "$ref": "#/definitions/jsonresult.JSONResult"
                    },
                    {
                        "type": "object",
                        "properties": {
                            "data": {
                                "type": "int"   //here should be integer
                            }
                        }
                    }
                ]
            }
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants