Skip to content

Commit 7cbca17

Browse files
committed
Update Petstore fixtures to use idiomatic naming
1 parent 8f51c49 commit 7cbca17

File tree

8 files changed

+146
-135
lines changed

8 files changed

+146
-135
lines changed

Tests/OpenAPIGeneratorReferenceTests/FileBasedReferenceTests.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,21 @@ struct TestConfig: Encodable {
2121
var mode: GeneratorMode
2222
var additionalImports: [String]?
2323
var featureFlags: FeatureFlags?
24+
var namingStrategy: NamingStrategy
25+
var nameOverrides: [String: String]
2426
var referenceOutputDirectory: String
2527
}
2628

2729
extension TestConfig {
2830
var asConfig: Config {
29-
.init(mode: mode, access: .public, additionalImports: additionalImports ?? [], featureFlags: featureFlags ?? [])
31+
.init(
32+
mode: mode,
33+
access: .public,
34+
additionalImports: additionalImports ?? [],
35+
namingStrategy: namingStrategy,
36+
nameOverrides: nameOverrides,
37+
featureFlags: featureFlags ?? []
38+
)
3039
}
3140
}
3241

@@ -127,6 +136,8 @@ final class FileBasedReferenceTests: XCTestCase {
127136
mode: mode,
128137
additionalImports: [],
129138
featureFlags: featureFlags,
139+
namingStrategy: .optimistic,
140+
nameOverrides: [:],
130141
referenceOutputDirectory: "ReferenceSources/\(project.fixtureCodeDirectoryName)"
131142
),
132143
ignoredDiagnosticMessages: ignoredDiagnosticMessages

