Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2820b40
feat: add support for x-request-body-extra-annotation to merge operat…
Picazsoo Aug 26, 2026
813b7a4
update comments and docs
Picazsoo Aug 26, 2026
55e317c
support also header params and cookie params
Picazsoo Aug 26, 2026
c977ee8
update docs
Picazsoo Aug 26, 2026
eda2dd1
feat: add --inject-operation-vendor-extensions to inject operation an…
Picazsoo Aug 26, 2026
f8cc18c
test: cover requestBody-object and reusable requestBodies extra-annot…
Picazsoo Aug 26, 2026
22a9d98
Address review findings on vendor-extension work
Picazsoo Aug 26, 2026
9f45ec5
Handle blank operationId and fix test assertion order
Picazsoo Aug 26, 2026
d0aafd2
Assert operationId invariant instead of silent blank guard
Picazsoo Aug 26, 2026
57e96c9
Document getOrGenerateOperationId never returns null or blank
Picazsoo Aug 26, 2026
87fec9e
test(spring): compile-verify extra-annotation features in existing sa…
Picazsoo Aug 26, 2026
704d4eb
fix(java-spring): correct spacing around request-body extra annotation
Picazsoo Aug 26, 2026
5f9764e
test(spring): exercise --inject-operation-vendor-extensions in the sa…
Picazsoo Aug 26, 2026
78406bc
test(kotlin-spring): side-load x-extra-imports alongside injected ann…
Picazsoo Aug 26, 2026
7953207
Add inject-vendor-extensions properties to Gradle and Maven plugins
Picazsoo Aug 26, 2026
8902338
docs(gradle): expand inject-vendor-extensions note with space example
Picazsoo Aug 26, 2026
8b93f41
docs: clarify inject-vendor-extensions as a generic string-typed mech…
Picazsoo Aug 26, 2026
e730b88
test(maven): assert injected annotation is scoped to addPet body param
Picazsoo Aug 26, 2026
8e9585d
Remove dead configOptions guards on maven inject-vendor-extensions pa…
Picazsoo Aug 26, 2026
578b006
Remove dead configOptions guards on maven *-name-mappings params
Picazsoo Aug 26, 2026
f61bddd
Merge branch 'master' into feature/add-extra-annotation-to-request-bo…
Picazsoo Sep 21, 2026
e3e2043
add whitespace change to trigger ci
Picazsoo Sep 21, 2026
8087ffa
Revert "add whitespace change to trigger ci"
Picazsoo Sep 21, 2026
54d5a43
fix: address code review findings on vendor-extension injection PR
Picazsoo Sep 21, 2026
825df3f
docs: use a parenthesized annotation example in inject-vendor-extensi…
Picazsoo Sep 21, 2026
6374f5b
docs: use realistic annotation example in inject-vendor-extensions CL…
Picazsoo Sep 21, 2026
6fe4d5b
docs: show quoted string example and double-quote escaping in inject-…
Picazsoo Sep 21, 2026
c77e4e0
feat: make inject-*-vendor-extensions CLI/Maven options more flexible
Picazsoo Sep 21, 2026
f08282e
Store injected vendor extensions as List<String> instead of a joined …
Picazsoo Sep 21, 2026
60dbcad
Fix CLI help example and restore config-file backward compatibility f…
Picazsoo Sep 21, 2026
ed71249
Fix second batch of vendor-extension review findings
Picazsoo Sep 21, 2026
b55fd9b
Fix vendor-extension injection issues: fromFile list aliasing, redund…
Picazsoo Sep 21, 2026
b36bfaf
Fix duplicate Size import in Kotlin spring extra-annotation fixture
Picazsoo Sep 21, 2026
12725da
Fix dotted parameter/property base names in vendor-extension injectio…
Picazsoo Sep 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion bin/configs/kotlin-spring-boot-delegate.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
generatorName: kotlin-spring
outputDir: samples/server/petstore/kotlin-springboot-delegate
library: spring-boot
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/petstore-with-extra-annotation.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-spring
injectOperationVendorExtensions:
placeOrder.x-request-body-extra-annotation: "@NonNull"
placeOrder.x-extra-imports: org.springframework.lang.NonNull
getOrderById.orderId.x-field-extra-annotation: "@NonNull"
getOrderById.orderId.x-extra-imports: org.springframework.lang.NonNull
additionalProperties:
generateJsonIncludeAnnotations: "true"
generateJsonSetterNullsAnnotations: "true"
Expand Down
7 changes: 6 additions & 1 deletion bin/configs/kotlin-spring-boot-reactive.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
generatorName: kotlin-spring
outputDir: samples/server/petstore/kotlin-springboot-reactive
library: spring-boot
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/petstore-with-extra-annotation.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-spring
injectOperationVendorExtensions:
placeOrder.x-request-body-extra-annotation: "@NonNull"
placeOrder.x-extra-imports: org.springframework.lang.NonNull
getOrderById.orderId.x-field-extra-annotation: "@NonNull"
getOrderById.orderId.x-extra-imports: org.springframework.lang.NonNull
additionalProperties:
generateJsonIncludeAnnotations: "true"
generateJsonSetterNullsAnnotations: "true"
Expand Down
5 changes: 4 additions & 1 deletion bin/configs/spring-boot-reactive.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
generatorName: spring
outputDir: samples/server/petstore/springboot-reactive
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing-extra-annotation.yaml
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
injectOperationVendorExtensions:
placeOrder.x-request-body-extra-annotation: "@org.springframework.lang.NonNull"
getOrderById.order_id.x-field-extra-annotation: "@org.springframework.lang.NonNull"
additionalProperties:
generateJsonIncludeAnnotations: "true"
generateJsonSetterNullsAnnotations: "true"
Expand Down
5 changes: 4 additions & 1 deletion bin/configs/spring-boot-useoptional.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
generatorName: spring
outputDir: samples/server/petstore/springboot-useoptional
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing-extra-annotation.yaml
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
injectOperationVendorExtensions:
placeOrder.x-request-body-extra-annotation: "@org.springframework.lang.NonNull"
getOrderById.order_id.x-field-extra-annotation: "@org.springframework.lang.NonNull"
additionalProperties:
generateJsonIncludeAnnotations: "true"
generateJsonSetterNullsAnnotations: "true"
Expand Down
1 change: 1 addition & 0 deletions docs/generators/kotlin-spring.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|x-field-extra-annotation|Custom annotation(s) to be added to property; accepts a string or list of strings|FIELD, OPERATION_PARAMETER|null
|x-jackson-default-impl|Specifies the default implementation class name for Jackson @JsonTypeInfo(defaultImpl=...) on a oneOf interface schema (deduction-based or discriminator-based). Can be overridden per-schema by the `typeInfoDefaultImpls` generator option.|MODEL|null
|x-operation-extra-annotation|Custom annotation(s) to be added to operation; accepts a string or list of strings|OPERATION|null
|x-request-body-extra-annotation|Custom annotation(s) to be added to the request body parameter; accepts a string or list of strings. Declared on the operation because the request body typically `$ref`s a shared model (so the annotation cannot be placed next to the `$ref`); the value is rendered by being merged into the body parameter's `x-field-extra-annotation`|OPERATION|null
|x-extra-imports|Custom import(s) to add to the generated file that declares the annotated model, property, operation, or parameter (e.g. so custom annotations can be referenced by their short name); accepts a string or list of strings. Values are emitted verbatim (Kotlin alias imports supported) and only exact duplicates are removed|MODEL, FIELD, OPERATION, OPERATION_PARAMETER|null
|x-pattern-message|Add this property whenever you need to customize the invalidation error message for the regex pattern of a variable|FIELD, OPERATION_PARAMETER|null
|x-size-message|Add this property whenever you need to customize the invalidation error message for the size or length of a variable|FIELD, OPERATION_PARAMETER|null
Expand Down
1 change: 1 addition & 0 deletions docs/generators/spring.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|x-class-extra-annotation|Custom annotation(s) to be added to model; accepts a string or list of strings|MODEL|null
|x-field-extra-annotation|Custom annotation(s) to be added to property; accepts a string or list of strings|FIELD, OPERATION_PARAMETER|null
|x-operation-extra-annotation|Custom annotation(s) to be added to operation; accepts a string or list of strings|OPERATION|null
|x-request-body-extra-annotation|Custom annotation(s) to be added to the request body parameter; accepts a string or list of strings. Declared on the operation because the request body typically `$ref`s a shared model (so the annotation cannot be placed next to the `$ref`); the value is rendered by being merged into the body parameter's `x-field-extra-annotation`|OPERATION|null
|x-spring-paginated|Add `org.springframework.data.domain.Pageable` to controller method. Can be used to handle `page`, `size` and `sort` query parameters. If these query parameters are also specified in the operation spec, they will be removed from the controller method as their values can be obtained from the `Pageable` object. Applies when `library=spring-boot` or `library=spring-cloud`; ignored for other (client) libraries.|OPERATION|false
|x-version-param|Marker property that tells that this parameter would be used for endpoint versioning. Applicable for headers & query params. true/false|OPERATION_PARAMETER|null
|x-pattern-message|Add this property whenever you need to customize the invalidation error message for the regex pattern of a variable|FIELD, OPERATION_PARAMETER|null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,50 @@ public class Generate extends OpenApiGeneratorCommand {
description = "injects vendor extensions into model classes or their properties."
+ " Class-level format: ModelName.x-extension-name=value."
+ " Property-level format: ModelName.propertyBaseName.x-extension-name=value."
+ " You can also have multiple occurrences of this option.")
+ " Values are strings, applied at render time, and overwrite existing values."
+ " Each occurrence of this option is exactly one key=value pair; everything after"
+ " the first '=' (including any commas, e.g. for @Size(min = 1, max = 100)) is"
+ " taken literally as the value, so annotation arguments do not need escaping."
+ " For the extra-annotation extensions, separate multiple annotations rendered on"
+ " the same line within a single value with spaces (e.g."
+ " 'ModelName.x-class-extra-annotation=@JsonProperty(value = \"example\") @Deprecated'),"
+ " or repeat this option with the same key to add another list entry (e.g. run it once"
+ " with 'ModelName.x-class-extra-annotation=@Foo' and again with"
+ " 'ModelName.x-class-extra-annotation=@Bar'); templates that loop over the extension"
+ " (such as class- and property-level extra-annotations) render each repeated"
+ " occurrence on its own line, in the order given."
+ " Quote the whole key=value pair when the value contains spaces (e.g."
+ " \"ModelName.x-class-extra-annotation=@Foo(\\\"some string with spaces\\\")\"),"
+ " and if your shell requires double-quoting the whole argument instead, escape"
+ " embedded double quotes (e.g. \\\")."
+ " You can have multiple occurrences of this option, one per injection target.")
private List<String> injectModelVendorExtensions = new ArrayList<>();

