christianhelle / httpgenerator

Generate .http files from OpenAPI (Swagger) specifications
MIT License
74 stars 6 forks source link

Generate file per tag #98

Closed ikopytko closed 3 months ago

ikopytko commented 3 months ago

This PR is related to feature request #97 Added support to generate file per operation tag. This implementation is not particularly efficient, as it will store partial result in StringBuilder for each file in memory, but it shouldn't cause much impact than building single file.

OpenAPI allows to specify more than one tag per operation and Swagger UI will show the same request under multiple categories. But this implementation will look only for the first tag (this will be a controller name in case of default MVC Core configuration).

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 58.62069% with 12 lines in your changes missing coverage. Please review.

Project coverage is 83.70%. Comparing base (c0ab9da) to head (c33d517). Report is 87 commits behind head on main.

Files Patch % Lines
src/HttpGenerator.Core/HttpFileGenerator.cs 58.62% 8 Missing and 4 partials :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #98 +/- ## ========================================== - Coverage 85.50% 83.70% -1.80% ========================================== Files 20 20 Lines 600 675 +75 ========================================== + Hits 513 565 +52 - Misses 56 77 +21 - Partials 31 33 +2 ``` | [Flag](https://app.codecov.io/gh/christianhelle/httpgenerator/pull/98/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Christian+Helle) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/christianhelle/httpgenerator/pull/98/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Christian+Helle) | `83.70% <58.62%> (-1.80%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Christian+Helle#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

christianhelle commented 3 months ago

@ikopytko I pulled the branch and tried it locally. The code looks good to me, It does what it should, and works fine

I tried generating files using all 3 available options (single file, per request, and per tag). When generating per tag, the output files use the tag value as it is for the filename, whereas the other options capitalize the first letter. Can we align it with the different options and capitalize the first letter?

sonarcloud[bot] commented 3 months ago

Quality Gate Passed Quality Gate passed

Issues
2 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

ikopytko commented 3 months ago

@christianhelle that's great! Regarding file names - absolutely, already added the capitalization. I'm working mainly with asp.net controllers so I took it for granted.