Skip to content

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

Merged
ubogdan merged 2 commits into
swaggo:masterfrom
starcharles:feature/swagger-yml
Jul 28, 2023
Merged

ubogdan merged 2 commits into
swaggo:masterfrom
starcharles:feature/swagger-yml

Conversation

@starcharles

@starcharles starcharles commented Jul 22, 2023 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

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

@EdouardBavoux EdouardBavoux left a comment

Copy link
Copy Markdown

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

Comment thread swagger.go
}

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

Copy link
Copy Markdown

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
Copy Markdown
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,

Copy link
Copy Markdown

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.

@EdouardBavoux EdouardBavoux left a comment

Copy link
Copy Markdown

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

starcharles commented Jul 26, 2023 •

Copy link
Copy Markdown
Contributor Author

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

@starcharles

Copy link
Copy Markdown
Contributor Author

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

Comment thread swagger.go
}

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

Copy link
Copy Markdown
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

codecov Bot commented Jul 27, 2023 •

Copy link
Copy Markdown

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
Copy Markdown
Contributor Author

need tests?

@ubogdan
ubogdan merged commit 3361106 into swaggo:master Jul 28, 2023
@ubogdan

ubogdan commented Jul 28, 2023 •

Copy link
Copy Markdown
Contributor

@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

⌂ 换网址