Skip to content

feat(validate): warn on spec names that contain a line break - #313

Merged
fredbi merged 1 commit into
go-openapi:masterfrom
fredbi:feat/warn-on-dubious-names
Nov 19, 2026
Merged

fredbi merged 1 commit into
go-openapi:masterfrom
fredbi:feat/warn-on-dubious-names

Conversation

@fredbi

@fredbi fredbi commented Nov 19, 2026

Copy link
Copy Markdown
Member

Code generators print spec names into comments and string literals of the generated source. A line feed in a name ends a // comment there, and the rest of the name compiles as code. No Swagger 2.0 name needs a line break, so validateDubiousNames adds a DubiousNameWarning, located by JSON pointer, for any name holding \n or \r: path templates, operationIds, tags, parameter names, response header names, the keys of the top-level parameters and responses, definition and property names, discriminators, auth scheme keys and apiKey names.

Descriptions, examples, enum and default values may span lines and are not checked. Findings are warnings: a spec that was valid stays valid.

Change type

Please select: 🆕 New feature or enhancement|🔧 Bug fix'|📃 Documentation update

Short description

Fixes

Full description

Checklist

  • I have signed all my commits with my name and email (see DCO. This does not require a PGP-signed commit
  • I have rebased and squashed my work, so only one commit remains
  • I have added tests to cover my changes.
  • I have properly enriched go doc comments in code.
  • I have properly documented any breaking change.

Code generators print spec names into comments and string literals of
the generated source. A line feed in a name ends a // comment there, and
the rest of the name compiles as code. No Swagger 2.0 name needs a line
break, so validateDubiousNames adds a DubiousNameWarning, located by
JSON pointer, for any name holding \n or \r: path templates,
operationIds, tags, parameter names, response header names, the keys of
the top-level parameters and responses, definition and property names,
discriminators, auth scheme keys and apiKey names.

Descriptions, examples, enum and default values may span lines and are
not checked. Findings are warnings: a spec that was valid stays valid.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.26027% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.97%. Comparing base (8c0eece) to head (b067f0b).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
spec_name_warnings.go 97.05% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master     #313   +/-   ##
=======================================
  Coverage   96.97%   96.97%           
=======================================
  Files          34       35    +1     
  Lines        3797     3868   +71     
=======================================
+ Hits         3682     3751   +69     
- Misses        111      113    +2     
  Partials        4        4           

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

@fredbi
fredbi merged commit 507f2d3 into go-openapi:master Nov 19, 2026
25 checks passed
@fredbi
fredbi deleted the feat/warn-on-dubious-names branch November 19, 2026 19:11
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.

1 participant