Skip to content

Commit

Permalink
[Experiment] Optimistic naming strategy as opt-in
Browse files Browse the repository at this point in the history
  • Loading branch information
czechboy0 committed Nov 20, 2024
1 parent 7fcef1d commit 140f5c0
Show file tree
Hide file tree
Showing 25 changed files with 589 additions and 121 deletions.
13 changes: 13 additions & 0 deletions Sources/_OpenAPIGeneratorCore/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
//
//===----------------------------------------------------------------------===//

public enum NamingStrategy: String, Sendable, Codable, Equatable {
case defensive
case optimistic
}

/// A structure that contains configuration options for a single execution
/// of the generator pipeline run.
///
Expand All @@ -35,6 +40,10 @@ public struct Config: Sendable {
/// Filter to apply to the OpenAPI document before generation.
public var filter: DocumentFilter?

public var namingStrategy: NamingStrategy?

public var nameOverrides: [String: String]?

/// Additional pre-release features to enable.
public var featureFlags: FeatureFlags

Expand All @@ -50,12 +59,16 @@ public struct Config: Sendable {
access: AccessModifier,
additionalImports: [String] = [],
filter: DocumentFilter? = nil,
namingStrategy: NamingStrategy? = nil,
nameOverrides: [String: String]? = nil,
featureFlags: FeatureFlags = []
) {
self.mode = mode
self.access = access
self.additionalImports = additionalImports
self.filter = filter
self.namingStrategy = namingStrategy
self.nameOverrides = nameOverrides
self.featureFlags = featureFlags
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ extension ClientFileTranslator {
func translateClientMethod(_ description: OperationDescription) throws -> Declaration {

let operationTypeExpr = Expression.identifierType(.member(Constants.Operations.namespace))
.dot(description.methodName)
.dot(description.operationTypeName)

let operationArg = FunctionArgumentDescription(label: "forOperation", expression: operationTypeExpr.dot("id"))
let inputArg = FunctionArgumentDescription(
Expand Down
Loading

0 comments on commit 140f5c0

Please sign in to comment.