Add skip header option#253
Conversation
WalkthroughIntroduces a new SkipHeaders option to omit header generation: adds properties to CLI Settings and Core GeneratorSettings, wires it through GenerateCommand, and updates HttpFileGenerator to conditionally skip header emission. Also includes minor Program.cs refactors and an added .gitignore entry. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor U as User
participant CLI as CLI (GenerateCommand)
participant Core as HttpFileGenerator
participant File as Output .http
U->>CLI: Run with options (e.g., --skip-headers)
CLI->>Core: Generate(settings { SkipHeaders })
Core->>Core: WriteFileHeaders()
alt SkipHeaders == true
Note over Core: Header emission skipped
else SkipHeaders == false
Core->>File: Write baseUrl/contentType headers
end
Core->>File: Write requests/body/etc.
File-->>U: Generated file(s)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
src/HttpGenerator.Core/GeneratorSettings.cs (1)
62-66: Add SkipHeaders flag — good, sensible defaultProperty naming and placement are consistent with the rest of the settings.
Consider clarifying the XML doc to: “Skip generating top-of-file @variables (e.g., @baseurl, @ContentType, @authorization).”
src/HttpGenerator.Core/HttpFileGenerator.cs (1)
246-246: Optional: make Content-Type resilient when skipping header variablesWithout
@contentType,Content-Type: {{contentType}}requires a .env var. If you want safer defaults under--skip-headers, inline the content type.- code.AppendLine("Content-Type: {{contentType}}"); + code.AppendLine( + settings.SkipHeaders + ? $"Content-Type: {settings.ContentType}" + : "Content-Type: {{contentType}}");src/HttpGenerator/Settings.cs (1)
85-87: CLI option addition looks good; refine help textFlag naming aligns with behavior. Consider hinting about .env usage in the description to avoid confusion.
Suggested description:
- “Don’t generate top-of-file @variables (e.g., @baseurl, @ContentType, @authorization). Use .env values instead.”
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
.gitignore(1 hunks)src/HttpGenerator.Core/GeneratorSettings.cs(1 hunks)src/HttpGenerator.Core/HttpFileGenerator.cs(2 hunks)src/HttpGenerator/GenerateCommand.cs(3 hunks)src/HttpGenerator/Program.cs(1 hunks)src/HttpGenerator/Settings.cs(3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/HttpGenerator.Core/HttpFileGenerator.cs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Make changes to core HTTP file generation logic in HttpFileGenerator.cs
Files:
src/HttpGenerator.Core/HttpFileGenerator.cs
src/HttpGenerator/{Settings.cs,GenerateCommand.cs}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Modify or add CLI options in Settings.cs and GenerateCommand.cs
Files:
src/HttpGenerator/Settings.cssrc/HttpGenerator/GenerateCommand.cs
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
PR: christianhelle/httpgenerator#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-27T20:12:21.432Z
Learning: Applies to src/HttpGenerator/{Settings.cs,GenerateCommand.cs} : Modify or add CLI options in Settings.cs and GenerateCommand.cs
Learnt from: CR
PR: christianhelle/httpgenerator#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-27T20:12:21.432Z
Learning: Applies to src/HttpGenerator.Core/HttpFileGenerator.cs : Make changes to core HTTP file generation logic in HttpFileGenerator.cs
📚 Learning: 2025-08-27T20:12:21.432Z
Learnt from: CR
PR: christianhelle/httpgenerator#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-27T20:12:21.432Z
Learning: Applies to src/HttpGenerator/{Settings.cs,GenerateCommand.cs} : Modify or add CLI options in Settings.cs and GenerateCommand.cs
Applied to files:
src/HttpGenerator.Core/GeneratorSettings.cssrc/HttpGenerator/Program.cssrc/HttpGenerator/Settings.cssrc/HttpGenerator/GenerateCommand.cs
📚 Learning: 2025-08-27T20:12:21.432Z
Learnt from: CR
PR: christianhelle/httpgenerator#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-27T20:12:21.432Z
Learning: Applies to src/HttpGenerator.Core/HttpFileGenerator.cs : Make changes to core HTTP file generation logic in HttpFileGenerator.cs
Applied to files:
src/HttpGenerator.Core/HttpFileGenerator.cssrc/HttpGenerator/Program.cssrc/HttpGenerator/Settings.cssrc/HttpGenerator/GenerateCommand.cs
🧬 Code graph analysis (2)
src/HttpGenerator/Program.cs (1)
src/HttpGenerator/GenerateCommand.cs (1)
GenerateCommand(12-284)
src/HttpGenerator/GenerateCommand.cs (1)
src/HttpGenerator.Core/HttpFileGenerator.cs (1)
HttpFileGenerator(9-430)
🔇 Additional comments (4)
.gitignore (1)
406-409: LGTM: scoped ignore for editor artifactsIgnoring
.ignore(and documenting the nvim section) is harmless and reduces noise.src/HttpGenerator/GenerateCommand.cs (2)
25-25: Minor style tweak is fineSingle-line await on validation reads fine here.
41-44: Wiring SkipHeaders through to GeneratorSettings looks correctEnd‑to‑end plumbed; result awaited explicitly is fine.
src/HttpGenerator/Program.cs (1)
13-17: Verify C# language version compatibility
args = ["--help"];and target‑typednew()require newer language features. Ensure the repo targets C# 12 (or appropriate SDK) to avoid build breaks.If broader compatibility is desired, revert the array init:
- if (args.Length == 0) args = ["--help"]; + if (args.Length == 0) args = new[] { "--help" };
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #253 +/- ##
=======================================
Coverage 95.07% 95.07%
=======================================
Files 10 10
Lines 325 325
=======================================
Hits 309 309
Partials 16 16
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@PolarTango thanks for taking the time to implement this |
christianhelle
left a comment
There was a problem hiding this comment.
@PolarTango This looks good to me.
Can you update Usage section in the README files to include the new --skip-headers argument?
README.md is found both at the root and src/HttpGenerator/README.md
|
|
@PolarTango thanks for your contribution ❤️ |



name: Pull request
title: ""
labels: enhancement
assignees: PolarTango
Description:
Option, that remove headers like @hostUrl or @contantType from start of the file.
Provides better experience when using .env file to not manually remove it from every file.
Summary by CodeRabbit
New Features
Refactor
Chores