Skip to content

Commit 5873ef0

Browse files
committed
add annotation-targets documentation (#380)
1 parent 3781dbc commit 5873ef0

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

docs/modules/ROOT/pages/processor/configuration.adoc

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,47 @@ options:
503503
layout: standard
504504
----
505505

506+
== annotation-targets: ([.badge .badge-since]+new with 2025.6+)
507+
508+
This section is used to configure the *allowed* targets of an annotation. This is like `java.lang.annotation.Target` which is used to define at which places an annotation can be used. On a type, field, method or property etc.
509+
510+
The new section `annotation-targets` is a map from annotation name to set of allowed targets.
511+
512+
The list of allowed targets is currently: `'type'`, `'field'`, `'method'` and `'parameter'`.
513+
514+
[source,yaml,subs=attributes+]
515+
----
516+
openapi-processor-mapping: {var-mapping-version}
517+
options:
518+
package-name: pkg
519+
520+
map:
521+
types:
522+
- type: Foo @ lombok.Builder
523+
524+
annotation-targets:
525+
# possible entries 'type', 'field', 'method' & 'parameter'
526+
lombok.Builder: ['type', 'method']
527+
----
528+
529+
Internally, the processor has a default list of "known" annotations. It is not necessary to add those manually unless to overide it.
530+
531+
The purpose of this configuration is to help the processor placing annotations. The processor may put an annotation at a place where it is not allowed. For example, it should not put `lombok.Builder` on method parameters or an annotation is not allowed on a mapped type.
532+
533+
534+
[NOTE]
535+
====
536+
Why doesn't openapi-processor directly check the allowed targets of `java.lang.annotation.Target` ?
537+
538+
It can't check the allowed targets directly, because the annotations are usually not available on teh processors classpath. They are just strings from the mapping.
539+
====
540+
541+
=== known annotations
542+
543+
The default list is quite short at the moment but can grow:
544+
545+
* `lombok.Builder: ['type', 'method']`
546+
506547
== logging:
507548

508549
This section contains keys for logging mapping lookups. It may be useful to locate mappings that should be used but are not.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
:var-mapping-version: v15
1+
:var-mapping-version: v16
22
:var-openapi-version: 3.1.0

0 commit comments

Comments
 (0)