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

feat: add feature to expose yaml format OpenAPI document #111

Merged
merged 2 commits into from
Jul 28, 2023

Conversation

starcharles
Copy link
Contributor

@starcharles starcharles commented Jul 22, 2023

Describe the PR
add feature to expose yaml format OpenAPI document.

You can see yaml formatted openapi document at "/swagger/doc.yaml" endpoint.

Relation issue
#109

Additional context
It's sometimes comfortable to get yaml format openapi document from Swagger UI.

@starcharles starcharles marked this pull request as ready for review July 22, 2023 14:47
@starcharles
Copy link
Contributor Author

@ubogdan Please review my PR!!!
THANKS in advance!!!

Copy link

@EdouardBavoux EdouardBavoux left a comment

Choose a reason for hiding this comment

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

Thanks a lot. I just have one suggestion so far. I'll test it and let you know

@@ -170,7 +173,20 @@ func EchoWrapHandler(options ...func(*Config)) echo.HandlerFunc {
}

_, _ = c.Response().Writer.Write([]byte(doc))
case "doc.yaml":

Choose a reason for hiding this comment

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

There is already a .yaml file generated, it is probably better to read it directly than doing the conversion from json ?

Copy link
Contributor

Choose a reason for hiding this comment

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

The yaml file is not embedded in the binary so reading it from disk may be a problem,

Choose a reason for hiding this comment

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

Makes perfect sense, thanks for the info. So let's merge it this way.

Copy link

@EdouardBavoux EdouardBavoux left a comment

Choose a reason for hiding this comment

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

OK, I did a few tests and it looks good to me ! Thanks

@starcharles
Copy link
Contributor Author

starcharles commented Jul 26, 2023

@EdouardBavoux Thanks fo approval this PR!
Is this PR can be merged?
or another reviewer need to approve?

@starcharles
Copy link
Contributor Author

@ubogdan Please review this PR if you have time Thanks.

@@ -170,7 +173,20 @@ func EchoWrapHandler(options ...func(*Config)) echo.HandlerFunc {
}

_, _ = c.Response().Writer.Write([]byte(doc))
case "doc.yaml":
Copy link
Contributor

Choose a reason for hiding this comment

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

The yaml file is not embedded in the binary so reading it from disk may be a problem,

@codecov
Copy link

codecov bot commented Jul 27, 2023

Codecov Report

Patch coverage: 14.28% and project coverage change: -13.64% ⚠️

Comparison is base (a969428) 100.00% compared to head (96b5024) 86.36%.

❗ Current head 96b5024 differs from pull request most recent head cbc2bc0. Consider uploading reports for the commit cbc2bc0 to get more accurate results

Additional details and impacted files
@@             Coverage Diff              @@
##            master     #111       +/-   ##
============================================
- Coverage   100.00%   86.36%   -13.64%     
============================================
  Files            1        1               
  Lines           76       88       +12     
============================================
  Hits            76       76               
- Misses           0       12       +12     
Files Changed Coverage Δ
swagger.go 86.36% <14.28%> (-13.64%) ⬇️

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

@starcharles
Copy link
Contributor Author

need tests?

@ubogdan ubogdan merged commit 3361106 into swaggo:master Jul 28, 2023
5 checks passed
@ubogdan
Copy link
Contributor

ubogdan commented Jul 28, 2023

@starcharles Thanks for your contribution.
No, just got busy with other things.

rytsh pushed a commit to worldline-go/echo-swagger that referenced this pull request May 16, 2024
* feat: respond yaml format
* feat: modify swagger-UI
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.

3 participants