File tree Expand file tree Collapse file tree 5 files changed +316
-5
lines changed
deployment/src/main/java/io/quarkiverse/openapi/generator/deployment
integration-tests/config-key/src
test/java/io/quarkiverse/openapi/generator/configkey Expand file tree Collapse file tree 5 files changed +316
-5
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ public final class OpenApiConfigValidator {
1919 private static final Logger LOGGER = LoggerFactory .getLogger (OpenApiConfigValidator .class );
2020
2121 static final Pattern CONFIG_PATTERN = Pattern .compile (
22- "quarkus\\ .openapi-generator\\ .codegen\\ .(spec.(?<specId>\\ w*)\\ .)?(?<configName>[A-Za-z0-9_\\ -]*)\\ .?(?<configMap>.+)?" );
22+ "quarkus\\ .openapi-generator\\ .codegen\\ .(spec.(?<specId>[ \\ w\\ -] *)\\ .)?(?<configName>[A-Za-z0-9_\\ -]*)\\ .?(?<configMap>.+)?" );
2323
2424 private OpenApiConfigValidator () {
2525 }
Original file line number Diff line number Diff line change 2121import org .openapitools .codegen .DefaultGenerator ;
2222import org .openapitools .codegen .config .GlobalSettings ;
2323
24- import io .smallrye .config .common .utils .StringUtil ;
25-
2624/**
2725 * Wrapper for the OpenAPIGen tool.
2826 * This is the same as calling the Maven plugin or the CLI.
@@ -356,11 +354,15 @@ private void consolidatePackageNames() {
356354
357355 public void withConfigKey (final String config ) {
358356 if (config != null && !config .isBlank ()) {
359- this .configurator .addAdditionalProperty ("configKey" , StringUtil . replaceNonAlphanumericByUnderscores (config ));
357+ this .configurator .addAdditionalProperty ("configKey" , transformToSafeConfigKey (config ));
360358 }
361359 }
362360
363361 public void withAdditionalPropertiesAsAttribute (final Boolean enable ) {
364362 this .configurator .addAdditionalProperty ("additionalPropertiesAsAttribute" , Optional .ofNullable (enable ).orElse (FALSE ));
365363 }
364+
365+ public static String transformToSafeConfigKey (String input ) {
366+ return input .replaceAll ("[^a-zA-Z0-9\\ -_]" , "_" );
367+ }
366368}
Original file line number Diff line number Diff line change 1+ ---
2+ openapi : 3.0.3
3+ info :
4+ title : greeting-flow API
5+ version : " 1.0"
6+ paths :
7+ / :
8+ post :
9+ requestBody :
10+ content :
11+ ' */* ' :
12+ schema :
13+ $ref : ' #/components/schemas/CloudEvent'
14+ responses :
15+ " 200 " :
16+ description : OK
17+ content :
18+ application/json :
19+ schema :
20+ $ref : ' #/components/schemas/Response'
21+ /hello :
22+ get :
23+ tags :
24+ - Reactive Greeting Resource
25+ operationId : hello
26+ responses :
27+ " 200 " :
28+ description : OK
29+ content :
30+ text/plain :
31+ schema :
32+ type : string
33+ /messaging/topics :
34+ get :
35+ tags :
36+ - Quarkus Topics Information Resource
37+ responses :
38+ " 200 " :
39+ description : OK
40+ components :
41+ schemas :
42+ CloudEvent :
43+ type : object
44+ properties :
45+ specVersion :
46+ $ref : ' #/components/schemas/SpecVersion'
47+ id :
48+ type : string
49+ type :
50+ type : string
51+ source :
52+ format : uri
53+ type : string
54+ dataContentType :
55+ type : string
56+ dataSchema :
57+ format : uri
58+ type : string
59+ subject :
60+ type : string
61+ time :
62+ format : date-time
63+ type : string
64+ attributeNames :
65+ uniqueItems : true
66+ type : array
67+ items :
68+ type : string
69+ extensionNames :
70+ uniqueItems : true
71+ type : array
72+ items :
73+ type : string
74+ data :
75+ $ref : ' #/components/schemas/CloudEventData'
76+ CloudEventData :
77+ type : object
78+ EntityTag :
79+ type : object
80+ properties :
81+ value :
82+ type : string
83+ weak :
84+ type : boolean
85+ Family :
86+ enum :
87+ - INFORMATIONAL
88+ - SUCCESSFUL
89+ - REDIRECTION
90+ - CLIENT_ERROR
91+ - SERVER_ERROR
92+ - OTHER
93+ type : string
94+ Link :
95+ type : object
96+ properties :
97+ uri :
98+ format : uri
99+ type : string
100+ uriBuilder :
101+ $ref : ' #/components/schemas/UriBuilder'
102+ rel :
103+ type : string
104+ rels :
105+ type : array
106+ items :
107+ type : string
108+ title :
109+ type : string
110+ type :
111+ type : string
112+ params :
113+ type : object
114+ additionalProperties :
115+ type : string
116+ Locale :
117+ type : object
118+ properties :
119+ language :
120+ type : string
121+ script :
122+ type : string
123+ country :
124+ type : string
125+ variant :
126+ type : string
127+ extensionKeys :
128+ uniqueItems : true
129+ type : array
130+ items :
131+ format : byte
132+ type : string
133+ unicodeLocaleAttributes :
134+ uniqueItems : true
135+ type : array
136+ items :
137+ type : string
138+ unicodeLocaleKeys :
139+ uniqueItems : true
140+ type : array
141+ items :
142+ type : string
143+ iSO3Language :
144+ type : string
145+ iSO3Country :
146+ type : string
147+ displayLanguage :
148+ type : string
149+ displayScript :
150+ type : string
151+ displayCountry :
152+ type : string
153+ displayVariant :
154+ type : string
155+ displayName :
156+ type : string
157+ MediaType :
158+ type : object
159+ properties :
160+ type :
161+ type : string
162+ subtype :
163+ type : string
164+ parameters :
165+ type : object
166+ additionalProperties :
167+ type : string
168+ wildcardType :
169+ type : boolean
170+ wildcardSubtype :
171+ type : boolean
172+ MultivaluedMapStringObject :
173+ type : object
174+ additionalProperties :
175+ type : array
176+ items :
177+ type : object
178+ MultivaluedMapStringString :
179+ type : object
180+ additionalProperties :
181+ type : array
182+ items :
183+ type : string
184+ NewCookie :
185+ type : object
186+ properties :
187+ name :
188+ type : string
189+ value :
190+ type : string
191+ version :
192+ format : int32
193+ type : integer
194+ path :
195+ type : string
196+ domain :
197+ type : string
198+ comment :
199+ type : string
200+ maxAge :
201+ format : int32
202+ type : integer
203+ expiry :
204+ format : date
205+ type : string
206+ secure :
207+ type : boolean
208+ httpOnly :
209+ type : boolean
210+ Response :
211+ type : object
212+ properties :
213+ status :
214+ format : int32
215+ type : integer
216+ statusInfo :
217+ $ref : ' #/components/schemas/StatusType'
218+ entity :
219+ type : object
220+ mediaType :
221+ $ref : ' #/components/schemas/MediaType'
222+ language :
223+ $ref : ' #/components/schemas/Locale'
224+ length :
225+ format : int32
226+ type : integer
227+ allowedMethods :
228+ uniqueItems : true
229+ type : array
230+ items :
231+ type : string
232+ cookies :
233+ type : object
234+ additionalProperties :
235+ $ref : ' #/components/schemas/NewCookie'
236+ entityTag :
237+ $ref : ' #/components/schemas/EntityTag'
238+ date :
239+ format : date
240+ type : string
241+ lastModified :
242+ format : date
243+ type : string
244+ location :
245+ format : uri
246+ type : string
247+ links :
248+ uniqueItems : true
249+ type : array
250+ items :
251+ $ref : ' #/components/schemas/Link'
252+ metadata :
253+ $ref : ' #/components/schemas/MultivaluedMapStringObject'
254+ headers :
255+ $ref : ' #/components/schemas/MultivaluedMapStringObject'
256+ stringHeaders :
257+ $ref : ' #/components/schemas/MultivaluedMapStringString'
258+ SpecVersion :
259+ enum :
260+ - V03
261+ - V1
262+ type : string
263+ StatusType :
264+ type : object
265+ properties :
266+ statusCode :
267+ format : int32
268+ type : integer
269+ family :
270+ $ref : ' #/components/schemas/Family'
271+ reasonPhrase :
272+ type : string
273+ UriBuilder :
274+ type : object
Original file line number Diff line number Diff line change @@ -15,4 +15,8 @@ quarkus.openapi-generator.codegen.spec.empty_config_key_yaml.config-key=
1515quarkus.openapi-generator.codegen.spec.empty_config_key_yaml.additional-api-type-annotations =@io.quarkiverse.openapi.generator.configkey.CustomAnnotation
1616quarkus.rest-client.empty_config_key_yaml.url =http://localhost:8080
1717
18- quarkus.keycloak.devservices.enabled =false
18+ quarkus.keycloak.devservices.enabled =false
19+
20+ # config-key with `-`
21+ quarkus.openapi-generator.codegen.spec.config_key_with_dash_yaml.config-key =my-api
22+ quarkus.rest-client.my-api.url =http://localhost:8080
Original file line number Diff line number Diff line change 1+ package io .quarkiverse .openapi .generator .configkey ;
2+
3+ import static org .assertj .core .api .Assertions .assertThat ;
4+
5+ import jakarta .inject .Inject ;
6+
7+ import org .eclipse .microprofile .rest .client .inject .RegisterRestClient ;
8+ import org .eclipse .microprofile .rest .client .inject .RestClient ;
9+ import org .junit .jupiter .api .Test ;
10+ import org .openapi .quarkus .config_key_with_dash_yaml .api .DefaultApi ;
11+
12+ import io .quarkus .test .junit .QuarkusTest ;
13+
14+ @ QuarkusTest
15+ class QuarkusConfigKeyWithDashOpenApiTest {
16+
17+ @ RestClient
18+ @ Inject
19+ DefaultApi defaultApi ;
20+
21+ @ Test
22+ void apiIsBeingGenerated () {
23+ assertThat (defaultApi ).isNotNull ();
24+ }
25+
26+ @ Test
27+ void config_key_should_have_dash () {
28+ assertThat (DefaultApi .class .getAnnotation (RegisterRestClient .class )).isNotNull ();
29+ assertThat (DefaultApi .class .getAnnotation (RegisterRestClient .class ).configKey ()).isEqualTo ("my-api" );
30+ }
31+ }
You can’t perform that action at this time.
0 commit comments