-
Notifications
You must be signed in to change notification settings - Fork 2
/
pom.xml
171 lines (146 loc) · 9.56 KB
/
pom.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sigpwned</groupId>
<artifactId>openapi-generator-maven-plugin-template-customization-example</artifactId>
<version>0.0.0-SNAPSHOT</version>
<name>openapi-generator-maven-plugin-template-customization-example</name>
<inceptionYear>2022</inceptionYear>
<description>An example Maven project that uses the OpenAPI Generator Maven plugin with template customization to generate an API model and server.</description>
<url>https://github.com/sigpwned/openapi-generator-maven-plugin-template-customization-example</url>
<packaging>jar</packaging>
<scm>
<connection>scm:git:ssh://git@github.com/sigpwned/openapi-generator-maven-plugin-template-customization-example.git</connection>
<developerConnection>scm:git:ssh://git@github.com/sigpwned/openapi-generator-maven-plugin-template-customization-example.git</developerConnection>
<url>https://github.com/sigpwned/openapi-generator-maven-plugin-template-customization-example/tree/main</url>
<tag>HEAD</tag>
</scm>
<developers>
<developer>
<name>Andy Boothe</name>
<email>andy.boothe@gmail.com</email>
</developer>
</developers>
<issueManagement>
<system>GitHub</system>
<url>https://github.com/sigpwned/openapi-generator-maven-plugin-template-customization-example</url>
</issueManagement>
<properties>
<java.version>11</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<openapi.source.directory>${project.build.directory}/generated-sources/openapi</openapi.source.directory>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<release>${java.version}</release>
</configuration>
</plugin>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>5.4.0</version>
<executions>
<execution>
<id>generate</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<!-- This section includes the "global" configuration options, so called because they apply to all generators. Users generally don't need to care about this detail, except to make sure their configuration information lands in the correct place - <configuration> vs <configOptions>. -->
<!-- https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator-maven-plugin -->
<!-- The OpenAPI spec is in a file in this repository called "openapi.yml". It can also be a hyperlink. -->
<inputSpec>${project.basedir}/openapi.yml</inputSpec>
<!-- There are many generators available. We are using jaxrs-spec. -->
<generatorName>jaxrs-spec</generatorName>
<!-- APIs are service interfaces or implementations. -->
<generateApis>true</generateApis>
<!-- Models are DTOs, generally from the schemas portion of the spec. -->
<generateModels>true</generateModels>
<!-- In this example, we're not generating the POM, README, etc. Just the code, ma'am. -->
<generateSupportingFiles>false</generateSupportingFiles>
<!-- This is the default value, but be explicit so it's clear when we refer to the value elsewhere. -->
<output>${openapi.source.directory}</output>
<!-- We are showing off template customization today. The custom templates are stored here. -->
<templateDirectory>${project.basedir}/openapi/templates</templateDirectory>
<configOptions>
<!-- These are the "local" configuration options that apply only to this generator. -->
<!-- https://openapi-generator.tech/docs/generators/jaxrs-spec -->
<!-- These are the packages we want our APIs and Models generated in, respectively. -->
<apiPackage>com.sigpwned.greeting.spi.service</apiPackage>
<modelPackage>com.sigpwned.greeting.spi.model</modelPackage>
<!-- I personally consider these to be best practices. However, they are up to you! -->
<dateLibrary>java8</dateLibrary>
<useSwaggerAnnotations>false</useSwaggerAnnotations>
<!-- These values are largely up to you, and depend on your goals and philosophy. This SSCCE should support all permutations of the below. -->
<!-- I prefer to have interface methods return model objects, not JAX-RS Response objects. I can still generate any response I want by throwing WebApplicationException classes. -->
<!-- If this is set to true, then all generated service methods will return javax.ws.rs.core.Response objects. -->
<!-- If this is set to false, then all generated service methods will return their respective model objects. -->
<returnResponse>false</returnResponse>
<!-- I prefer to generate interfaces, not implementation. This allows me to make sure that my client and server implementations are in sync. -->
<!-- If this is set to true, then service interfaces will be generated. -->
<!-- If this is set to false, then service implementations will be generated. -->
<interfaceOnly>true</interfaceOnly>
<!-- This is a useful feature for web frameworks that support the JAX-RS 2.1 feature of implementing asynchronous processing by returning CompletionStage instances. In all cases, generated service methods return either Response or a model object, depending on the above configuration. This configuration option affects all methods. Users cannot choose to make individual methods synchronous versus asynchronous. -->
<!-- If this is set to true, then all generated service method return types will be changed from T to CompletionStage<T>. -->
<!-- If this is set to false, then all generate service method return types will be unchanged. -->
<supportAsync>false</supportAsync>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>add-source</id>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<!-- Add the generated source to the project so it gets compiled -->
<source>${openapi.source.directory}/src/gen/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<!-- A convenient way to co-manage these dependency versions is to use a BOM, e.g. the dropwizard-dependencies BOM. -->
<!-- This provides the model JSON serialization annotations, e.g. @JsonProperty -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.3</version>
</dependency>
<!-- This provides the model @Generated annotation -->
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>1.3.5</version>
</dependency>
<!-- This provides the model bean validation annotations, e.g. @Valid -->
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>2.0.2</version>
</dependency>
<!-- This provides the service REST annotations, e.g. @POST -->
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<version>2.1.6</version>
</dependency>
</dependencies>
</project>