feat: add opt-out for JsonPropertyName attributes#47
feat: add opt-out for JsonPropertyName attributes#47nikcio merged 4 commits intoNikcio-labs:mainfrom
Conversation
|
full disclosure: Coded by Claude, but I verified it works manually by compiling and running the tool on our own spec |
There was a problem hiding this comment.
Pull request overview
Adds a new generator option to suppress emitting System.Text.Json.Serialization.JsonPropertyName attributes, with corresponding CLI/docs updates, to support consumers that rely on serializer naming policies instead of per-property attributes.
Changes:
- Added
GeneratorOptions.GenerateJsonPropertyNameAttributes(defaulttrue) to control[JsonPropertyName]emission. - Wired the option through the CLI via
--no-json-property-name-attributesand updated help text / docs. - Added unit + integration tests covering the opt-out behavior and confirming the default remains enabled.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/OpenApiCodeGenerator.Tests/GeneratorOptionsTests.cs | Asserts the new option defaults to true. |
| tests/OpenApiCodeGenerator.Tests/CSharpSchemaGeneratorTests.cs | Integration coverage ensuring generated code omits [JsonPropertyName] and serializes correctly with a naming policy when disabled. |
| tests/OpenApiCodeGenerator.Tests/CSharpCodeEmitterTests.cs | Unit coverage ensuring emitter skips property attributes when disabled. |
| src/OpenApiCodeGenerator/GeneratorOptions.cs | Introduces GenerateJsonPropertyNameAttributes option with docs and default. |
| src/OpenApiCodeGenerator/CSharpCodeEmitter.cs | Gates [JsonPropertyName] emission behind the new option. |
| src/OpenApiCodeGenerator.Cli/Program.cs | Adds --no-json-property-name-attributes flag and passes it into GeneratorOptions. |
| docs/src/content/docs/reference/cli.md | Documents the new CLI flag and adds it to examples. |
| docs/src/content/docs/guides/configuration.md | Documents the library option + CLI mapping, plus guidance and examples. |
| README.md | Updates CLI options list to include the new flag. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c440c1e to
506e8be
Compare
|
fixed merge conflicts |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
GenerateJsonPropertyNameAttributesoption (defaulttrue) toGeneratorOptionsso[JsonPropertyName]emission can be suppressed.--no-json-property-name-attributes.Test plan
CSharpCodeEmitterTestscovers the opt-out pathCSharpSchemaGeneratorTestsverifies generated output omits the attribute when disabledGeneratorOptionsTestsconfirms the default remainstrue(no behavior change for existing users)Replaces #45 — re-opened from a dedicated feature branch so my fork's
maincan track upstream cleanly.