Skip to content

Commit

Permalink
Update Petstore fixtures to use idiomatic naming
Browse files Browse the repository at this point in the history
  • Loading branch information
czechboy0 committed Nov 27, 2024
1 parent 8f51c49 commit 7cbca17
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 135 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,21 @@ struct TestConfig: Encodable {
var mode: GeneratorMode
var additionalImports: [String]?
var featureFlags: FeatureFlags?
var namingStrategy: NamingStrategy
var nameOverrides: [String: String]
var referenceOutputDirectory: String
}

extension TestConfig {
var asConfig: Config {
.init(mode: mode, access: .public, additionalImports: additionalImports ?? [], featureFlags: featureFlags ?? [])
.init(
mode: mode,
access: .public,
additionalImports: additionalImports ?? [],
namingStrategy: namingStrategy,
nameOverrides: nameOverrides,
featureFlags: featureFlags ?? []
)
}
}

Expand Down Expand Up @@ -127,6 +136,8 @@ final class FileBasedReferenceTests: XCTestCase {
mode: mode,
additionalImports: [],
featureFlags: featureFlags,
namingStrategy: .optimistic,
nameOverrides: [:],
referenceOutputDirectory: "ReferenceSources/\(project.fixtureCodeDirectoryName)"
),
ignoredDiagnosticMessages: ignoredDiagnosticMessages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public struct Client: APIProtocol {
///
/// - Remark: HTTP `GET /pets`.
/// - Remark: Generated from `#/paths//pets/get(listPets)`.
public func listPets(_ input: Operations.listPets.Input) async throws -> Operations.listPets.Output {
public func listPets(_ input: Operations.ListPets.Input) async throws -> Operations.ListPets.Output {
try await client.send(
input: input,
forOperation: Operations.listPets.id,
forOperation: Operations.ListPets.id,
serializer: { input in
let path = try converter.renderedPath(
template: "/pets",
Expand Down Expand Up @@ -103,7 +103,7 @@ public struct Client: APIProtocol {
deserializer: { response, responseBody in
switch response.status.code {
case 200:
let headers: Operations.listPets.Output.Ok.Headers = .init(
let headers: Operations.ListPets.Output.Ok.Headers = .init(
My_hyphen_Response_hyphen_UUID: try converter.getRequiredHeaderFieldAsURI(
in: response.headerFields,
name: "My-Response-UUID",
Expand All @@ -116,7 +116,7 @@ public struct Client: APIProtocol {
)
)
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
let body: Operations.listPets.Output.Ok.Body
let body: Operations.ListPets.Output.Ok.Body
let chosenContentType = try converter.bestContentType(
received: contentType,
options: [
Expand All @@ -141,7 +141,7 @@ public struct Client: APIProtocol {
))
default:
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
let body: Operations.listPets.Output.Default.Body
let body: Operations.ListPets.Output.Default.Body
let chosenContentType = try converter.bestContentType(
received: contentType,
options: [
Expand Down Expand Up @@ -172,10 +172,10 @@ public struct Client: APIProtocol {
///
/// - Remark: HTTP `POST /pets`.
/// - Remark: Generated from `#/paths//pets/post(createPet)`.
public func createPet(_ input: Operations.createPet.Input) async throws -> Operations.createPet.Output {
public func createPet(_ input: Operations.CreatePet.Input) async throws -> Operations.CreatePet.Output {
try await client.send(
input: input,
forOperation: Operations.createPet.id,
forOperation: Operations.CreatePet.id,
serializer: { input in
let path = try converter.renderedPath(
template: "/pets",
Expand Down Expand Up @@ -209,13 +209,13 @@ public struct Client: APIProtocol {
deserializer: { response, responseBody in
switch response.status.code {
case 201:
let headers: Operations.createPet.Output.Created.Headers = .init(X_hyphen_Extra_hyphen_Arguments: try converter.getOptionalHeaderFieldAsJSON(
let headers: Operations.CreatePet.Output.Created.Headers = .init(X_hyphen_Extra_hyphen_Arguments: try converter.getOptionalHeaderFieldAsJSON(
in: response.headerFields,
name: "X-Extra-Arguments",
as: Components.Schemas.CodeError.self
))
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
let body: Operations.createPet.Output.Created.Body
let body: Operations.CreatePet.Output.Created.Body
let chosenContentType = try converter.bestContentType(
received: contentType,
options: [
Expand Down Expand Up @@ -287,10 +287,10 @@ public struct Client: APIProtocol {
///
/// - Remark: HTTP `POST /pets/create`.
/// - Remark: Generated from `#/paths//pets/create/post(createPetWithForm)`.
public func createPetWithForm(_ input: Operations.createPetWithForm.Input) async throws -> Operations.createPetWithForm.Output {
public func createPetWithForm(_ input: Operations.CreatePetWithForm.Input) async throws -> Operations.CreatePetWithForm.Output {
try await client.send(
input: input,
forOperation: Operations.createPetWithForm.id,
forOperation: Operations.CreatePetWithForm.id,
serializer: { input in
let path = try converter.renderedPath(
template: "/pets/create",
Expand Down Expand Up @@ -330,10 +330,10 @@ public struct Client: APIProtocol {
}
/// - Remark: HTTP `GET /pets/stats`.
/// - Remark: Generated from `#/paths//pets/stats/get(getStats)`.
public func getStats(_ input: Operations.getStats.Input) async throws -> Operations.getStats.Output {
public func getStats(_ input: Operations.GetStats.Input) async throws -> Operations.GetStats.Output {
try await client.send(
input: input,
forOperation: Operations.getStats.id,
forOperation: Operations.GetStats.id,
serializer: { input in
let path = try converter.renderedPath(
template: "/pets/stats",
Expand All @@ -354,7 +354,7 @@ public struct Client: APIProtocol {
switch response.status.code {
case 200:
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
let body: Operations.getStats.Output.Ok.Body
let body: Operations.GetStats.Output.Ok.Body
let chosenContentType = try converter.bestContentType(
received: contentType,
options: [
Expand Down Expand Up @@ -406,10 +406,10 @@ public struct Client: APIProtocol {
}
/// - Remark: HTTP `POST /pets/stats`.
/// - Remark: Generated from `#/paths//pets/stats/post(postStats)`.
public func postStats(_ input: Operations.postStats.Input) async throws -> Operations.postStats.Output {
public func postStats(_ input: Operations.PostStats.Input) async throws -> Operations.PostStats.Output {
try await client.send(
input: input,
forOperation: Operations.postStats.id,
forOperation: Operations.PostStats.id,
serializer: { input in
let path = try converter.renderedPath(
template: "/pets/stats",
Expand Down Expand Up @@ -461,10 +461,10 @@ public struct Client: APIProtocol {
}
/// - Remark: HTTP `POST /probe/`.
/// - Remark: Generated from `#/paths//probe//post(probe)`.
public func probe(_ input: Operations.probe.Input) async throws -> Operations.probe.Output {
public func probe(_ input: Operations.Probe.Input) async throws -> Operations.Probe.Output {
try await client.send(
input: input,
forOperation: Operations.probe.id,
forOperation: Operations.Probe.id,
serializer: { input in
let path = try converter.renderedPath(
template: "/probe/",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ fileprivate extension UniversalServer where APIHandler: APIProtocol {
request: request,
requestBody: body,
metadata: metadata,
forOperation: Operations.listPets.id,
forOperation: Operations.ListPets.id,
using: {
APIHandler.listPets($0)
},
deserializer: { request, requestBody, metadata in
let query: Operations.listPets.Input.Query = .init(
let query: Operations.ListPets.Input.Query = .init(
limit: try converter.getOptionalQueryItemAsURI(
in: request.soar_query,
style: .form,
Expand All @@ -178,14 +178,14 @@ fileprivate extension UniversalServer where APIHandler: APIProtocol {
style: .form,
explode: true,
name: "habitat",
as: Operations.listPets.Input.Query.habitatPayload.self
as: Operations.ListPets.Input.Query.habitatPayload.self
),
feeds: try converter.getOptionalQueryItemAsURI(
in: request.soar_query,
style: .form,
explode: true,
name: "feeds",
as: Operations.listPets.Input.Query.feedsPayload.self
as: Operations.ListPets.Input.Query.feedsPayload.self
),
since: try converter.getOptionalQueryItemAsURI(
in: request.soar_query,
Expand All @@ -195,15 +195,15 @@ fileprivate extension UniversalServer where APIHandler: APIProtocol {
as: Components.Parameters.query_period_born_hyphen_since.self
)
)
let headers: Operations.listPets.Input.Headers = .init(
let headers: Operations.ListPets.Input.Headers = .init(
My_hyphen_Request_hyphen_UUID: try converter.getOptionalHeaderFieldAsURI(
in: request.headerFields,
name: "My-Request-UUID",
as: Swift.String.self
),
accept: try converter.extractAcceptHeaderIfPresent(in: request.headerFields)
)
return Operations.listPets.Input(
return Operations.ListPets.Input(
query: query,
headers: headers
)
Expand Down Expand Up @@ -273,12 +273,12 @@ fileprivate extension UniversalServer where APIHandler: APIProtocol {
request: request,
requestBody: body,
metadata: metadata,
forOperation: Operations.createPet.id,
forOperation: Operations.CreatePet.id,
using: {
APIHandler.createPet($0)
},
deserializer: { request, requestBody, metadata in
let headers: Operations.createPet.Input.Headers = .init(
let headers: Operations.CreatePet.Input.Headers = .init(
X_hyphen_Extra_hyphen_Arguments: try converter.getOptionalHeaderFieldAsJSON(
in: request.headerFields,
name: "X-Extra-Arguments",
Expand All @@ -287,7 +287,7 @@ fileprivate extension UniversalServer where APIHandler: APIProtocol {
accept: try converter.extractAcceptHeaderIfPresent(in: request.headerFields)
)
let contentType = converter.extractContentTypeIfPresent(in: request.headerFields)
let body: Operations.createPet.Input.Body
let body: Operations.CreatePet.Input.Body
let chosenContentType = try converter.bestContentType(
received: contentType,
options: [
Expand All @@ -306,7 +306,7 @@ fileprivate extension UniversalServer where APIHandler: APIProtocol {
default:
preconditionFailure("bestContentType chose an invalid content type.")
}
return Operations.createPet.Input(
return Operations.CreatePet.Input(
headers: headers,
body: body
)
Expand Down Expand Up @@ -378,13 +378,13 @@ fileprivate extension UniversalServer where APIHandler: APIProtocol {
request: request,
requestBody: body,
metadata: metadata,
forOperation: Operations.createPetWithForm.id,
forOperation: Operations.CreatePetWithForm.id,
using: {
APIHandler.createPetWithForm($0)
},
deserializer: { request, requestBody, metadata in
let contentType = converter.extractContentTypeIfPresent(in: request.headerFields)
let body: Operations.createPetWithForm.Input.Body
let body: Operations.CreatePetWithForm.Input.Body
let chosenContentType = try converter.bestContentType(
received: contentType,
options: [
Expand All @@ -403,7 +403,7 @@ fileprivate extension UniversalServer where APIHandler: APIProtocol {
default:
preconditionFailure("bestContentType chose an invalid content type.")
}
return Operations.createPetWithForm.Input(body: body)
return Operations.CreatePetWithForm.Input(body: body)
},
serializer: { output, request in
switch output {
Expand All @@ -429,13 +429,13 @@ fileprivate extension UniversalServer where APIHandler: APIProtocol {
request: request,
requestBody: body,
metadata: metadata,
forOperation: Operations.getStats.id,
forOperation: Operations.GetStats.id,
using: {
APIHandler.getStats($0)
},
deserializer: { request, requestBody, metadata in
let headers: Operations.getStats.Input.Headers = .init(accept: try converter.extractAcceptHeaderIfPresent(in: request.headerFields))
return Operations.getStats.Input(headers: headers)
let headers: Operations.GetStats.Input.Headers = .init(accept: try converter.extractAcceptHeaderIfPresent(in: request.headerFields))
return Operations.GetStats.Input(headers: headers)
},
serializer: { output, request in
switch output {
Expand Down Expand Up @@ -494,13 +494,13 @@ fileprivate extension UniversalServer where APIHandler: APIProtocol {
request: request,
requestBody: body,
metadata: metadata,
forOperation: Operations.postStats.id,
forOperation: Operations.PostStats.id,
using: {
APIHandler.postStats($0)
},
deserializer: { request, requestBody, metadata in
let contentType = converter.extractContentTypeIfPresent(in: request.headerFields)
let body: Operations.postStats.Input.Body
let body: Operations.PostStats.Input.Body
let chosenContentType = try converter.bestContentType(
received: contentType,
options: [
Expand Down Expand Up @@ -537,7 +537,7 @@ fileprivate extension UniversalServer where APIHandler: APIProtocol {
default:
preconditionFailure("bestContentType chose an invalid content type.")
}
return Operations.postStats.Input(body: body)
return Operations.PostStats.Input(body: body)
},
serializer: { output, request in
switch output {
Expand All @@ -563,12 +563,12 @@ fileprivate extension UniversalServer where APIHandler: APIProtocol {
request: request,
requestBody: body,
metadata: metadata,
forOperation: Operations.probe.id,
forOperation: Operations.Probe.id,
using: {
APIHandler.probe($0)
},
deserializer: { request, requestBody, metadata in
return Operations.probe.Input()
return Operations.Probe.Input()
},
serializer: { output, request in
switch output {
Expand Down
Loading

0 comments on commit 7cbca17

Please sign in to comment.