Skip to content

Commit e30691e

Browse files
authored
Remove the base64 feature flag (#401)
Remove the base64 feature flag ### Motivation In preparation for 1.0.0-alpha.1, we enable and remove all feature flags. ### Modifications Remove the feature flag. Now, the fun thing I just discovered is that the feature flag wasn't correctly wired up, so we accidentally broke some users in 0.3.x when base64 landed, as it changed `Swift.String` to `OpenAPIRuntime.Base64EncodedData` _unconditionally_. This wasn't caught in PR review and unfortunately didn't have a negative test that would have caught this. ### Result Removed a stale feature flag. ### Test Plan All tests pass. Reviewed by: simonjbeaumont Builds: ✔︎ pull request validation (5.10) - Build finished. ✔︎ pull request validation (5.9) - Build finished. ✔︎ pull request validation (compatibility test) - Build finished. ✔︎ pull request validation (docc test) - Build finished. ✔︎ pull request validation (nightly) - Build finished. ✔︎ pull request validation (soundness) - Build finished. ✖︎ pull request validation (integration test) - Build finished. #401
1 parent 92bffd1 commit e30691e

File tree

4 files changed

+4
-33
lines changed

4 files changed

+4
-33
lines changed

Sources/_OpenAPIGeneratorCore/FeatureFlags.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@
2828
public enum FeatureFlag: String, Hashable, Codable, CaseIterable, Sendable {
2929
// needs to be here for the enum to compile
3030
case empty
31-
32-
/// Base64 encoding and decoding.
33-
///
34-
/// Enable interpretation of `type: string, format: byte` as base64-encoded data.
35-
case base64DataEncodingDecoding
3631
}
3732

3833
/// A set of enabled feature flags.

Sources/_OpenAPIGeneratorCore/Translator/TypeAssignment/TypeAssigner.swift

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ struct TypeAssigner {
4545
/// safe to be used as a Swift identifier.
4646
var asSwiftSafeName: (String) -> String
4747

48-
///Enable decoding and encoding of as base64-encoded data strings.
49-
var enableBase64EncodingDecoding: Bool
50-
5148
/// Returns a type name for an OpenAPI-named component type.
5249
///
5350
/// A component type is any type in `#/components` in the OpenAPI document.
@@ -331,10 +328,7 @@ struct TypeAssigner {
331328
inParent parent: TypeName,
332329
subtype: SubtypeNamingMethod
333330
) throws -> TypeUsage {
334-
let typeMatcher = TypeMatcher(
335-
asSwiftSafeName: asSwiftSafeName,
336-
enableBase64EncodingDecoding: enableBase64EncodingDecoding
337-
)
331+
let typeMatcher = TypeMatcher(asSwiftSafeName: asSwiftSafeName)
338332
// Check if this type can be simply referenced without
339333
// creating a new inline type.
340334
if let referenceableType = try typeMatcher.tryMatchReferenceableType(for: schema, components: components) {
@@ -551,20 +545,10 @@ struct TypeAssigner {
551545
extension FileTranslator {
552546
553547
/// A configured type assigner.
554-
var typeAssigner: TypeAssigner {
555-
TypeAssigner(
556-
asSwiftSafeName: swiftSafeName,
557-
enableBase64EncodingDecoding: config.featureFlags.contains(.base64DataEncodingDecoding)
558-
)
559-
}
548+
var typeAssigner: TypeAssigner { TypeAssigner(asSwiftSafeName: swiftSafeName) }
560549
561550
/// A configured type matcher.
562-
var typeMatcher: TypeMatcher {
563-
TypeMatcher(
564-
asSwiftSafeName: swiftSafeName,
565-
enableBase64EncodingDecoding: config.featureFlags.contains(.base64DataEncodingDecoding)
566-
)
567-
}
551+
var typeMatcher: TypeMatcher { TypeMatcher(asSwiftSafeName: swiftSafeName) }
568552
}
569553
570554
/// An error used during the parsing of JSON references specified in an

Sources/_OpenAPIGeneratorCore/Translator/TypeAssignment/TypeMatcher.swift

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ struct TypeMatcher {
2020
/// safe to be used as a Swift identifier.
2121
var asSwiftSafeName: (String) -> String
2222

23-
///Enable decoding and encoding of as base64-encoded data strings.
24-
var enableBase64EncodingDecoding: Bool
25-
2623
/// Returns the type name of a built-in type that matches the specified
2724
/// schema.
2825
///
@@ -72,11 +69,7 @@ struct TypeMatcher {
7269
test: { (schema) -> TypeUsage? in
7370
if let builtinType = Self._tryMatchBuiltinNonRecursive(for: schema) { return builtinType }
7471
guard case let .reference(ref, _) = schema else { return nil }
75-
return try TypeAssigner(
76-
asSwiftSafeName: asSwiftSafeName,
77-
enableBase64EncodingDecoding: enableBase64EncodingDecoding
78-
)
79-
.typeName(for: ref).asUsage
72+
return try TypeAssigner(asSwiftSafeName: asSwiftSafeName).typeName(for: ref).asUsage
8073
},
8174
matchedArrayHandler: { elementType in elementType.asArray },
8275
genericArrayHandler: { TypeName.arrayContainer.asUsage }

Tests/OpenAPIGeneratorReferenceTests/SnippetBasedReferenceTests.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4671,7 +4671,6 @@ final class SnippetBasedReferenceTests: XCTestCase {
46714671

46724672
func testResponseWithExampleWithOnlyValueByte() throws {
46734673
try self.assertResponsesTranslation(
4674-
featureFlags: [.base64DataEncodingDecoding],
46754674
"""
46764675
responses:
46774676
MyResponse:

0 commit comments

Comments
 (0)