@Option(
name = {"--inject-operation-vendor-extensions"},
title = "inject operation vendor extensions",
description = "injects vendor extensions into operations or their parameters."
+ " Operation-level format: operationId.x-extension-name=value."
+ " Parameter-level format: operationId.paramBaseName.x-extension-name=value."
+ " Values are strings, applied at render time, and overwrite existing values."
+ " Each occurrence of this option is exactly one key=value pair; everything after"
+ " the first '=' (including any commas, e.g. for @Size(min = 1, max = 100)) is"
+ " taken literally as the value, so annotation arguments do not need escaping."
+ " For the extra-annotation extensions, separate multiple annotations rendered on"
+ " the same line within a single value with spaces (e.g."
+ " 'operationId.x-operation-extra-annotation=@JsonProperty(value = \"example\") @Deprecated'),"
+ " or repeat this option with the same key to add another list entry (e.g. run it once"
+ " with 'operationId.x-operation-extra-annotation=@Foo' and again with"
+ " 'operationId.x-operation-extra-annotation=@Bar'); templates that loop over the"
+ " extension (such as operation-level extra-annotations) render each repeated"
+ " occurrence on its own line, in the order given."
+ " Quote the whole key=value pair when the value contains spaces (e.g."
+ " \"operationId.x-operation-extra-annotation=@Foo(\\\"some string with spaces\\\")\"),"
+ " and if your shell requires double-quoting the whole argument instead, escape"
+ " embedded double quotes (e.g. \\\")."
+ " You can have multiple occurrences of this option, one per injection target.")
private List<String> injectOperationVendorExtensions = new ArrayList<>();

@Option(
name = {"--openapi-normalizer"},
title = "OpenAPI normalizer rules",
Expand Down Expand Up @@ -606,6 +647,7 @@ public void execute() {
applyEnumNameMappingsKvpList(enumNameMappings, configurator);
applyOperationIdNameMappingsKvpList(operationIdNameMappings, configurator);
applyInjectModelVendorExtensionsKvpList(injectModelVendorExtensions, configurator);
applyInjectOperationVendorExtensionsKvpList(injectOperationVendorExtensions, configurator);
applyOpenapiNormalizerKvpList(openapiNormalizer, configurator);
applyTypeMappingsKvpList(typeMappings, configurator);
applyAdditionalPropertiesKvpList(additionalProperties, configurator);
Expand Down
Loading
Loading