Tests/OpenAPIGeneratorReferenceTests/Resources/ReferenceSources/Petstore/Client.swift

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ public struct Client: APIProtocol {
4747
///
4848
/// - Remark: HTTP `GET /pets`.
4949
/// - Remark: Generated from `#/paths//pets/get(listPets)`.
50-
public func listPets(_ input: Operations.listPets.Input) async throws -> Operations.listPets.Output {
50+
public func listPets(_ input: Operations.ListPets.Input) async throws -> Operations.ListPets.Output {
5151
try await client.send(
5252
input: input,
53-
forOperation: Operations.listPets.id,
53+
forOperation: Operations.ListPets.id,
5454
serializer: { input in
5555
let path = try converter.renderedPath(
5656
template: "/pets",
@@ -103,7 +103,7 @@ public struct Client: APIProtocol {
103103
deserializer: { response, responseBody in
104104
switch response.status.code {
105105
case 200:
106-
let headers: Operations.listPets.Output.Ok.Headers = .init(
106+
let headers: Operations.ListPets.Output.Ok.Headers = .init(
107107
My_hyphen_Response_hyphen_UUID: try converter.getRequiredHeaderFieldAsURI(
108108
in: response.headerFields,
109109
name: "My-Response-UUID",
@@ -116,7 +116,7 @@ public struct Client: APIProtocol {
116116
)
117117
)
118118
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
119-
let body: Operations.listPets.Output.Ok.Body
119+
let body: Operations.ListPets.Output.Ok.Body
120120
let chosenContentType = try converter.bestContentType(
121121
received: contentType,
122122
options: [
@@ -141,7 +141,7 @@ public struct Client: APIProtocol {
141141
))
142142
default:
143143
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
144-
let body: Operations.listPets.Output.Default.Body
144+
let body: Operations.ListPets.Output.Default.Body
145145
let chosenContentType = try converter.bestContentType(
146146
received: contentType,
147147
options: [
@@ -172,10 +172,10 @@ public struct Client: APIProtocol {
172172
///
173173
/// - Remark: HTTP `POST /pets`.
174174
/// - Remark: Generated from `#/paths//pets/post(createPet)`.
175-
public func createPet(_ input: Operations.createPet.Input) async throws -> Operations.createPet.Output {
175+
public func createPet(_ input: Operations.CreatePet.Input) async throws -> Operations.CreatePet.Output {
176176
try await client.send(
177177
input: input,
178-
forOperation: Operations.createPet.id,
178+
forOperation: Operations.CreatePet.id,
179179
serializer: { input in
180180
let path = try converter.renderedPath(
181181
template: "/pets",
@@ -209,13 +209,13 @@ public struct Client: APIProtocol {
209209
deserializer: { response, responseBody in
210210
switch response.status.code {
211211
case 201:
212-
let headers: Operations.createPet.Output.Created.Headers = .init(X_hyphen_Extra_hyphen_Arguments: try converter.getOptionalHeaderFieldAsJSON(
212+
let headers: Operations.CreatePet.Output.Created.Headers = .init(X_hyphen_Extra_hyphen_Arguments: try converter.getOptionalHeaderFieldAsJSON(
213213
in: response.headerFields,
214214
name: "X-Extra-Arguments",
215215
as: Components.Schemas.CodeError.self
216216
))
217217
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
218-
let body: Operations.createPet.Output.Created.Body
218+
let body: Operations.CreatePet.Output.Created.Body
219219
let chosenContentType = try converter.bestContentType(
220220
received: contentType,
221221
options: [
@@ -287,10 +287,10 @@ public struct Client: APIProtocol {
287287
///
288288
/// - Remark: HTTP `POST /pets/create`.
289289
/// - Remark: Generated from `#/paths//pets/create/post(createPetWithForm)`.
290-
public func createPetWithForm(_ input: Operations.createPetWithForm.Input) async throws -> Operations.createPetWithForm.Output {
290+
public func createPetWithForm(_ input: Operations.CreatePetWithForm.Input) async throws -> Operations.CreatePetWithForm.Output {
291291
try await client.send(
292292
input: input,
293-
forOperation: Operations.createPetWithForm.id,
293+
forOperation: Operations.CreatePetWithForm.id,
294294
serializer: { input in
295295
let path = try converter.renderedPath(
296296
template: "/pets/create",
@@ -330,10 +330,10 @@ public struct Client: APIProtocol {
330330
}
331331
/// - Remark: HTTP `GET /pets/stats`.
332332
/// - Remark: Generated from `#/paths//pets/stats/get(getStats)`.
333-
public func getStats(_ input: Operations.getStats.Input) async throws -> Operations.getStats.Output {
333+
public func getStats(_ input: Operations.GetStats.Input) async throws -> Operations.GetStats.Output {
334334
try await client.send(
335335
input: input,
336-
forOperation: Operations.getStats.id,
336+
forOperation: Operations.GetStats.id,
337337
serializer: { input in
338338
let path = try converter.renderedPath(
339339
template: "/pets/stats",
@@ -354,7 +354,7 @@ public struct Client: APIProtocol {
354354
switch response.status.code {
355355
case 200:
356356
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
357-
let body: Operations.getStats.Output.Ok.Body
357+
let body: Operations.GetStats.Output.Ok.Body
358358
let chosenContentType = try converter.bestContentType(
359359
received: contentType,
360360
options: [
@@ -406,10 +406,10 @@ public struct Client: APIProtocol {
406406
}
407407
/// - Remark: HTTP `POST /pets/stats`.
408408
/// - Remark: Generated from `#/paths//pets/stats/post(postStats)`.
409-
public func postStats(_ input: Operations.postStats.Input) async throws -> Operations.postStats.Output {
409+
public func postStats(_ input: Operations.PostStats.Input) async throws -> Operations.PostStats.Output {
410410
try await client.send(
411411
input: input,
412-
forOperation: Operations.postStats.id,
412+
forOperation: Operations.PostStats.id,
413413
serializer: { input in
414414
let path = try converter.renderedPath(
415415
template: "/pets/stats",
@@ -461,10 +461,10 @@ public struct Client: APIProtocol {
461461
}
462462
/// - Remark: HTTP `POST /probe/`.
463463
/// - Remark: Generated from `#/paths//probe//post(probe)`.
464-
public func probe(_ input: Operations.probe.Input) async throws -> Operations.probe.Output {
464+
public func probe(_ input: Operations.Probe.Input) async throws -> Operations.Probe.Output {
465465
try await client.send(
466466
input: input,
467-
forOperation: Operations.probe.id,
467+
forOperation: Operations.Probe.id,
468468
serializer: { input in
469469
let path = try converter.renderedPath(
470470
template: "/probe/",

Tests/OpenAPIGeneratorReferenceTests/Resources/ReferenceSources/Petstore/Server.swift

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,12 @@ fileprivate extension UniversalServer where APIHandler: APIProtocol {
160160
request: request,
161161
requestBody: body,
162162
metadata: metadata,
163-
forOperation: Operations.listPets.id,
163+
forOperation: Operations.ListPets.id,
164164
using: {
165165
APIHandler.listPets($0)
166166
},
167167
deserializer: { request, requestBody, metadata in
168-
let query: Operations.listPets.Input.Query = .init(
168+
let query: Operations.ListPets.Input.Query = .init(
169169
limit: try converter.getOptionalQueryItemAsURI(
170170
in: request.soar_query,
171171
style: .form,
@@ -178,14 +178,14 @@ fileprivate extension UniversalServer where APIHandler: APIProtocol {
178178
style: .form,
179179
explode: true,
180180
name: "habitat",
181-
as: Operations.listPets.Input.Query.habitatPayload.self
181+
as: Operations.ListPets.Input.Query.habitatPayload.self
182182
),
183183
feeds: try converter.getOptionalQueryItemAsURI(
184184
in: request.soar_query,
185185
style: .form,
186186
explode: true,
187187
name: "feeds",
188-
as: Operations.listPets.Input.Query.feedsPayload.self
188+
as: Operations.ListPets.Input.Query.feedsPayload.self
189189
),
190190
since: try converter.getOptionalQueryItemAsURI(
191191
in: request.soar_query,
@@ -195,15 +195,15 @@ fileprivate extension UniversalServer where APIHandler: APIProtocol {
195195
as: Components.Parameters.query_period_born_hyphen_since.self
196196
)
197197
)
198-
let headers: Operations.listPets.Input.Headers = .init(
198+
let headers: Operations.ListPets.Input.Headers = .init(
199199
My_hyphen_Request_hyphen_UUID: try converter.getOptionalHeaderFieldAsURI(
200200
in: request.headerFields,
201201
name: "My-Request-UUID",
202202
as: Swift.String.self
203203
),
204204
accept: try converter.extractAcceptHeaderIfPresent(in: request.headerFields)
205205
)
206-
return Operations.listPets.Input(
206+
return Operations.ListPets.Input(
207207
query: query,
208208
headers: headers
209209
)
@@ -273,12 +273,12 @@ fileprivate extension UniversalServer where APIHandler: APIProtocol {
273273
request: request,
274274
requestBody: body,
275275
metadata: metadata,
276-
forOperation: Operations.createPet.id,
276+
forOperation: Operations.CreatePet.id,
277277
using: {
278278
APIHandler.createPet($0)
279279
},
280280
deserializer: { request, requestBody, metadata in
281-
let headers: Operations.createPet.Input.Headers = .init(
281+
let headers: Operations.CreatePet.Input.Headers = .init(
282282
X_hyphen_Extra_hyphen_Arguments: try converter.getOptionalHeaderFieldAsJSON(
283283
in: request.headerFields,
284284
name: "X-Extra-Arguments",
@@ -287,7 +287,7 @@ fileprivate extension UniversalServer where APIHandler: APIProtocol {
287287
accept: try converter.extractAcceptHeaderIfPresent(in: request.headerFields)
288288
)
289289
let contentType = converter.extractContentTypeIfPresent(in: request.headerFields)
290-
let body: Operations.createPet.Input.Body
290+
let body: Operations.CreatePet.Input.Body
291291
let chosenContentType = try converter.bestContentType(
292292
received: contentType,
293293
options: [
@@ -306,7 +306,7 @@ fileprivate extension UniversalServer where APIHandler: APIProtocol {
306306
default:
307307
preconditionFailure("bestContentType chose an invalid content type.")
308308
}
309-
return Operations.createPet.Input(
309+
return Operations.CreatePet.Input(
310310
headers: headers,
311311
body: body
312312
)
@@ -378,13 +378,13 @@ fileprivate extension UniversalServer where APIHandler: APIProtocol {
378378
request: request,
379379
requestBody: body,
380380
metadata: metadata,
381-
forOperation: Operations.createPetWithForm.id,
381+
forOperation: Operations.CreatePetWithForm.id,
382382
using: {
383383
APIHandler.createPetWithForm($0)
384384
},
385385
deserializer: { request, requestBody, metadata in
386386
let contentType = converter.extractContentTypeIfPresent(in: request.headerFields)
387-
let body: Operations.createPetWithForm.Input.Body
387+
let body: Operations.CreatePetWithForm.Input.Body
388388
let chosenContentType = try converter.bestContentType(
389389
received: contentType,
390390
options: [
@@ -403,7 +403,7 @@ fileprivate extension UniversalServer where APIHandler: APIProtocol {
403403
default:
404404
preconditionFailure("bestContentType chose an invalid content type.")
405405
}
406-
return Operations.createPetWithForm.Input(body: body)
406+
return Operations.CreatePetWithForm.Input(body: body)
407407
},
408408
serializer: { output, request in
409409
switch output {
@@ -429,13 +429,13 @@ fileprivate extension UniversalServer where APIHandler: APIProtocol {
429429
request: request,
430430
requestBody: body,
431431
metadata: metadata,
432-
forOperation: Operations.getStats.id,
432+
forOperation: Operations.GetStats.id,
433433
using: {
434434
APIHandler.getStats($0)
435435
},
436436
deserializer: { request, requestBody, metadata in
437-
let headers: Operations.getStats.Input.Headers = .init(accept: try converter.extractAcceptHeaderIfPresent(in: request.headerFields))
438-
return Operations.getStats.Input(headers: headers)
437+
let headers: Operations.GetStats.Input.Headers = .init(accept: try converter.extractAcceptHeaderIfPresent(in: request.headerFields))
438+
return Operations.GetStats.Input(headers: headers)
439439
},
440440
serializer: { output, request in
441441
switch output {
@@ -494,13 +494,13 @@ fileprivate extension UniversalServer where APIHandler: APIProtocol {
494494
request: request,
495495
requestBody: body,
496496
metadata: metadata,
497-
forOperation: Operations.postStats.id,
497+
forOperation: Operations.PostStats.id,
498498
using: {
499499
APIHandler.postStats($0)
500500
},
501501
deserializer: { request, requestBody, metadata in
502502
let contentType = converter.extractContentTypeIfPresent(in: request.headerFields)
503-
let body: Operations.postStats.Input.Body
503+
let body: Operations.PostStats.Input.Body
504504
let chosenContentType = try converter.bestContentType(
505505
received: contentType,
506506
options: [
@@ -537,7 +537,7 @@ fileprivate extension UniversalServer where APIHandler: APIProtocol {
537537
default:
538538
preconditionFailure("bestContentType chose an invalid content type.")
539539
}
540-
return Operations.postStats.Input(body: body)
540+
return Operations.PostStats.Input(body: body)
541541
},
542542
serializer: { output, request in
543543
switch output {
@@ -563,12 +563,12 @@ fileprivate extension UniversalServer where APIHandler: APIProtocol {
563563
request: request,
564564
requestBody: body,
565565
metadata: metadata,
566-
forOperation: Operations.probe.id,
566+
forOperation: Operations.Probe.id,
567567
using: {
568568
APIHandler.probe($0)
569569
},
570570
deserializer: { request, requestBody, metadata in
571-
return Operations.probe.Input()
571+
return Operations.Probe.Input()
572572
},
573573
serializer: { output, request in
574574
switch output {

0 commit comments

Comments
 (0)