Skip to content

Add skip header option#253

Merged
christianhelle merged 3 commits intochristianhelle:mainfrom
PolarTango:polartango/skip-headers
Sep 19, 2025
Merged

Add skip header option#253
christianhelle merged 3 commits intochristianhelle:mainfrom
PolarTango:polartango/skip-headers

Conversation

@PolarTango
Copy link
Contributor

@PolarTango PolarTango commented Sep 17, 2025


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

    • Added a --skip-headers option to the generator to omit HTTP header lines (e.g., base URL, content type) in output files. Default behavior is unchanged unless this flag is used.
  • Refactor

    • Minor CLI and initialization cleanups with no impact on behavior.
  • Chores

    • Updated ignore rules to exclude files/directories named .ignore.

@coderabbitai
Copy link

coderabbitai bot commented Sep 17, 2025

Walkthrough

Introduces 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

Cohort / File(s) Summary of changes
Git ignore update
\.gitignore
Added comment line and pattern .ignore; no existing rules changed.
Core: header-skipping support
src/HttpGenerator.Core/GeneratorSettings.cs, src/HttpGenerator.Core/HttpFileGenerator.cs
Added SkipHeaders to GeneratorSettings. HttpFileGenerator.WriteFileHeaders now early-returns when SkipHeaders is true.
CLI: option and wiring
src/HttpGenerator/Settings.cs, src/HttpGenerator/GenerateCommand.cs
Added CLI option --skip-headers (Settings.SkipHeaders) with description. Passed through to GeneratorSettings in GenerateCommand. Minor formatting and type annotation changes.
CLI startup/style tweaks
src/HttpGenerator/Program.cs
Compact args handling, target-typed new for CommandApp, simplified Console qualification. Behavior unchanged.

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)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I twitched my nose at headers tall,
A hop, a flag—now none at all.
With lighter files I leap ahead,
Less fluff, more carrots, code instead.
Thump-thump! The garden’s neatly pared—
Skip the tops, the roots are shared. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Add skip header option" succinctly and accurately describes the primary change in this PR: introducing a SkipHeaders setting and a corresponding --skip-headers CLI option to suppress generated file headers. It is concise, relevant to the code changes (GeneratorSettings, Settings, and generation behavior) and clear enough for a reviewer scanning history to understand the main intent.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
src/HttpGenerator.Core/GeneratorSettings.cs (1)

62-66: Add SkipHeaders flag — good, sensible default

Property 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 variables

Without @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 text

Flag naming aligns with behavior. Consider hinting about .env usage in the description to avoid confusion.

Suggested description:

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8c70f59 and 4933aca.

📒 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.cs
  • src/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.cs
  • src/HttpGenerator/Program.cs
  • src/HttpGenerator/Settings.cs
  • src/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.cs
  • src/HttpGenerator/Program.cs
  • src/HttpGenerator/Settings.cs
  • src/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 artifacts

Ignoring .ignore (and documenting the nvim section) is harmless and reduces noise.

src/HttpGenerator/GenerateCommand.cs (2)

25-25: Minor style tweak is fine

Single-line await on validation reads fine here.


41-44: Wiring SkipHeaders through to GeneratorSettings looks correct

End‑to‑end plumbed; result awaited explicitly is fine.

src/HttpGenerator/Program.cs (1)

13-17: Verify C# language version compatibility

args = ["--help"]; and target‑typed new() 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" };

@christianhelle christianhelle self-assigned this Sep 18, 2025
@christianhelle christianhelle added the enhancement New feature or request label Sep 18, 2025
@codecov
Copy link

codecov bot commented Sep 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.07%. Comparing base (aa78ac0) to head (34ffe5d).
⚠️ Report is 5 commits behind head on main.

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           
Flag Coverage Δ
unittests 95.07% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@christianhelle
Copy link
Owner

@PolarTango thanks for taking the time to implement this

Copy link
Owner

@christianhelle christianhelle left a comment

Choose a reason for hiding this comment

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

@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

@sonarqubecloud
Copy link

@christianhelle christianhelle merged commit 22b00fa into christianhelle:main Sep 19, 2025
10 checks passed
@christianhelle
Copy link
Owner

@PolarTango thanks for your contribution ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants