You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apicurio Codegen Extensions use https://swagger.io/docs/specification/v3_0/openapi-extensions/[OpenAPI specification extensions] to allow customization of the generated source code based on your API contract.
23
+
Apicurio Codegen Extensions use https://spec.openapis.org/oas/v3.0.3.html#specification-extensions/[OpenAPI specification extensions] to allow customization of the generated source code based on your API contract.
24
+
25
+
=== `x-codegen`
26
+
27
+
The `x-codegen` extension can be defined at the root level of the OpenAPI document.
28
+
29
+
It is applied globally and allows you to customize the generated bean classes by:
30
+
- Adding annotations to all generated beans.
31
+
- Controlling date/time formatting.
32
+
- Configuring the application context root.
33
+
34
+
=== `x-codegen.bean-annotations`
35
+
36
+
Adding annotations to generated bean classes:
37
+
38
+
[source,json]
39
+
----
40
+
{
41
+
"x-codegen": {
42
+
"bean-annotations": [
43
+
"@lombok.ToString", // (1)
44
+
{
45
+
"annotation": "@lombok.EqualsAndHashCode", // (2)
46
+
"excludeEnums": true
47
+
}
48
+
]
49
+
}
50
+
}
51
+
----
52
+
53
+
1. Adds the `@lombok.ToString` annotation to all generated bean classes.
54
+
2. Adds the `@lombok.EqualsAndHashCode` annotation to all generated bean classes, except for Java enums (when excludeEnums is set to `true`).
55
+
56
+
=== `x-codegen.contextRoot`
57
+
58
+
Additionally, you can configure the application context root using the `x-codegen.contextRoot` property.
59
+
60
+
This property defines a base path that will be automatically prefixed to all generated JAX-RS resource classes.
61
+
62
+
For example, if you set the context root to `/apis/studio/v1`, all generated resource paths will include this prefix.
63
+
64
+
[source,json]
65
+
----
66
+
{
67
+
"x-codegen": {
68
+
"contextRoot": "/apis/studio/v1",
69
+
"bean-annotations": []
70
+
}
71
+
}
72
+
----
73
+
74
+
Corresponding JAX-RS code:
75
+
76
+
[source,java]
77
+
----
78
+
@Path("/apis/studio/v1/users")
79
+
public class UserResource {}
80
+
----
81
+
82
+
[NOTE]
83
+
84
+
You can use the xref:x-codegen-contextRoot[x-codegen-contextRoot] property to apply a context root prefix to a specific JAX-RS resource instead of using the global one.
85
+
86
+
=== `x-codegen.suppress-date-time-formatting`
87
+
88
+
By default, Apicurio Codegen generates properties of type `string` with the format `date-time` as shown below:
If you want to disable this behavior, you can use the `x-codegen.suppress-date-time-formatting` property to remove the `@JsonFormat` annotation from generated fields.
98
+
99
+
[source,json]
100
+
----
101
+
{
102
+
"x-codegen": {
103
+
"suppress-date-time-formatting": true
104
+
}
105
+
}
106
+
----
24
107
25
108
The following extensions modify the behavior of the code generation in specific parts of the OpenAPI document.
26
109
@@ -211,6 +294,7 @@ public Response deleteBeer(
211
294
);
212
295
----
213
296
297
+
[[x-codegen-contextRoot]]
214
298
=== x-codegen-contextRoot
215
299
216
300
The `x-codegen-contextRoot` extension allows you to define a base path (context root) that is prepended to all generated endpoint paths.
0 commit comments