diff --git a/generators/swift/base/src/context/AbstractSwiftGeneratorContext.ts b/generators/swift/base/src/context/AbstractSwiftGeneratorContext.ts index 0909db9fa20e..e0777a5c0c41 100644 --- a/generators/swift/base/src/context/AbstractSwiftGeneratorContext.ts +++ b/generators/swift/base/src/context/AbstractSwiftGeneratorContext.ts @@ -6,12 +6,22 @@ import { } from "@fern-api/base-generator"; import { assertDefined, assertNever, entries } from "@fern-api/core-utils"; import { RelativeFilePath } from "@fern-api/fs-utils"; -import { BaseSwiftCustomConfigSchema, Referencer, swift, UndiscriminatedUnion } from "@fern-api/swift-codegen"; +import { + BaseSwiftCustomConfigSchema, + NameRegistry, + Referencer, + swift, + UndiscriminatedUnion +} from "@fern-api/swift-codegen"; import { FernIr } from "@fern-fern/ir-sdk"; import { AsIsFileDefinition, SourceAsIsFiles, TestAsIsFiles } from "../AsIs.js"; import { SwiftProject } from "../project/index.js"; import { CycleDetector } from "./cycle-detector.js"; -import { registerLiteralEnums, registerLiteralEnumsForObjectProperties } from "./register-literal-enums.js"; +import { + registerLiteralEnums, + registerLiteralEnumsForObjectProperties, + registerLiteralEnumsForTypeReference +} from "./register-literal-enums.js"; import { registerUndiscriminatedUnionVariants } from "./register-undiscriminated-unions.js"; export abstract class AbstractSwiftGeneratorContext< @@ -156,13 +166,53 @@ export abstract class AbstractSwiftGeneratorContext< }); }); Object.entries(ir.subpackages).forEach(([subpackageId, subpackage]) => { - nameRegistry.registerSubClientSymbol({ + const subClientSymbol = nameRegistry.registerSubClientSymbol({ subpackageId, fernFilepathPartNamesPascalCase: subpackage.fernFilepath.allParts.map((name) => this.caseConverter.pascalUnsafe(name) ), subpackageNamePascalCase: this.caseConverter.pascalUnsafe(subpackage.name) }); + if (subpackage.service != null) { + this.registerEndpointParameterLiteralEnums({ + parentSymbol: subClientSymbol, + service: ir.services[subpackage.service], + registry: nameRegistry + }); + } + }); + if (ir.rootPackage.service != null) { + this.registerEndpointParameterLiteralEnums({ + parentSymbol: nameRegistry.getRootClientSymbolOrThrow(), + service: ir.services[ir.rootPackage.service], + registry: nameRegistry + }); + } + } + + /** + * Inline literal query parameters become method parameters on the generated client, so their + * literal enums must be registered under the owning client symbol (matching the scope used to + * resolve the parameter's Swift type). Otherwise the parameter falls back to `JSONValue` while + * snippets and wire tests emit the literal enum case, producing a type mismatch. + */ + private registerEndpointParameterLiteralEnums({ + parentSymbol, + service, + registry + }: { + parentSymbol: swift.Symbol; + service: FernIr.HttpService | undefined; + registry: NameRegistry; + }): void { + service?.endpoints.forEach((endpoint) => { + endpoint.queryParameters.forEach((queryParam) => { + registerLiteralEnumsForTypeReference({ + parentSymbol, + registry, + typeReference: queryParam.valueType + }); + }); }); } @@ -282,7 +332,7 @@ export abstract class AbstractSwiftGeneratorContext< return typeReference.container._visit({ literal: (literal) => literal._visit({ - boolean: () => referencer.referenceAsIsType("JSONValue"), + boolean: () => referencer.referenceSwiftType("Bool"), string: (literalValue) => { const symbol = this.project.nameRegistry.getNestedLiteralEnumSymbol( fromSymbol, diff --git a/generators/swift/codegen/src/ast/Class.ts b/generators/swift/codegen/src/ast/Class.ts index 4e3c82c59dd1..5e37e93090ab 100644 --- a/generators/swift/codegen/src/ast/Class.ts +++ b/generators/swift/codegen/src/ast/Class.ts @@ -2,6 +2,7 @@ import { escapeReservedKeyword } from "../syntax/index.js"; import { AccessLevel } from "./AccessLevel.js"; import { AstNode, Writer } from "./core/index.js"; import { DocComment } from "./DocComment.js"; +import { EnumWithRawValues } from "./EnumWithRawValues.js"; import { Initializer } from "./Initializer.js"; import { Method } from "./Method.js"; import { Property } from "./Property.js"; @@ -16,6 +17,7 @@ export declare namespace Class { properties: Property[]; initializers?: Initializer[]; methods?: Method[]; + nestedTypes?: EnumWithRawValues[]; docs?: DocComment; } } @@ -28,6 +30,7 @@ export class Class extends AstNode { public readonly properties: Property[]; public readonly initializers: Initializer[]; public readonly methods: Method[]; + public readonly nestedTypes: EnumWithRawValues[]; public readonly docs?: DocComment; public constructor({ @@ -38,6 +41,7 @@ export class Class extends AstNode { properties, initializers, methods, + nestedTypes, docs }: Class.Args) { super(); @@ -48,6 +52,7 @@ export class Class extends AstNode { this.properties = properties; this.initializers = initializers ?? []; this.methods = methods ?? []; + this.nestedTypes = nestedTypes ?? []; this.docs = docs; } @@ -98,6 +103,16 @@ export class Class extends AstNode { writer.newLine(); }); } + if (this.nestedTypes.length > 0) { + writer.newLine(); + this.nestedTypes.forEach((nestedType, nestedTypeIdx) => { + if (nestedTypeIdx > 0) { + writer.newLine(); + } + nestedType.write(writer); + writer.newLine(); + }); + } writer.dedent(); writer.write("}"); } diff --git a/generators/swift/codegen/src/name-registry/name-registry.ts b/generators/swift/codegen/src/name-registry/name-registry.ts index 1a68905ea55a..bf7287ea5a0a 100644 --- a/generators/swift/codegen/src/name-registry/name-registry.ts +++ b/generators/swift/codegen/src/name-registry/name-registry.ts @@ -448,8 +448,11 @@ export class NameRegistry { variants: UndiscriminatedUnionVariant[]; }) { const parentSymbolId = typeof parentSymbol === "string" ? parentSymbol : parentSymbol.id; + // Preserve the declaration order of the union members. Decoding attempts are emitted in + // this order, and Fern decodes undiscriminated unions by trying members in declaration + // order; sorting (e.g. alphabetically) would, for example, try `double` before `int` and + // decode an integral JSON number as a `Double`. const distinctVariants = uniqWith(variants, (a, b) => a.caseName === b.caseName); - distinctVariants.sort((a, b) => a.caseName.localeCompare(b.caseName)); this.undiscriminatedUnionVariantsByParentSymbolId.set(parentSymbolId, distinctVariants); return distinctVariants; } diff --git a/generators/swift/dynamic-snippets/src/EndpointSnippetGenerator.ts b/generators/swift/dynamic-snippets/src/EndpointSnippetGenerator.ts index 42789db53cec..58d56404c147 100644 --- a/generators/swift/dynamic-snippets/src/EndpointSnippetGenerator.ts +++ b/generators/swift/dynamic-snippets/src/EndpointSnippetGenerator.ts @@ -404,6 +404,19 @@ export class EndpointSnippetGenerator { this.context.errors.unscope(); args.push(...pathParameterFields); + // The generated SDK declares endpoint headers as method parameters after the + // path parameters and before the query parameters, so emit them here to keep + // the rendered argument order aligned with the method signature. + this.context.errors.scope(Scope.Headers); + const headerParameterFields: swift.FunctionArgument[] = []; + if (request.headers != null) { + headerParameterFields.push( + ...this.getEndpointMethodHeaderParameters({ namedParameters: request.headers, snippet }) + ); + } + this.context.errors.unscope(); + args.push(...headerParameterFields); + this.context.errors.scope(Scope.QueryParameters); const queryParameterFields: swift.FunctionArgument[] = []; if (request.queryParameters != null) { @@ -514,6 +527,53 @@ export class EndpointSnippetGenerator { }); } + private getEndpointMethodHeaderParameters({ + namedParameters, + snippet + }: { + namedParameters: FernIr.dynamic.NamedParameter[]; + snippet: FernIr.dynamic.EndpointSnippetRequest; + }): swift.FunctionArgument[] { + const moduleSymbol = this.context.nameRegistry.getRegisteredSourceModuleSymbolOrThrow(); + const referencer = this.context.createReferencer(moduleSymbol); + return this.context + .getExampleObjectProperties({ + parameters: namedParameters, + snippetObject: snippet.headers ?? {} + }) + .filter((parameter) => { + // The generated SDK only surfaces String-typed headers as endpoint + // method parameters; non-String and literal headers are set + // automatically, so the snippet must omit them to match the signature. + // Resolve through type aliases first so that a header typed as an + // alias of String (which the SDK treats as a String parameter) is + // still emitted here. + const resolvedTypeReference = this.resolveAliasTypeReference(parameter.typeReference); + const swiftType = this.context.getSwiftTypeReferenceFromScope(resolvedTypeReference, moduleSymbol); + return referencer.resolvesToTheSwiftType(swiftType.nonOptional(), "String"); + }) + .map((parameter) => { + return swift.functionArgument({ + label: parameter.name.name.camelCase.unsafeName, + value: this.context.dynamicTypeLiteralMapper.convert({ + fromSymbol: moduleSymbol, + typeReference: parameter.typeReference, + value: parameter.value + }) + }); + }); + } + + private resolveAliasTypeReference(typeReference: FernIr.dynamic.TypeReference): FernIr.dynamic.TypeReference { + if (typeReference.type === "named") { + const namedType = this.context.ir.types[typeReference.value]; + if (namedType != null && namedType.type === "alias") { + return this.resolveAliasTypeReference(namedType.typeReference); + } + } + return typeReference; + } + private getFilePropertyInfo({ request, snippet @@ -525,7 +585,8 @@ export class EndpointSnippetGenerator { if (request.body == null || !this.context.isFileUploadRequestBody(request.body)) { return { fileFields: [], - bodyPropertyFields: [] + bodyPropertyFields: [], + orderedFields: [] }; } return this.context.filePropertyMapper.getFilePropertyInfo({ @@ -575,7 +636,7 @@ export class EndpointSnippetGenerator { }): swift.FunctionArgument[] { switch (body.type) { case "fileUpload": - return [...filePropertyInfo.fileFields, ...filePropertyInfo.bodyPropertyFields]; + return filePropertyInfo.orderedFields; case "properties": return this.getInlinedRequestBodyPropertyObjectFields({ parameters: body.value, value }); case "referenced": diff --git a/generators/swift/dynamic-snippets/src/__test__/__snapshots__/DynamicSnippetsGenerator.test.ts.snap b/generators/swift/dynamic-snippets/src/__test__/__snapshots__/DynamicSnippetsGenerator.test.ts.snap index 8a2d376eb918..af5b337c9323 100644 --- a/generators/swift/dynamic-snippets/src/__test__/__snapshots__/DynamicSnippetsGenerator.test.ts.snap +++ b/generators/swift/dynamic-snippets/src/__test__/__snapshots__/DynamicSnippetsGenerator.test.ts.snap @@ -8,6 +8,7 @@ private func main() async throws { let client = AcmeClient(token: "") _ = try await client.service.getMetadata( + xAPIVersion: "0.0.1", shallow: false, tag: [ "development", diff --git a/generators/swift/dynamic-snippets/src/context/DynamicSnippetsGeneratorContext.ts b/generators/swift/dynamic-snippets/src/context/DynamicSnippetsGeneratorContext.ts index 06b3b0b26b9f..f7dbd5947349 100644 --- a/generators/swift/dynamic-snippets/src/context/DynamicSnippetsGeneratorContext.ts +++ b/generators/swift/dynamic-snippets/src/context/DynamicSnippetsGeneratorContext.ts @@ -9,7 +9,11 @@ import { BaseSwiftCustomConfigSchema, NameRegistry, Referencer, swift } from "@f import { pascalCase } from "../util/pascal-case.js"; import { DynamicTypeLiteralMapper } from "./DynamicTypeLiteralMapper.js"; import { FilePropertyMapper } from "./FilePropertyMapper.js"; -import { registerLiteralEnums, registerLiteralEnumsForObjectProperties } from "./register-literal-enums.js"; +import { + registerLiteralEnums, + registerLiteralEnumsForObjectProperties, + registerLiteralEnumsForTypeReference +} from "./register-literal-enums.js"; import { registerUndiscriminatedUnionVariants } from "./register-undiscriminated-unions.js"; export class DynamicSnippetsGeneratorContext extends AbstractDynamicSnippetsGeneratorContext { @@ -131,6 +135,17 @@ export class DynamicSnippetsGeneratorContext extends AbstractDynamicSnippetsGene requestNamePascalCase: endpoint.request.declaration.name.pascalCase.unsafeName }); } + // Inline literal query parameters are resolved against the source module symbol + // (see EndpointSnippetGenerator.getEndpointMethodQueryParameters), so their literal + // enums must be registered under that same scope. This mirrors the SDK generator's + // AbstractSwiftGeneratorContext, which registers them under the owning client symbol. + endpoint.request.queryParameters?.forEach((queryParameter) => { + registerLiteralEnumsForTypeReference({ + parentSymbol: registeredSourceModuleSymbol, + registry: nameRegistry, + typeReference: queryParameter.typeReference + }); + }); } }); @@ -164,12 +179,12 @@ export class DynamicSnippetsGeneratorContext extends AbstractDynamicSnippetsGene list: (ref) => swift.TypeReference.array(this.getSwiftTypeReferenceFromScope(ref.value, fromSymbol)), literal: (ref) => { return visitDiscriminatedUnion(ref.value, "type")._visit({ - boolean: () => referencer.referenceAsIsType("JSONValue"), + boolean: () => referencer.referenceSwiftType("Bool"), string: (literalType) => { - const symbol = this.nameRegistry.getNestedLiteralEnumSymbolOrThrow( - fromSymbol, - literalType.value - ); + const symbol = this.nameRegistry.getNestedLiteralEnumSymbol(fromSymbol, literalType.value); + if (symbol == null) { + return referencer.referenceAsIsType("JSONValue"); + } return referencer.referenceType(symbol); }, _other: () => referencer.referenceAsIsType("JSONValue") diff --git a/generators/swift/dynamic-snippets/src/context/DynamicTypeLiteralMapper.ts b/generators/swift/dynamic-snippets/src/context/DynamicTypeLiteralMapper.ts index 87f292a4ebbf..7fc876b3d47b 100644 --- a/generators/swift/dynamic-snippets/src/context/DynamicTypeLiteralMapper.ts +++ b/generators/swift/dynamic-snippets/src/context/DynamicTypeLiteralMapper.ts @@ -259,10 +259,19 @@ export class DynamicTypeLiteralMapper { if (record == null) { return swift.Expression.nop(); } + // A single-property variant wraps its value under the variant's property + // wire key (the union's CodingKeys raw value), which defaults to "value" but + // can be customized via `key:` and is not exposed on the dynamic IR. The + // discriminant has already been stripped from the record, so exclude any + // inherited base properties to isolate the wrapped value's key. + const basePropertyKeys = new Set( + (unionVariant.properties ?? []).map((property) => property.name.wireValue) + ); + const propertyKey = Object.keys(record).find((key) => !basePropertyKeys.has(key)) ?? "value"; const converted = this.convert({ fromSymbol, typeReference: unionVariant.typeReference, - value: record[unionVariant.discriminantValue.wireValue] + value: record[propertyKey] }); return swift.Expression.methodCall({ target: swift.Expression.reference(unionSymbol.name), @@ -323,13 +332,30 @@ export class DynamicTypeLiteralMapper { value: unknown; }): swift.Expression { const symbol = this.context.nameRegistry.getSchemaTypeSymbolOrThrow(typeId); + const exampleProperties = this.context.getExampleObjectProperties({ + parameters: object_.properties, + snippetObject: value + }); + const examplePropertiesByWireValue = new Map( + exampleProperties.map((typeInstance) => [typeInstance.name.wireValue, typeInstance]) + ); + // Literal properties are constants that the generated initializer always requires, so emit + // them in declaration order even when the example omits them. + const orderedProperties = object_.properties + .map((property) => { + const exampleProperty = examplePropertiesByWireValue.get(property.name.wireValue); + if (exampleProperty != null) { + return exampleProperty; + } + if (property.typeReference.type === "literal") { + return { name: property.name, typeReference: property.typeReference, value: undefined }; + } + return null; + }) + .filter((typeInstance) => typeInstance != null); return swift.Expression.structInitialization({ unsafeName: symbol.name, - arguments_: this.context - .getExampleObjectProperties({ - parameters: object_.properties, - snippetObject: value - }) + arguments_: orderedProperties .map((typeInstance) => { const expression = this.convert({ fromSymbol, diff --git a/generators/swift/dynamic-snippets/src/context/FilePropertyMapper.ts b/generators/swift/dynamic-snippets/src/context/FilePropertyMapper.ts index 598388841187..d904684921dc 100644 --- a/generators/swift/dynamic-snippets/src/context/FilePropertyMapper.ts +++ b/generators/swift/dynamic-snippets/src/context/FilePropertyMapper.ts @@ -7,6 +7,12 @@ import { DynamicSnippetsGeneratorContext } from "./DynamicSnippetsGeneratorConte export interface FilePropertyInfo { fileFields: swift.FunctionArgument[]; bodyPropertyFields: swift.FunctionArgument[]; + /** + * All file and body-property fields in their original schema declaration + * order. The generated request type declares its initializer parameters in + * this order, so snippets must emit arguments in the same order. + */ + orderedFields: swift.FunctionArgument[]; } export class FilePropertyMapper { @@ -27,7 +33,8 @@ export class FilePropertyMapper { }): FilePropertyInfo { const result: FilePropertyInfo = { fileFields: [], - bodyPropertyFields: [] + bodyPropertyFields: [], + orderedFields: [] }; const record = this.context.getRecord(value) ?? {}; for (const property of body.properties) { @@ -38,6 +45,7 @@ export class FilePropertyMapper { value: this.getSingleFileProperty({ property, record }) }); result.fileFields.push(arg); + result.orderedFields.push(arg); break; } case "fileArray": { @@ -46,6 +54,7 @@ export class FilePropertyMapper { value: this.getArrayFileProperty({ property, record }) }); result.fileFields.push(arg); + result.orderedFields.push(arg); break; } case "bodyProperty": { @@ -54,6 +63,7 @@ export class FilePropertyMapper { value: this.getBodyProperty({ fromSymbol, property, record }) }); result.bodyPropertyFields.push(arg); + result.orderedFields.push(arg); break; } default: diff --git a/generators/swift/sdk/changes/0.35.12/fix-wire-test-response-body-encoding.yml b/generators/swift/sdk/changes/0.35.12/fix-wire-test-response-body-encoding.yml new file mode 100644 index 000000000000..fb97a3d08d7c --- /dev/null +++ b/generators/swift/sdk/changes/0.35.12/fix-wire-test-response-body-encoding.yml @@ -0,0 +1,11 @@ +# yaml-language-server: $schema=../../../../../fern-changes-yml.schema.json + +- summary: | + Fixed wire-test stub response bodies so they are valid JSON for every + response type. The generated SDK reads `String`-typed response bodies as raw + UTF-8 but decodes every other type via `JSONDecoder`. Wire tests now mirror + that: `String`-decoded responses (string/bigInteger/base64 primitives) emit + the raw payload, while all other types (objects, enums, dates, UUIDs, numbers, + unions, etc.) are JSON-encoded. Previously bare scalars such as a UUID or enum + value were emitted unquoted, producing invalid JSON that failed to decode. + type: fix diff --git a/generators/swift/sdk/changes/0.35.13/fix-argument-ordering-in-wire-tests-and-snippets.yml b/generators/swift/sdk/changes/0.35.13/fix-argument-ordering-in-wire-tests-and-snippets.yml new file mode 100644 index 000000000000..af21b57f4ad7 --- /dev/null +++ b/generators/swift/sdk/changes/0.35.13/fix-argument-ordering-in-wire-tests-and-snippets.yml @@ -0,0 +1,12 @@ +# yaml-language-server: $schema=../../../../../fern-changes-yml.schema.json + +- summary: | + Fixed argument ordering in generated wire tests and snippets so they match + the order in which the corresponding Swift types declare their memberwise + initializer parameters. Example object properties were previously emitted in + the example's authoring order, and file-upload fields were grouped by kind + (files before body properties), both of which could produce arguments in the + wrong positional order and fail to compile. Wire-test response objects are + now reordered to match the generated struct's declaration order, and + file-upload request snippets preserve the original schema declaration order. + type: fix diff --git a/generators/swift/sdk/changes/0.35.13/fix-literal-query-parameters.yml b/generators/swift/sdk/changes/0.35.13/fix-literal-query-parameters.yml new file mode 100644 index 000000000000..1e875c0f6e85 --- /dev/null +++ b/generators/swift/sdk/changes/0.35.13/fix-literal-query-parameters.yml @@ -0,0 +1,11 @@ +# yaml-language-server: $schema=../../../../../fern-changes-yml.schema.json + +- summary: | + Fixed inline literal query parameters so they are typed correctly in the + generated client method instead of falling back to the placeholder + `JSONValue`. A boolean literal now maps to `Bool` and a string literal maps + to a dedicated literal enum nested on the owning client. Previously the + parameter was typed as `JSONValue` while the generated snippets and wire + tests emitted the literal enum case, causing a type mismatch that failed to + compile. + type: fix diff --git a/generators/swift/sdk/changes/0.35.13/fix-plain-text-response-type.yml b/generators/swift/sdk/changes/0.35.13/fix-plain-text-response-type.yml new file mode 100644 index 000000000000..e61b0a915745 --- /dev/null +++ b/generators/swift/sdk/changes/0.35.13/fix-plain-text-response-type.yml @@ -0,0 +1,9 @@ +# yaml-language-server: $schema=../../../../../fern-changes-yml.schema.json + +- summary: | + Fixed endpoints that return a `text/plain` response so the generated method + returns `String` instead of the placeholder `JSONValue`. The HTTP client + already decodes a `String` response type from the raw UTF-8 body, so the + generated wire tests now compile and pass (previously `response == "string"` + failed because the response was typed as `JSONValue`). + type: fix diff --git a/generators/swift/sdk/changes/0.35.13/fix-single-property-union-snippets.yml b/generators/swift/sdk/changes/0.35.13/fix-single-property-union-snippets.yml new file mode 100644 index 000000000000..5c20fac5fe59 --- /dev/null +++ b/generators/swift/sdk/changes/0.35.13/fix-single-property-union-snippets.yml @@ -0,0 +1,12 @@ +# yaml-language-server: $schema=../../../../../fern-changes-yml.schema.json + +- summary: | + Fixed generated snippets and wire tests for single-property discriminated + union variants. The wrapped value is serialized under the variant's property + wire key (the union's CodingKeys raw value), but the snippet/wire-test + generator was reading it from the discriminant's wire name, so variants whose + discriminant differed from that key (e.g. a `date` or `datetime` case) emitted + an empty enum case like `UnionWithTime.date()` that failed to compile. The + value is now read from the correct property key, including variants that + customize it via `key:`. + type: fix diff --git a/generators/swift/sdk/changes/0.35.13/fix-undiscriminated-union-member-order.yml b/generators/swift/sdk/changes/0.35.13/fix-undiscriminated-union-member-order.yml new file mode 100644 index 000000000000..bbd170a34cf1 --- /dev/null +++ b/generators/swift/sdk/changes/0.35.13/fix-undiscriminated-union-member-order.yml @@ -0,0 +1,11 @@ +# yaml-language-server: $schema=../../../../../fern-changes-yml.schema.json + +- summary: | + Preserve the declaration order of undiscriminated union members in generated + code. Members were previously sorted alphabetically, which reordered the + decoding attempts emitted in the `Decodable` initializer. For a union + containing both `int` and `double`, this tried `Double` before `Int` and + decoded integral JSON numbers (e.g. `1`) as a `Double` (`1.0`), so wire tests + failed to round-trip. Members are now decoded in declaration order, matching + Fern's undiscriminated union semantics. + type: fix diff --git a/generators/swift/sdk/changes/0.35.13/fix-wire-test-additional-properties.yml b/generators/swift/sdk/changes/0.35.13/fix-wire-test-additional-properties.yml new file mode 100644 index 000000000000..e788e3886bf1 --- /dev/null +++ b/generators/swift/sdk/changes/0.35.13/fix-wire-test-additional-properties.yml @@ -0,0 +1,10 @@ +# yaml-language-server: $schema=../../../../../fern-changes-yml.schema.json + +- summary: | + Fixed generated wire tests to include extra (additional) properties in the + expected response object for types whose schema permits them. The decoded + response captures any undeclared JSON keys into `additionalProperties`, but + the expected response object previously omitted them, so the equality + assertion failed. Plain object responses now populate `additionalProperties` + the same way undiscriminated-union responses already did. + type: fix diff --git a/generators/swift/sdk/changes/0.35.13/fix-wire-test-and-snippet-endpoint-headers.yml b/generators/swift/sdk/changes/0.35.13/fix-wire-test-and-snippet-endpoint-headers.yml new file mode 100644 index 000000000000..a3705236673f --- /dev/null +++ b/generators/swift/sdk/changes/0.35.13/fix-wire-test-and-snippet-endpoint-headers.yml @@ -0,0 +1,13 @@ +# yaml-language-server: $schema=../../../../../fern-changes-yml.schema.json + +- summary: | + Fixed generated wire tests and snippets so that they pass endpoint header + arguments to the endpoint method. The endpoint method call previously emitted + only path, query, and body arguments, omitting required header parameters + (e.g. `X-API-Version`), which produced calls missing required arguments that + failed to compile. Headers are now rendered between the path and query + arguments to match the generated method signature, filtered to the + String-typed headers the SDK surfaces as parameters. The String-type filter + resolves through type aliases, so a header typed as an alias of String is + emitted just like the SDK declares it. + type: fix diff --git a/generators/swift/sdk/src/generators/client/EndpointMethodGenerator.ts b/generators/swift/sdk/src/generators/client/EndpointMethodGenerator.ts index 2ec104f37551..b389d0cc9fd3 100644 --- a/generators/swift/sdk/src/generators/client/EndpointMethodGenerator.ts +++ b/generators/swift/sdk/src/generators/client/EndpointMethodGenerator.ts @@ -187,7 +187,7 @@ export class EndpointMethodGenerator { json: (resp) => this.sdkGeneratorContext.getSwiftTypeReferenceFromScope(resp.responseBodyType, this.parentClassSymbol), fileDownload: () => this.referencer.referenceFoundationType("Data"), - text: () => this.referencer.referenceAsIsType("JSONValue"), // TODO(kafkas): Handle text responses + text: () => this.referencer.referenceSwiftType("String"), bytes: () => this.referencer.referenceAsIsType("JSONValue"), // TODO(kafkas): Handle bytes responses streaming: () => this.referencer.referenceAsIsType("JSONValue"), // TODO(kafkas): Handle streaming responses streamParameter: () => this.referencer.referenceAsIsType("JSONValue"), // TODO(kafkas): Handle stream parameter responses diff --git a/generators/swift/sdk/src/generators/client/RootClientGenerator.ts b/generators/swift/sdk/src/generators/client/RootClientGenerator.ts index a411311fbeea..e99a9c5d1de7 100644 --- a/generators/swift/sdk/src/generators/client/RootClientGenerator.ts +++ b/generators/swift/sdk/src/generators/client/RootClientGenerator.ts @@ -1,6 +1,7 @@ import { getWireValue } from "@fern-api/base-generator"; import { assertNever, visitDiscriminatedUnion } from "@fern-api/core-utils"; import { Referencer, swift } from "@fern-api/swift-codegen"; +import { LiteralEnumGenerator } from "@fern-api/swift-model"; import { FernIr } from "@fern-fern/ir-sdk"; import { SdkGeneratorContext } from "../../SdkGeneratorContext.js"; import { ClientGeneratorContext } from "./ClientGeneratorContext.js"; @@ -114,6 +115,7 @@ export class RootClientGenerator { ], initializers: this.generateInitializers(), methods: this.generateMethods(), + nestedTypes: this.generateNestedLiteralEnums(), docs: swift.docComment({ summary: "Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions." @@ -121,6 +123,14 @@ export class RootClientGenerator { }); } + private generateNestedLiteralEnums(): swift.EnumWithRawValues[] { + return this.sdkGeneratorContext.project.nameRegistry + .getAllNestedLiteralEnumSymbolsOrThrow(this.symbol) + .map(({ symbol, literalValue }) => + new LiteralEnumGenerator({ name: symbol.name, literalValue }).generate() + ); + } + private generateInitializers(): swift.Initializer[] { const initializers: swift.Initializer[] = [ this.generateConvenienceInitializer({ bearerTokenParamType: "string" }) diff --git a/generators/swift/sdk/src/generators/client/SubClientGenerator.ts b/generators/swift/sdk/src/generators/client/SubClientGenerator.ts index 1ccb78cd36a0..4a620d843542 100644 --- a/generators/swift/sdk/src/generators/client/SubClientGenerator.ts +++ b/generators/swift/sdk/src/generators/client/SubClientGenerator.ts @@ -1,4 +1,5 @@ import { Referencer, swift } from "@fern-api/swift-codegen"; +import { LiteralEnumGenerator } from "@fern-api/swift-model"; import { FernIr } from "@fern-fern/ir-sdk"; import { SdkGeneratorContext } from "../../SdkGeneratorContext.js"; import { ClientGeneratorContext } from "./ClientGeneratorContext.js"; @@ -48,10 +49,19 @@ export class SubClientGenerator { this.clientGeneratorContext.httpClient.property ], initializers: [this.generateInitializer()], - methods: this.generateMethods() + methods: this.generateMethods(), + nestedTypes: this.generateNestedLiteralEnums() }); } + private generateNestedLiteralEnums(): swift.EnumWithRawValues[] { + return this.sdkGeneratorContext.project.nameRegistry + .getAllNestedLiteralEnumSymbolsOrThrow(this.symbol) + .map(({ symbol, literalValue }) => + new LiteralEnumGenerator({ name: symbol.name, literalValue }).generate() + ); + } + private generateInitializer(): swift.Initializer { return swift.initializer({ parameters: [ diff --git a/generators/swift/sdk/src/generators/test/WireTestFunctionGenerator.ts b/generators/swift/sdk/src/generators/test/WireTestFunctionGenerator.ts index f54bbc8ba773..29aba523d7d6 100644 --- a/generators/swift/sdk/src/generators/test/WireTestFunctionGenerator.ts +++ b/generators/swift/sdk/src/generators/test/WireTestFunctionGenerator.ts @@ -205,16 +205,7 @@ export class WireTestFunctionGenerator { return literalContainer.literal._visit({ string: (val) => swift.Expression.enumCaseShorthand(LiteralEnum.generateEnumCaseLabel(val.original)), - boolean: (val) => - swift.Expression.methodCall({ - target: swift.Expression.reference("JSONValue"), - methodName: "bool", - arguments_: [ - swift.functionArgument({ - value: swift.Expression.boolLiteral(val) - }) - ] - }), + boolean: (val) => swift.Expression.boolLiteral(val), integer: () => swift.Expression.nop(), uint: () => swift.Expression.nop(), uint64: () => swift.Expression.nop(), @@ -338,24 +329,35 @@ export class WireTestFunctionGenerator { ); }, object: (exampleObjectType) => { + const propertyArgs: swift.FunctionArgument[] = this.orderExamplePropertiesByDeclaration( + typeId, + exampleObjectType.properties + ) + .map((property) => { + if ( + property.value.shape.type === "container" && + property.value.shape.container.type === "optional" && + property.value.shape.container.optional == null + ) { + return null; + } + const exampleResponse = this.generateExampleResponse(property.value, fromScope); + return swift.functionArgument({ + label: this.sdkGeneratorContext.caseConverter.camelUnsafe(property.name), + value: exampleResponse + }); + }) + .filter((arg): arg is swift.FunctionArgument => arg != null); + const additionalPropertiesArg = this.buildAdditionalPropertiesArg({ + jsonExample: exampleTypeRef.jsonExample, + declaredWireNames: new Set(exampleObjectType.properties.map((p) => getWireValue(p.name))) + }); + if (additionalPropertiesArg != null) { + propertyArgs.push(additionalPropertiesArg); + } return swift.Expression.structInitialization({ unsafeName: symbol.name, - arguments_: exampleObjectType.properties - .map((property) => { - if ( - property.value.shape.type === "container" && - property.value.shape.container.type === "optional" && - property.value.shape.container.optional == null - ) { - return null; - } - const exampleResponse = this.generateExampleResponse(property.value, fromScope); - return swift.functionArgument({ - label: this.sdkGeneratorContext.caseConverter.camelUnsafe(property.name), - value: exampleResponse - }); - }) - .filter((arg) => arg != null), + arguments_: propertyArgs, multiline: true }); }, @@ -370,19 +372,10 @@ export class WireTestFunctionGenerator { memberName: caseName }), samePropertiesAsObject: (exampleObjectTypeWithId) => { - const declaredWireNames = new Set( - exampleObjectTypeWithId.object.properties.map((p) => getWireValue(p.name)) - ); - const jsonObj = - exampleTypeRef.jsonExample != null && - typeof exampleTypeRef.jsonExample === "object" && - !Array.isArray(exampleTypeRef.jsonExample) - ? (exampleTypeRef.jsonExample as Record) - : {}; - const extraEntries = Object.entries(jsonObj).filter( - ([key]) => !declaredWireNames.has(key) - ); - const propertyArgs: swift.FunctionArgument[] = exampleObjectTypeWithId.object.properties + const propertyArgs: swift.FunctionArgument[] = this.orderExamplePropertiesByDeclaration( + exampleObjectTypeWithId.typeId, + exampleObjectTypeWithId.object.properties + ) .map((property) => { if ( property.value.shape.type === "container" && @@ -398,19 +391,14 @@ export class WireTestFunctionGenerator { }); }) .filter((arg): arg is swift.FunctionArgument => arg != null); - if (extraEntries.length > 0) { - propertyArgs.push( - swift.functionArgument({ - label: "additionalProperties", - value: swift.Expression.dictionaryLiteral({ - entries: extraEntries.map(([key, value]) => [ - swift.Expression.escapedStringLiteral(key), - this.generateUnknownExampleResponse(value) - ]), - multiline: true - }) - }) - ); + const additionalPropertiesArg = this.buildAdditionalPropertiesArg({ + jsonExample: exampleTypeRef.jsonExample, + declaredWireNames: new Set( + exampleObjectTypeWithId.object.properties.map((p) => getWireValue(p.name)) + ) + }); + if (additionalPropertiesArg != null) { + propertyArgs.push(additionalPropertiesArg); } return swift.Expression.methodCall({ target: swift.Expression.reference(symbol.name), @@ -470,6 +458,69 @@ export class WireTestFunctionGenerator { }); } + /** + * Builds the `additionalProperties` argument for an object whose schema + * permits extra properties. The decoded response captures any JSON keys not + * declared on the type into `additionalProperties`, so the expected response + * must include them too or the equality assertion fails. Returns `null` when + * the example has no undeclared keys (so objects without extra properties are + * left untouched). + */ + private buildAdditionalPropertiesArg({ + jsonExample, + declaredWireNames + }: { + jsonExample: unknown; + declaredWireNames: Set; + }): swift.FunctionArgument | null { + const jsonObj = + jsonExample != null && typeof jsonExample === "object" && !Array.isArray(jsonExample) + ? (jsonExample as Record) + : {}; + const extraEntries = Object.entries(jsonObj).filter(([key]) => !declaredWireNames.has(key)); + if (extraEntries.length === 0) { + return null; + } + return swift.functionArgument({ + label: "additionalProperties", + value: swift.Expression.dictionaryLiteral({ + entries: extraEntries.map(([key, value]) => [ + swift.Expression.escapedStringLiteral(key), + this.generateUnknownExampleResponse(value) + ]), + multiline: true + }) + }); + } + + /** + * Reorders example object properties to match the order the generated Swift + * struct declares them in its memberwise initializer, which is + * `[...extendedProperties, ...properties]`. Example properties are otherwise + * emitted in the example's authoring order, which can differ from the + * declaration order and produce arguments in the wrong positional order. + */ + private orderExamplePropertiesByDeclaration( + typeId: FernIr.TypeId, + properties: FernIr.ExampleObjectProperty[] + ): FernIr.ExampleObjectProperty[] { + const typeDeclaration = this.sdkGeneratorContext.ir.types[typeId]; + if (typeDeclaration == null || typeDeclaration.shape.type !== "object") { + return properties; + } + const declaredOrder = [ + ...(typeDeclaration.shape.extendedProperties ?? []), + ...typeDeclaration.shape.properties + ].map((property) => getWireValue(property.name)); + const declarationIndexOf = (wireName: string): number => { + const index = declaredOrder.indexOf(wireName); + return index === -1 ? declaredOrder.length : index; + }; + return [...properties].sort( + (a, b) => declarationIndexOf(getWireValue(a.name)) - declarationIndexOf(getWireValue(b.name)) + ); + } + public getSwiftTypeReferenceForExampleTypeReferenceFromTestModuleScope( typeReference: FernIr.ExampleTypeReference ): swift.TypeReference { @@ -499,7 +550,7 @@ export class WireTestFunctionGenerator { .createReferencer(fromScope) .referenceType(literalEnumSymbol); }, - boolean: () => this.referencer.referenceAsIsType("JSONValue"), + boolean: () => this.referencer.referenceSwiftType("Bool"), integer: () => this.referencer.referenceAsIsType("JSONValue"), uint: () => this.referencer.referenceAsIsType("JSONValue"), uint64: () => this.referencer.referenceAsIsType("JSONValue"), @@ -654,12 +705,54 @@ export class WireTestFunctionGenerator { } function renderWireTestResponseBody(exampleTypeRef: FernIr.ExampleTypeReference): string { - if (typeof exampleTypeRef.jsonExample === "string") { - return exampleTypeRef.jsonExample; - } const value = buildJsonFromExampleTypeReference(exampleTypeRef); - if (typeof value === "string") { - return value; + // The generated SDK reads `String`-typed response bodies as the raw UTF-8 + // payload (see HTTPClient: `responseType == String.self`), whereas every + // other type is parsed as JSON. Mirror that here: emit the raw string for + // String-decoded responses, and JSON-encode everything else so a bare + // scalar (e.g. a UUID or number) is still valid JSON the decoder accepts. + if (responseDecodesAsRawString(exampleTypeRef)) { + return typeof value === "string" ? value : String(value ?? ""); } return JSON.stringify(value, null, 2); } + +/** + * Whether the SDK decodes the given response type as a raw Swift `String` + * (rather than parsing it as JSON). Mirrors the Swift type mapping in which + * `string`, `bigInteger`, and `base64` primitives resolve to `String`. + */ +function responseDecodesAsRawString(exampleTypeRef: FernIr.ExampleTypeReference): boolean { + return exampleTypeRef.shape._visit({ + primitive: (primitive) => + primitive._visit({ + string: () => true, + bigInteger: () => true, + base64: () => true, + integer: () => false, + long: () => false, + uint: () => false, + uint64: () => false, + float: () => false, + double: () => false, + boolean: () => false, + date: () => false, + datetime: () => false, + datetimeRfc2822: () => false, + uuid: () => false, + _other: () => false + }), + named: (named) => + named.shape._visit({ + alias: (alias) => responseDecodesAsRawString(alias.value), + enum: () => false, + object: () => false, + union: () => false, + undiscriminatedUnion: () => false, + _other: () => false + }), + container: () => false, + unknown: () => false, + _other: () => false + }); +} diff --git a/generators/swift/sdk/versions.yml b/generators/swift/sdk/versions.yml index 2d3338ce7da1..5dbbde1ce0dc 100644 --- a/generators/swift/sdk/versions.yml +++ b/generators/swift/sdk/versions.yml @@ -1,4 +1,85 @@ # yaml-language-server: $schema=../../../fern-versions-yml.schema.json +- version: 0.35.13 + changelogEntry: + - summary: | + Fixed argument ordering in generated wire tests and snippets so they match + the order in which the corresponding Swift types declare their memberwise + initializer parameters. Example object properties were previously emitted in + the example's authoring order, and file-upload fields were grouped by kind + (files before body properties), both of which could produce arguments in the + wrong positional order and fail to compile. Wire-test response objects are + now reordered to match the generated struct's declaration order, and + file-upload request snippets preserve the original schema declaration order. + type: fix + - summary: | + Fixed inline literal query parameters so they are typed correctly in the + generated client method instead of falling back to the placeholder + `JSONValue`. A boolean literal now maps to `Bool` and a string literal maps + to a dedicated literal enum nested on the owning client. Previously the + parameter was typed as `JSONValue` while the generated snippets and wire + tests emitted the literal enum case, causing a type mismatch that failed to + compile. + type: fix + - summary: | + Fixed endpoints that return a `text/plain` response so the generated method + returns `String` instead of the placeholder `JSONValue`. The HTTP client + already decodes a `String` response type from the raw UTF-8 body, so the + generated wire tests now compile and pass (previously `response == "string"` + failed because the response was typed as `JSONValue`). + type: fix + - summary: | + Fixed generated snippets and wire tests for single-property discriminated + union variants. The wrapped value is serialized under the variant's property + wire key (the union's CodingKeys raw value), but the snippet/wire-test + generator was reading it from the discriminant's wire name, so variants whose + discriminant differed from that key (e.g. a `date` or `datetime` case) emitted + an empty enum case like `UnionWithTime.date()` that failed to compile. The + value is now read from the correct property key, including variants that + customize it via `key:`. + type: fix + - summary: | + Preserve the declaration order of undiscriminated union members in generated + code. Members were previously sorted alphabetically, which reordered the + decoding attempts emitted in the `Decodable` initializer. For a union + containing both `int` and `double`, this tried `Double` before `Int` and + decoded integral JSON numbers (e.g. `1`) as a `Double` (`1.0`), so wire tests + failed to round-trip. Members are now decoded in declaration order, matching + Fern's undiscriminated union semantics. + type: fix + - summary: | + Fixed generated wire tests to include extra (additional) properties in the + expected response object for types whose schema permits them. The decoded + response captures any undeclared JSON keys into `additionalProperties`, but + the expected response object previously omitted them, so the equality + assertion failed. Plain object responses now populate `additionalProperties` + the same way undiscriminated-union responses already did. + type: fix + - summary: | + Fixed generated wire tests and snippets so that they pass endpoint header + arguments to the endpoint method. The endpoint method call previously emitted + only path, query, and body arguments, omitting required header parameters + (e.g. `X-API-Version`), which produced calls missing required arguments that + failed to compile. Headers are now rendered between the path and query + arguments to match the generated method signature, filtered to the + String-typed headers the SDK surfaces as parameters. The String-type filter + resolves through type aliases, so a header typed as an alias of String is + emitted just like the SDK declares it. + type: fix + createdAt: "2026-06-16" + irVersion: 66 +- version: 0.35.12 + changelogEntry: + - summary: | + Fixed wire-test stub response bodies so they are valid JSON for every + response type. The generated SDK reads `String`-typed response bodies as raw + UTF-8 but decodes every other type via `JSONDecoder`. Wire tests now mirror + that: `String`-decoded responses (string/bigInteger/base64 primitives) emit + the raw payload, while all other types (objects, enums, dates, UUIDs, numbers, + unions, etc.) are JSON-encoded. Previously bare scalars such as a UUID or enum + value were emitted unquoted, producing invalid JSON that failed to decode. + type: fix + createdAt: "2026-06-16" + irVersion: 66 - version: 0.35.11 changelogEntry: - summary: | diff --git a/seed/swift-sdk/circular-references/Sources/Schemas/JsonLike.swift b/seed/swift-sdk/circular-references/Sources/Schemas/JsonLike.swift index 40cd1950719e..a1faab0c36e4 100644 --- a/seed/swift-sdk/circular-references/Sources/Schemas/JsonLike.swift +++ b/seed/swift-sdk/circular-references/Sources/Schemas/JsonLike.swift @@ -1,24 +1,24 @@ import Foundation public indirect enum JsonLike: Codable, Hashable, Sendable { - case bool(Bool) - case int(Int) case jsonLikeArray([JsonLike]) - case string(String) case stringToJsonLikeDictionary([String: JsonLike]) + case string(String) + case int(Int) + case bool(Bool) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(Bool.self) { - self = .bool(value) - } else if let value = try? container.decode(Int.self) { - self = .int(value) - } else if let value = try? container.decode([JsonLike].self) { + if let value = try? container.decode([JsonLike].self) { self = .jsonLikeArray(value) - } else if let value = try? container.decode(String.self) { - self = .string(value) } else if let value = try? container.decode([String: JsonLike].self) { self = .stringToJsonLikeDictionary(value) + } else if let value = try? container.decode(String.self) { + self = .string(value) + } else if let value = try? container.decode(Int.self) { + self = .int(value) + } else if let value = try? container.decode(Bool.self) { + self = .bool(value) } else { throw DecodingError.dataCorruptedError( in: container, @@ -30,15 +30,15 @@ public indirect enum JsonLike: Codable, Hashable, Sendable { public func encode(to encoder: Encoder) throws -> Void { var container = encoder.singleValueContainer() switch self { - case .bool(let value): - try container.encode(value) - case .int(let value): - try container.encode(value) case .jsonLikeArray(let value): try container.encode(value) + case .stringToJsonLikeDictionary(let value): + try container.encode(value) case .string(let value): try container.encode(value) - case .stringToJsonLikeDictionary(let value): + case .int(let value): + try container.encode(value) + case .bool(let value): try container.encode(value) } } diff --git a/seed/swift-sdk/circular-references/Sources/Schemas/JsonLikeWithNullAndUndefined.swift b/seed/swift-sdk/circular-references/Sources/Schemas/JsonLikeWithNullAndUndefined.swift index ce71f34645a5..b097c770d8f0 100644 --- a/seed/swift-sdk/circular-references/Sources/Schemas/JsonLikeWithNullAndUndefined.swift +++ b/seed/swift-sdk/circular-references/Sources/Schemas/JsonLikeWithNullAndUndefined.swift @@ -1,24 +1,24 @@ import Foundation public indirect enum JsonLikeWithNullAndUndefined: Codable, Hashable, Sendable { - case optionalNullableBool(Nullable?) - case optionalNullableInt(Nullable?) case optionalNullableJsonLikeWithNullAndUndefinedArray([Nullable?]) - case optionalNullableString(Nullable?) case stringToOptionalNullableJsonLikeWithNullAndUndefinedDictionary([String: Nullable?]) + case optionalNullableString(Nullable?) + case optionalNullableInt(Nullable?) + case optionalNullableBool(Nullable?) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(Nullable?.self) { - self = .optionalNullableBool(value) - } else if let value = try? container.decode(Nullable?.self) { - self = .optionalNullableInt(value) - } else if let value = try? container.decode([Nullable?].self) { + if let value = try? container.decode([Nullable?].self) { self = .optionalNullableJsonLikeWithNullAndUndefinedArray(value) - } else if let value = try? container.decode(Nullable?.self) { - self = .optionalNullableString(value) } else if let value = try? container.decode([String: Nullable?].self) { self = .stringToOptionalNullableJsonLikeWithNullAndUndefinedDictionary(value) + } else if let value = try? container.decode(Nullable?.self) { + self = .optionalNullableString(value) + } else if let value = try? container.decode(Nullable?.self) { + self = .optionalNullableInt(value) + } else if let value = try? container.decode(Nullable?.self) { + self = .optionalNullableBool(value) } else { throw DecodingError.dataCorruptedError( in: container, @@ -30,15 +30,15 @@ public indirect enum JsonLikeWithNullAndUndefined: Codable, Hashable, Sendable { public func encode(to encoder: Encoder) throws -> Void { var container = encoder.singleValueContainer() switch self { - case .optionalNullableBool(let value): - try container.encode(value) - case .optionalNullableInt(let value): - try container.encode(value) case .optionalNullableJsonLikeWithNullAndUndefinedArray(let value): try container.encode(value) + case .stringToOptionalNullableJsonLikeWithNullAndUndefinedDictionary(let value): + try container.encode(value) case .optionalNullableString(let value): try container.encode(value) - case .stringToOptionalNullableJsonLikeWithNullAndUndefinedDictionary(let value): + case .optionalNullableInt(let value): + try container.encode(value) + case .optionalNullableBool(let value): try container.encode(value) } } diff --git a/seed/swift-sdk/examples/no-custom-config/Tests/Snippets/Example17.swift b/seed/swift-sdk/examples/no-custom-config/Tests/Snippets/Example17.swift index de462ec07971..5f28dbe74bb7 100644 --- a/seed/swift-sdk/examples/no-custom-config/Tests/Snippets/Example17.swift +++ b/seed/swift-sdk/examples/no-custom-config/Tests/Snippets/Example17.swift @@ -8,6 +8,9 @@ enum Example17 { token: "" ) - _ = try await client.service.getMetadata(shallow: false) + _ = try await client.service.getMetadata( + xApiVersion: "0.0.1", + shallow: false + ) } } diff --git a/seed/swift-sdk/examples/no-custom-config/Tests/Snippets/Example18.swift b/seed/swift-sdk/examples/no-custom-config/Tests/Snippets/Example18.swift index 08425df1d50e..2bd94e25fc05 100644 --- a/seed/swift-sdk/examples/no-custom-config/Tests/Snippets/Example18.swift +++ b/seed/swift-sdk/examples/no-custom-config/Tests/Snippets/Example18.swift @@ -8,6 +8,9 @@ enum Example18 { token: "" ) - _ = try await client.service.getMetadata(shallow: true) + _ = try await client.service.getMetadata( + xApiVersion: "X-API-Version", + shallow: true + ) } } diff --git a/seed/swift-sdk/examples/no-custom-config/Tests/Snippets/Example19.swift b/seed/swift-sdk/examples/no-custom-config/Tests/Snippets/Example19.swift index 6aa1ec7ab484..abfe4c38e809 100644 --- a/seed/swift-sdk/examples/no-custom-config/Tests/Snippets/Example19.swift +++ b/seed/swift-sdk/examples/no-custom-config/Tests/Snippets/Example19.swift @@ -42,7 +42,7 @@ enum Example19 { name: "name" ), metadata: MetadataType.html( - + "metadata" ), commonMetadata: Metadata( id: "id", @@ -61,7 +61,7 @@ enum Example19 { ) ), data: Data.string( - + "data" ), migration: Migration( name: "name", @@ -75,7 +75,7 @@ enum Example19 { ) ), test: Test.and( - + true ), node: Node( name: "name", diff --git a/seed/swift-sdk/examples/no-custom-config/Tests/Snippets/Example5.swift b/seed/swift-sdk/examples/no-custom-config/Tests/Snippets/Example5.swift index bc536b99e6dd..6ff5d20e97d8 100644 --- a/seed/swift-sdk/examples/no-custom-config/Tests/Snippets/Example5.swift +++ b/seed/swift-sdk/examples/no-custom-config/Tests/Snippets/Example5.swift @@ -8,6 +8,9 @@ enum Example5 { token: "" ) - _ = try await client.file.service.getFile(filename: "file.txt") + _ = try await client.file.service.getFile( + filename: "file.txt", + xFileApiVersion: "0.0.2" + ) } } diff --git a/seed/swift-sdk/examples/no-custom-config/Tests/Snippets/Example6.swift b/seed/swift-sdk/examples/no-custom-config/Tests/Snippets/Example6.swift index baa92888ce01..85abdd3c88ff 100644 --- a/seed/swift-sdk/examples/no-custom-config/Tests/Snippets/Example6.swift +++ b/seed/swift-sdk/examples/no-custom-config/Tests/Snippets/Example6.swift @@ -8,6 +8,9 @@ enum Example6 { token: "" ) - _ = try await client.file.service.getFile(filename: "filename") + _ = try await client.file.service.getFile( + filename: "filename", + xFileApiVersion: "X-File-API-Version" + ) } } diff --git a/seed/swift-sdk/examples/no-custom-config/Tests/Snippets/Example7.swift b/seed/swift-sdk/examples/no-custom-config/Tests/Snippets/Example7.swift index a12a5c7ee4bc..df85a8f95e6a 100644 --- a/seed/swift-sdk/examples/no-custom-config/Tests/Snippets/Example7.swift +++ b/seed/swift-sdk/examples/no-custom-config/Tests/Snippets/Example7.swift @@ -8,6 +8,9 @@ enum Example7 { token: "" ) - _ = try await client.file.service.getFile(filename: "filename") + _ = try await client.file.service.getFile( + filename: "filename", + xFileApiVersion: "X-File-API-Version" + ) } } diff --git a/seed/swift-sdk/examples/no-custom-config/Tests/Wire/Resources/File/Service/FileServiceClientWireTests.swift b/seed/swift-sdk/examples/no-custom-config/Tests/Wire/Resources/File/Service/FileServiceClientWireTests.swift index 0b833e7ad4bd..e0c91f1d0129 100644 --- a/seed/swift-sdk/examples/no-custom-config/Tests/Wire/Resources/File/Service/FileServiceClientWireTests.swift +++ b/seed/swift-sdk/examples/no-custom-config/Tests/Wire/Resources/File/Service/FileServiceClientWireTests.swift @@ -26,6 +26,7 @@ import Examples ) let response = try await client.file.service.getFile( filename: "filename", + xFileApiVersion: "X-File-API-Version", requestOptions: RequestOptions(additionalHeaders: stub.headers) ) try #require(response == expectedResponse) diff --git a/seed/swift-sdk/examples/no-custom-config/Tests/Wire/Resources/Service/ServiceClient_WireTests.swift b/seed/swift-sdk/examples/no-custom-config/Tests/Wire/Resources/Service/ServiceClient_WireTests.swift index f0897d4fb3da..223a5e364006 100644 --- a/seed/swift-sdk/examples/no-custom-config/Tests/Wire/Resources/Service/ServiceClient_WireTests.swift +++ b/seed/swift-sdk/examples/no-custom-config/Tests/Wire/Resources/Service/ServiceClient_WireTests.swift @@ -230,6 +230,7 @@ import Examples ) let expectedResponse = MetadataType.html("...") let response = try await client.service.getMetadata( + xApiVersion: "0.0.1", shallow: false, requestOptions: RequestOptions(additionalHeaders: stub.headers) ) @@ -261,6 +262,7 @@ import Examples ) let expectedResponse = MetadataType.html("string") let response = try await client.service.getMetadata( + xApiVersion: "X-API-Version", shallow: true, requestOptions: RequestOptions(additionalHeaders: stub.headers) ) @@ -355,7 +357,7 @@ import Examples name: "name" ), metadata: MetadataType.html( - + "metadata" ), commonMetadata: Metadata( id: "id", @@ -374,7 +376,7 @@ import Examples ) ), data: Data.string( - + "data" ), migration: Migration( name: "name", @@ -388,7 +390,7 @@ import Examples ) ), test: Test.and( - + true ), node: Node( name: "name", diff --git a/seed/swift-sdk/examples/no-custom-config/reference.md b/seed/swift-sdk/examples/no-custom-config/reference.md index e8b7736b622d..eb22c53c8541 100644 --- a/seed/swift-sdk/examples/no-custom-config/reference.md +++ b/seed/swift-sdk/examples/no-custom-config/reference.md @@ -205,7 +205,10 @@ import Examples private func main() async throws { let client = ExamplesClient(token: "") - _ = try await client.file.service.getFile(filename: "file.txt") + _ = try await client.file.service.getFile( + filename: "file.txt", + xFileApiVersion: "0.0.2" + ) } try await main() @@ -541,7 +544,10 @@ import Examples private func main() async throws { let client = ExamplesClient(token: "") - _ = try await client.service.getMetadata(shallow: false) + _ = try await client.service.getMetadata( + xApiVersion: "0.0.1", + shallow: false + ) } try await main() @@ -648,7 +654,7 @@ private func main() async throws { name: "name" ), metadata: MetadataType.html( - + "metadata" ), commonMetadata: Metadata( id: "id", @@ -667,7 +673,7 @@ private func main() async throws { ) ), data: Data.string( - + "data" ), migration: Migration( name: "name", @@ -681,7 +687,7 @@ private func main() async throws { ) ), test: Test.and( - + true ), node: Node( name: "name", diff --git a/seed/swift-sdk/examples/readme-config/Tests/Snippets/Example17.swift b/seed/swift-sdk/examples/readme-config/Tests/Snippets/Example17.swift index de462ec07971..5f28dbe74bb7 100644 --- a/seed/swift-sdk/examples/readme-config/Tests/Snippets/Example17.swift +++ b/seed/swift-sdk/examples/readme-config/Tests/Snippets/Example17.swift @@ -8,6 +8,9 @@ enum Example17 { token: "" ) - _ = try await client.service.getMetadata(shallow: false) + _ = try await client.service.getMetadata( + xApiVersion: "0.0.1", + shallow: false + ) } } diff --git a/seed/swift-sdk/examples/readme-config/Tests/Snippets/Example18.swift b/seed/swift-sdk/examples/readme-config/Tests/Snippets/Example18.swift index 08425df1d50e..2bd94e25fc05 100644 --- a/seed/swift-sdk/examples/readme-config/Tests/Snippets/Example18.swift +++ b/seed/swift-sdk/examples/readme-config/Tests/Snippets/Example18.swift @@ -8,6 +8,9 @@ enum Example18 { token: "" ) - _ = try await client.service.getMetadata(shallow: true) + _ = try await client.service.getMetadata( + xApiVersion: "X-API-Version", + shallow: true + ) } } diff --git a/seed/swift-sdk/examples/readme-config/Tests/Snippets/Example19.swift b/seed/swift-sdk/examples/readme-config/Tests/Snippets/Example19.swift index 6aa1ec7ab484..abfe4c38e809 100644 --- a/seed/swift-sdk/examples/readme-config/Tests/Snippets/Example19.swift +++ b/seed/swift-sdk/examples/readme-config/Tests/Snippets/Example19.swift @@ -42,7 +42,7 @@ enum Example19 { name: "name" ), metadata: MetadataType.html( - + "metadata" ), commonMetadata: Metadata( id: "id", @@ -61,7 +61,7 @@ enum Example19 { ) ), data: Data.string( - + "data" ), migration: Migration( name: "name", @@ -75,7 +75,7 @@ enum Example19 { ) ), test: Test.and( - + true ), node: Node( name: "name", diff --git a/seed/swift-sdk/examples/readme-config/Tests/Snippets/Example5.swift b/seed/swift-sdk/examples/readme-config/Tests/Snippets/Example5.swift index bc536b99e6dd..6ff5d20e97d8 100644 --- a/seed/swift-sdk/examples/readme-config/Tests/Snippets/Example5.swift +++ b/seed/swift-sdk/examples/readme-config/Tests/Snippets/Example5.swift @@ -8,6 +8,9 @@ enum Example5 { token: "" ) - _ = try await client.file.service.getFile(filename: "file.txt") + _ = try await client.file.service.getFile( + filename: "file.txt", + xFileApiVersion: "0.0.2" + ) } } diff --git a/seed/swift-sdk/examples/readme-config/Tests/Snippets/Example6.swift b/seed/swift-sdk/examples/readme-config/Tests/Snippets/Example6.swift index baa92888ce01..85abdd3c88ff 100644 --- a/seed/swift-sdk/examples/readme-config/Tests/Snippets/Example6.swift +++ b/seed/swift-sdk/examples/readme-config/Tests/Snippets/Example6.swift @@ -8,6 +8,9 @@ enum Example6 { token: "" ) - _ = try await client.file.service.getFile(filename: "filename") + _ = try await client.file.service.getFile( + filename: "filename", + xFileApiVersion: "X-File-API-Version" + ) } } diff --git a/seed/swift-sdk/examples/readme-config/Tests/Snippets/Example7.swift b/seed/swift-sdk/examples/readme-config/Tests/Snippets/Example7.swift index a12a5c7ee4bc..df85a8f95e6a 100644 --- a/seed/swift-sdk/examples/readme-config/Tests/Snippets/Example7.swift +++ b/seed/swift-sdk/examples/readme-config/Tests/Snippets/Example7.swift @@ -8,6 +8,9 @@ enum Example7 { token: "" ) - _ = try await client.file.service.getFile(filename: "filename") + _ = try await client.file.service.getFile( + filename: "filename", + xFileApiVersion: "X-File-API-Version" + ) } } diff --git a/seed/swift-sdk/examples/readme-config/Tests/Wire/Resources/File/Service/FileServiceClientWireTests.swift b/seed/swift-sdk/examples/readme-config/Tests/Wire/Resources/File/Service/FileServiceClientWireTests.swift index 0b833e7ad4bd..e0c91f1d0129 100644 --- a/seed/swift-sdk/examples/readme-config/Tests/Wire/Resources/File/Service/FileServiceClientWireTests.swift +++ b/seed/swift-sdk/examples/readme-config/Tests/Wire/Resources/File/Service/FileServiceClientWireTests.swift @@ -26,6 +26,7 @@ import Examples ) let response = try await client.file.service.getFile( filename: "filename", + xFileApiVersion: "X-File-API-Version", requestOptions: RequestOptions(additionalHeaders: stub.headers) ) try #require(response == expectedResponse) diff --git a/seed/swift-sdk/examples/readme-config/Tests/Wire/Resources/Service/ServiceClient_WireTests.swift b/seed/swift-sdk/examples/readme-config/Tests/Wire/Resources/Service/ServiceClient_WireTests.swift index f0897d4fb3da..223a5e364006 100644 --- a/seed/swift-sdk/examples/readme-config/Tests/Wire/Resources/Service/ServiceClient_WireTests.swift +++ b/seed/swift-sdk/examples/readme-config/Tests/Wire/Resources/Service/ServiceClient_WireTests.swift @@ -230,6 +230,7 @@ import Examples ) let expectedResponse = MetadataType.html("...") let response = try await client.service.getMetadata( + xApiVersion: "0.0.1", shallow: false, requestOptions: RequestOptions(additionalHeaders: stub.headers) ) @@ -261,6 +262,7 @@ import Examples ) let expectedResponse = MetadataType.html("string") let response = try await client.service.getMetadata( + xApiVersion: "X-API-Version", shallow: true, requestOptions: RequestOptions(additionalHeaders: stub.headers) ) @@ -355,7 +357,7 @@ import Examples name: "name" ), metadata: MetadataType.html( - + "metadata" ), commonMetadata: Metadata( id: "id", @@ -374,7 +376,7 @@ import Examples ) ), data: Data.string( - + "data" ), migration: Migration( name: "name", @@ -388,7 +390,7 @@ import Examples ) ), test: Test.and( - + true ), node: Node( name: "name", diff --git a/seed/swift-sdk/examples/readme-config/reference.md b/seed/swift-sdk/examples/readme-config/reference.md index e8b7736b622d..eb22c53c8541 100644 --- a/seed/swift-sdk/examples/readme-config/reference.md +++ b/seed/swift-sdk/examples/readme-config/reference.md @@ -205,7 +205,10 @@ import Examples private func main() async throws { let client = ExamplesClient(token: "") - _ = try await client.file.service.getFile(filename: "file.txt") + _ = try await client.file.service.getFile( + filename: "file.txt", + xFileApiVersion: "0.0.2" + ) } try await main() @@ -541,7 +544,10 @@ import Examples private func main() async throws { let client = ExamplesClient(token: "") - _ = try await client.service.getMetadata(shallow: false) + _ = try await client.service.getMetadata( + xApiVersion: "0.0.1", + shallow: false + ) } try await main() @@ -648,7 +654,7 @@ private func main() async throws { name: "name" ), metadata: MetadataType.html( - + "metadata" ), commonMetadata: Metadata( id: "id", @@ -667,7 +673,7 @@ private func main() async throws { ) ), data: Data.string( - + "data" ), migration: Migration( name: "name", @@ -681,7 +687,7 @@ private func main() async throws { ) ), test: Test.and( - + true ), node: Node( name: "name", diff --git a/seed/swift-sdk/exhaustive/Sources/Schemas/MixedType.swift b/seed/swift-sdk/exhaustive/Sources/Schemas/MixedType.swift index f1e9f89231c6..d572d918afce 100644 --- a/seed/swift-sdk/exhaustive/Sources/Schemas/MixedType.swift +++ b/seed/swift-sdk/exhaustive/Sources/Schemas/MixedType.swift @@ -1,17 +1,17 @@ import Foundation public enum MixedType: Codable, Hashable, Sendable { - case bool(Bool) case double(Double) + case bool(Bool) case string(String) case stringArray([String]) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(Bool.self) { - self = .bool(value) - } else if let value = try? container.decode(Double.self) { + if let value = try? container.decode(Double.self) { self = .double(value) + } else if let value = try? container.decode(Bool.self) { + self = .bool(value) } else if let value = try? container.decode(String.self) { self = .string(value) } else if let value = try? container.decode([String].self) { @@ -27,10 +27,10 @@ public enum MixedType: Codable, Hashable, Sendable { public func encode(to encoder: Encoder) throws -> Void { var container = encoder.singleValueContainer() switch self { - case .bool(let value): - try container.encode(value) case .double(let value): try container.encode(value) + case .bool(let value): + try container.encode(value) case .string(let value): try container.encode(value) case .stringArray(let value): diff --git a/seed/swift-sdk/exhaustive/Tests/Snippets/Example62.swift b/seed/swift-sdk/exhaustive/Tests/Snippets/Example62.swift index 55aa6cc640e4..288bb083074f 100644 --- a/seed/swift-sdk/exhaustive/Tests/Snippets/Example62.swift +++ b/seed/swift-sdk/exhaustive/Tests/Snippets/Example62.swift @@ -8,9 +8,12 @@ enum Example62 { token: "" ) - _ = try await client.inlinedRequests.postWithArrayBodyAndHeaders(request: [ - "string", - "string" - ]) + _ = try await client.inlinedRequests.postWithArrayBodyAndHeaders( + xCustomHeader: "X-Custom-Header", + request: [ + "string", + "string" + ] + ) } } diff --git a/seed/swift-sdk/exhaustive/Tests/Snippets/Example67.swift b/seed/swift-sdk/exhaustive/Tests/Snippets/Example67.swift index 0f7ea79666dc..af984194733b 100644 --- a/seed/swift-sdk/exhaustive/Tests/Snippets/Example67.swift +++ b/seed/swift-sdk/exhaustive/Tests/Snippets/Example67.swift @@ -8,6 +8,10 @@ enum Example67 { token: "" ) - _ = try await client.reqWithHeaders.getWithCustomHeader(request: "string") + _ = try await client.reqWithHeaders.getWithCustomHeader( + xTestServiceHeader: "X-TEST-SERVICE-HEADER", + xTestEndpointHeader: "X-TEST-ENDPOINT-HEADER", + request: "string" + ) } } diff --git a/seed/swift-sdk/exhaustive/Tests/Wire/Resources/Endpoints/Enum/EnumClientWireTests.swift b/seed/swift-sdk/exhaustive/Tests/Wire/Resources/Endpoints/Enum/EnumClientWireTests.swift index 9d4b2c3cdb6e..3e0326465e29 100644 --- a/seed/swift-sdk/exhaustive/Tests/Wire/Resources/Endpoints/Enum/EnumClientWireTests.swift +++ b/seed/swift-sdk/exhaustive/Tests/Wire/Resources/Endpoints/Enum/EnumClientWireTests.swift @@ -8,7 +8,7 @@ import Exhaustive stub.setResponse( body: Data( #""" - SUNNY + "SUNNY" """#.utf8 ) ) diff --git a/seed/swift-sdk/exhaustive/Tests/Wire/Resources/Endpoints/Primitive/PrimitiveClientWireTests.swift b/seed/swift-sdk/exhaustive/Tests/Wire/Resources/Endpoints/Primitive/PrimitiveClientWireTests.swift index 499fa10f0c7e..fbb6a3c81d3f 100644 --- a/seed/swift-sdk/exhaustive/Tests/Wire/Resources/Endpoints/Primitive/PrimitiveClientWireTests.swift +++ b/seed/swift-sdk/exhaustive/Tests/Wire/Resources/Endpoints/Primitive/PrimitiveClientWireTests.swift @@ -118,7 +118,7 @@ import Exhaustive stub.setResponse( body: Data( #""" - 2024-01-15T09:30:00Z + "2024-01-15T09:30:00Z" """#.utf8 ) ) @@ -140,7 +140,7 @@ import Exhaustive stub.setResponse( body: Data( #""" - 2023-01-15 + "2023-01-15" """#.utf8 ) ) @@ -162,7 +162,7 @@ import Exhaustive stub.setResponse( body: Data( #""" - d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32 + "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32" """#.utf8 ) ) diff --git a/seed/swift-sdk/exhaustive/Tests/Wire/Resources/InlinedRequests/InlinedRequestsClientWireTests.swift b/seed/swift-sdk/exhaustive/Tests/Wire/Resources/InlinedRequests/InlinedRequestsClientWireTests.swift index a8f80f8a38c5..8458a7dacb3e 100644 --- a/seed/swift-sdk/exhaustive/Tests/Wire/Resources/InlinedRequests/InlinedRequestsClientWireTests.swift +++ b/seed/swift-sdk/exhaustive/Tests/Wire/Resources/InlinedRequests/InlinedRequestsClientWireTests.swift @@ -102,6 +102,7 @@ import Exhaustive ) let expectedResponse = "string" let response = try await client.inlinedRequests.postWithArrayBodyAndHeaders( + xCustomHeader: "X-Custom-Header", request: [ "string", "string" diff --git a/seed/swift-sdk/exhaustive/reference.md b/seed/swift-sdk/exhaustive/reference.md index ee4bd0ba5736..925eb3466b27 100644 --- a/seed/swift-sdk/exhaustive/reference.md +++ b/seed/swift-sdk/exhaustive/reference.md @@ -3794,10 +3794,13 @@ import Exhaustive private func main() async throws { let client = ExhaustiveClient(token: "") - _ = try await client.inlinedRequests.postWithArrayBodyAndHeaders(request: [ - "string", - "string" - ]) + _ = try await client.inlinedRequests.postWithArrayBodyAndHeaders( + xCustomHeader: "X-Custom-Header", + request: [ + "string", + "string" + ] + ) } try await main() @@ -4036,7 +4039,11 @@ import Exhaustive private func main() async throws { let client = ExhaustiveClient(token: "") - _ = try await client.reqWithHeaders.getWithCustomHeader(request: "string") + _ = try await client.reqWithHeaders.getWithCustomHeader( + xTestServiceHeader: "X-TEST-SERVICE-HEADER", + xTestEndpointHeader: "X-TEST-ENDPOINT-HEADER", + request: "string" + ) } try await main() diff --git a/seed/swift-sdk/extra-properties/Tests/Wire/Resources/User/UserClientWireTests.swift b/seed/swift-sdk/extra-properties/Tests/Wire/Resources/User/UserClientWireTests.swift index 33ff77ffaa53..52f245d8d681 100644 --- a/seed/swift-sdk/extra-properties/Tests/Wire/Resources/User/UserClientWireTests.swift +++ b/seed/swift-sdk/extra-properties/Tests/Wire/Resources/User/UserClientWireTests.swift @@ -21,7 +21,11 @@ import ExtraProperties urlSession: stub.urlSession ) let expectedResponse = User( - name: "Alice" + name: "Alice", + additionalProperties: [ + "age": JSONValue.number(30), + "location": JSONValue.string("Wonderland") + ] ) let response = try await client.user.createUser( request: .init( diff --git a/seed/swift-sdk/file-upload-openapi/README.md b/seed/swift-sdk/file-upload-openapi/README.md index b8a60bdae932..25773454df27 100644 --- a/seed/swift-sdk/file-upload-openapi/README.md +++ b/seed/swift-sdk/file-upload-openapi/README.md @@ -55,8 +55,8 @@ private func main() async throws { let client = ApiClient() _ = try await client.fileUploadExample.uploadFile(request: .init( - file: .init(data: Data("".utf8)), - name: "name" + name: "name", + file: .init(data: Data("".utf8)) )) } diff --git a/seed/swift-sdk/file-upload-openapi/Tests/Core/ClientErrorTests.swift b/seed/swift-sdk/file-upload-openapi/Tests/Core/ClientErrorTests.swift index 7c708c9f1034..2b9c950fcc1e 100644 --- a/seed/swift-sdk/file-upload-openapi/Tests/Core/ClientErrorTests.swift +++ b/seed/swift-sdk/file-upload-openapi/Tests/Core/ClientErrorTests.swift @@ -21,8 +21,8 @@ import Testing do { _ = try await client.fileUploadExample.uploadFile( request: .init( - file: .init(data: Data("".utf8)), - name: "name" + name: "name", + file: .init(data: Data("".utf8)) ), requestOptions: RequestOptions(additionalHeaders: stub.headers) ) @@ -57,8 +57,8 @@ import Testing do { _ = try await client.fileUploadExample.uploadFile( request: .init( - file: .init(data: Data("".utf8)), - name: "name" + name: "name", + file: .init(data: Data("".utf8)) ), requestOptions: RequestOptions(additionalHeaders: stub.headers) ) @@ -93,8 +93,8 @@ import Testing do { _ = try await client.fileUploadExample.uploadFile( request: .init( - file: .init(data: Data("".utf8)), - name: "name" + name: "name", + file: .init(data: Data("".utf8)) ), requestOptions: RequestOptions(additionalHeaders: stub.headers) ) @@ -131,8 +131,8 @@ import Testing do { _ = try await client.fileUploadExample.uploadFile( request: .init( - file: .init(data: Data("".utf8)), - name: "name" + name: "name", + file: .init(data: Data("".utf8)) ), requestOptions: RequestOptions(additionalHeaders: stub.headers) ) @@ -167,8 +167,8 @@ import Testing do { _ = try await client.fileUploadExample.uploadFile( request: .init( - file: .init(data: Data("".utf8)), - name: "name" + name: "name", + file: .init(data: Data("".utf8)) ), requestOptions: RequestOptions(additionalHeaders: stub.headers) ) @@ -205,8 +205,8 @@ import Testing do { _ = try await client.fileUploadExample.uploadFile( request: .init( - file: .init(data: Data("".utf8)), - name: "name" + name: "name", + file: .init(data: Data("".utf8)) ), requestOptions: RequestOptions(additionalHeaders: stub.headers) ) @@ -241,8 +241,8 @@ import Testing do { _ = try await client.fileUploadExample.uploadFile( request: .init( - file: .init(data: Data("".utf8)), - name: "name" + name: "name", + file: .init(data: Data("".utf8)) ), requestOptions: RequestOptions(additionalHeaders: stub.headers) ) diff --git a/seed/swift-sdk/file-upload-openapi/Tests/Core/ClientRetryTests.swift b/seed/swift-sdk/file-upload-openapi/Tests/Core/ClientRetryTests.swift index c2968e154a98..3c4a00388f5c 100644 --- a/seed/swift-sdk/file-upload-openapi/Tests/Core/ClientRetryTests.swift +++ b/seed/swift-sdk/file-upload-openapi/Tests/Core/ClientRetryTests.swift @@ -22,8 +22,8 @@ import Testing do { _ = try await client.fileUploadExample.uploadFile( request: .init( - file: .init(data: Data("".utf8)), - name: "name" + name: "name", + file: .init(data: Data("".utf8)) ), requestOptions: RequestOptions(additionalHeaders: stub.headers) ) @@ -52,8 +52,8 @@ import Testing do { _ = try await client.fileUploadExample.uploadFile( request: .init( - file: .init(data: Data("".utf8)), - name: "name" + name: "name", + file: .init(data: Data("".utf8)) ), requestOptions: RequestOptions(additionalHeaders: stub.headers) ) @@ -82,8 +82,8 @@ import Testing do { _ = try await client.fileUploadExample.uploadFile( request: .init( - file: .init(data: Data("".utf8)), - name: "name" + name: "name", + file: .init(data: Data("".utf8)) ), requestOptions: RequestOptions(additionalHeaders: stub.headers) ) @@ -111,8 +111,8 @@ import Testing do { _ = try await client.fileUploadExample.uploadFile( request: .init( - file: .init(data: Data("".utf8)), - name: "name" + name: "name", + file: .init(data: Data("".utf8)) ), requestOptions: RequestOptions(additionalHeaders: stub.headers) ) @@ -139,8 +139,8 @@ import Testing do { _ = try await client.fileUploadExample.uploadFile( request: .init( - file: .init(data: Data("".utf8)), - name: "name" + name: "name", + file: .init(data: Data("".utf8)) ), requestOptions: RequestOptions(additionalHeaders: stub.headers) ) @@ -168,8 +168,8 @@ import Testing do { _ = try await client.fileUploadExample.uploadFile( request: .init( - file: .init(data: Data("".utf8)), - name: "name" + name: "name", + file: .init(data: Data("".utf8)) ), requestOptions: RequestOptions(additionalHeaders: stub.headers) ) @@ -197,8 +197,8 @@ import Testing do { _ = try await client.fileUploadExample.uploadFile( request: .init( - file: .init(data: Data("".utf8)), - name: "name" + name: "name", + file: .init(data: Data("".utf8)) ), requestOptions: RequestOptions(additionalHeaders: stub.headers) ) @@ -231,8 +231,8 @@ import Testing do { _ = try await client.fileUploadExample.uploadFile( request: .init( - file: .init(data: Data("".utf8)), - name: "name" + name: "name", + file: .init(data: Data("".utf8)) ), requestOptions: RequestOptions(additionalHeaders: stub.headers) ) @@ -275,8 +275,8 @@ import Testing do { _ = try await client.fileUploadExample.uploadFile( request: .init( - file: .init(data: Data("".utf8)), - name: "name" + name: "name", + file: .init(data: Data("".utf8)) ), requestOptions: RequestOptions(additionalHeaders: stub.headers) ) @@ -315,8 +315,8 @@ import Testing do { _ = try await client.fileUploadExample.uploadFile( request: .init( - file: .init(data: Data("".utf8)), - name: "name" + name: "name", + file: .init(data: Data("".utf8)) ), requestOptions: RequestOptions(additionalHeaders: stub.headers) ) @@ -366,8 +366,8 @@ import Testing do { _ = try await client.fileUploadExample.uploadFile( request: .init( - file: .init(data: Data("".utf8)), - name: "name" + name: "name", + file: .init(data: Data("".utf8)) ), requestOptions: RequestOptions(maxRetries: 5, additionalHeaders: stub.headers) ) @@ -391,8 +391,8 @@ import Testing do { _ = try await client.fileUploadExample.uploadFile( request: .init( - file: .init(data: Data("".utf8)), - name: "name" + name: "name", + file: .init(data: Data("".utf8)) ), requestOptions: RequestOptions(maxRetries: 0, additionalHeaders: stub.headers) ) @@ -420,8 +420,8 @@ import Testing do { _ = try await client.fileUploadExample.uploadFile( request: .init( - file: .init(data: Data("".utf8)), - name: "name" + name: "name", + file: .init(data: Data("".utf8)) ), requestOptions: RequestOptions(additionalHeaders: stub.headers) ) diff --git a/seed/swift-sdk/file-upload-openapi/Tests/Snippets/Example0.swift b/seed/swift-sdk/file-upload-openapi/Tests/Snippets/Example0.swift index abee2f0339c0..047798db29ba 100644 --- a/seed/swift-sdk/file-upload-openapi/Tests/Snippets/Example0.swift +++ b/seed/swift-sdk/file-upload-openapi/Tests/Snippets/Example0.swift @@ -6,8 +6,8 @@ enum Example0 { let client = ApiClient(baseURL: "https://api.fern.com") _ = try await client.fileUploadExample.uploadFile(request: .init( - file: .init(data: Data("".utf8)), - name: "name" + name: "name", + file: .init(data: Data("".utf8)) )) } } diff --git a/seed/swift-sdk/file-upload-openapi/Tests/Wire/Resources/FileUploadExample/FileUploadExampleClientWireTests.swift b/seed/swift-sdk/file-upload-openapi/Tests/Wire/Resources/FileUploadExample/FileUploadExampleClientWireTests.swift index e3df89b00fc3..26f2a27318a4 100644 --- a/seed/swift-sdk/file-upload-openapi/Tests/Wire/Resources/FileUploadExample/FileUploadExampleClientWireTests.swift +++ b/seed/swift-sdk/file-upload-openapi/Tests/Wire/Resources/FileUploadExample/FileUploadExampleClientWireTests.swift @@ -19,8 +19,8 @@ import Api let expectedResponse = "string" let response = try await client.fileUploadExample.uploadFile( request: .init( - file: .init(data: Data("".utf8)), - name: "name" + name: "name", + file: .init(data: Data("".utf8)) ), requestOptions: RequestOptions(additionalHeaders: stub.headers) ) diff --git a/seed/swift-sdk/file-upload-openapi/reference.md b/seed/swift-sdk/file-upload-openapi/reference.md index e3aa1ac08e8f..6acfa038073b 100644 --- a/seed/swift-sdk/file-upload-openapi/reference.md +++ b/seed/swift-sdk/file-upload-openapi/reference.md @@ -34,8 +34,8 @@ private func main() async throws { let client = ApiClient() _ = try await client.fileUploadExample.uploadFile(request: .init( - file: .init(data: Data("".utf8)), - name: "name" + name: "name", + file: .init(data: Data("".utf8)) )) } diff --git a/seed/swift-sdk/idempotency-headers/Tests/Wire/Resources/Payment/PaymentClientWireTests.swift b/seed/swift-sdk/idempotency-headers/Tests/Wire/Resources/Payment/PaymentClientWireTests.swift index 4844ac6eecd1..bcfcb272169c 100644 --- a/seed/swift-sdk/idempotency-headers/Tests/Wire/Resources/Payment/PaymentClientWireTests.swift +++ b/seed/swift-sdk/idempotency-headers/Tests/Wire/Resources/Payment/PaymentClientWireTests.swift @@ -8,7 +8,7 @@ import IdempotencyHeaders stub.setResponse( body: Data( #""" - d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32 + "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32" """#.utf8 ) ) diff --git a/seed/swift-sdk/inferred-auth-explicit/README.md b/seed/swift-sdk/inferred-auth-explicit/README.md index 2c8809638534..c55b3c33f5ec 100644 --- a/seed/swift-sdk/inferred-auth-explicit/README.md +++ b/seed/swift-sdk/inferred-auth-explicit/README.md @@ -54,13 +54,16 @@ import InferredAuthExplicit private func main() async throws { let client = InferredAuthExplicitClient() - _ = try await client.auth.getTokenWithClientCredentials(request: .init( - clientId: "client_id", - clientSecret: "client_secret", - audience: .httpsApiExampleCom, - grantType: .clientCredentials, - scope: "scope" - )) + _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", + request: .init( + clientId: "client_id", + clientSecret: "client_secret", + audience: .httpsApiExampleCom, + grantType: .clientCredentials, + scope: "scope" + ) + ) } try await main() diff --git a/seed/swift-sdk/inferred-auth-explicit/Tests/Core/ClientErrorTests.swift b/seed/swift-sdk/inferred-auth-explicit/Tests/Core/ClientErrorTests.swift index b20ca95d5838..1f6f22dd0162 100644 --- a/seed/swift-sdk/inferred-auth-explicit/Tests/Core/ClientErrorTests.swift +++ b/seed/swift-sdk/inferred-auth-explicit/Tests/Core/ClientErrorTests.swift @@ -20,6 +20,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -59,6 +60,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -98,6 +100,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -139,6 +142,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -178,6 +182,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -219,6 +224,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -258,6 +264,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", diff --git a/seed/swift-sdk/inferred-auth-explicit/Tests/Core/ClientRetryTests.swift b/seed/swift-sdk/inferred-auth-explicit/Tests/Core/ClientRetryTests.swift index e7d4c779f051..49df9823337f 100644 --- a/seed/swift-sdk/inferred-auth-explicit/Tests/Core/ClientRetryTests.swift +++ b/seed/swift-sdk/inferred-auth-explicit/Tests/Core/ClientRetryTests.swift @@ -21,6 +21,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -54,6 +55,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -87,6 +89,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -119,6 +122,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -150,6 +154,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -182,6 +187,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -214,6 +220,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -251,6 +258,7 @@ import Testing let startTime = Date() do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -298,6 +306,7 @@ import Testing let startTime = Date() do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -341,6 +350,7 @@ import Testing let startTime = Date() do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -395,6 +405,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -423,6 +434,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -455,6 +467,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", diff --git a/seed/swift-sdk/inferred-auth-explicit/Tests/Snippets/Example0.swift b/seed/swift-sdk/inferred-auth-explicit/Tests/Snippets/Example0.swift index 23cfb8cec988..da38297f3194 100644 --- a/seed/swift-sdk/inferred-auth-explicit/Tests/Snippets/Example0.swift +++ b/seed/swift-sdk/inferred-auth-explicit/Tests/Snippets/Example0.swift @@ -5,12 +5,15 @@ enum Example0 { static func snippet() async throws { let client = InferredAuthExplicitClient(baseURL: "https://api.fern.com") - _ = try await client.auth.getTokenWithClientCredentials(request: .init( - clientId: "client_id", - clientSecret: "client_secret", - audience: .httpsApiExampleCom, - grantType: .clientCredentials, - scope: "scope" - )) + _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", + request: .init( + clientId: "client_id", + clientSecret: "client_secret", + audience: .httpsApiExampleCom, + grantType: .clientCredentials, + scope: "scope" + ) + ) } } diff --git a/seed/swift-sdk/inferred-auth-explicit/Tests/Snippets/Example1.swift b/seed/swift-sdk/inferred-auth-explicit/Tests/Snippets/Example1.swift index c71f2b380219..8ded805b353b 100644 --- a/seed/swift-sdk/inferred-auth-explicit/Tests/Snippets/Example1.swift +++ b/seed/swift-sdk/inferred-auth-explicit/Tests/Snippets/Example1.swift @@ -5,13 +5,16 @@ enum Example1 { static func snippet() async throws { let client = InferredAuthExplicitClient(baseURL: "https://api.fern.com") - _ = try await client.auth.refreshToken(request: .init( - clientId: "client_id", - clientSecret: "client_secret", - refreshToken: "refresh_token", - audience: .httpsApiExampleCom, - grantType: .refreshToken, - scope: "scope" - )) + _ = try await client.auth.refreshToken( + xApiKey: "X-Api-Key", + request: .init( + clientId: "client_id", + clientSecret: "client_secret", + refreshToken: "refresh_token", + audience: .httpsApiExampleCom, + grantType: .refreshToken, + scope: "scope" + ) + ) } } diff --git a/seed/swift-sdk/inferred-auth-explicit/Tests/Wire/Resources/Auth/AuthClientWireTests.swift b/seed/swift-sdk/inferred-auth-explicit/Tests/Wire/Resources/Auth/AuthClientWireTests.swift index 108f6f99c1f8..29362674c9da 100644 --- a/seed/swift-sdk/inferred-auth-explicit/Tests/Wire/Resources/Auth/AuthClientWireTests.swift +++ b/seed/swift-sdk/inferred-auth-explicit/Tests/Wire/Resources/Auth/AuthClientWireTests.swift @@ -26,6 +26,7 @@ import InferredAuthExplicit refreshToken: Optional("refresh_token") ) let response = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -61,6 +62,7 @@ import InferredAuthExplicit refreshToken: Optional("refresh_token") ) let response = try await client.auth.refreshToken( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", diff --git a/seed/swift-sdk/inferred-auth-explicit/reference.md b/seed/swift-sdk/inferred-auth-explicit/reference.md index 38a6b2a1819b..21a801cc83a5 100644 --- a/seed/swift-sdk/inferred-auth-explicit/reference.md +++ b/seed/swift-sdk/inferred-auth-explicit/reference.md @@ -19,13 +19,16 @@ import InferredAuthExplicit private func main() async throws { let client = InferredAuthExplicitClient() - _ = try await client.auth.getTokenWithClientCredentials(request: .init( - clientId: "client_id", - clientSecret: "client_secret", - audience: .httpsApiExampleCom, - grantType: .clientCredentials, - scope: "scope" - )) + _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", + request: .init( + clientId: "client_id", + clientSecret: "client_secret", + audience: .httpsApiExampleCom, + grantType: .clientCredentials, + scope: "scope" + ) + ) } try await main() @@ -90,14 +93,17 @@ import InferredAuthExplicit private func main() async throws { let client = InferredAuthExplicitClient() - _ = try await client.auth.refreshToken(request: .init( - clientId: "client_id", - clientSecret: "client_secret", - refreshToken: "refresh_token", - audience: .httpsApiExampleCom, - grantType: .refreshToken, - scope: "scope" - )) + _ = try await client.auth.refreshToken( + xApiKey: "X-Api-Key", + request: .init( + clientId: "client_id", + clientSecret: "client_secret", + refreshToken: "refresh_token", + audience: .httpsApiExampleCom, + grantType: .refreshToken, + scope: "scope" + ) + ) } try await main() diff --git a/seed/swift-sdk/inferred-auth-implicit-api-key/README.md b/seed/swift-sdk/inferred-auth-implicit-api-key/README.md index d2b0abe075f1..b4791e08c9b9 100644 --- a/seed/swift-sdk/inferred-auth-implicit-api-key/README.md +++ b/seed/swift-sdk/inferred-auth-implicit-api-key/README.md @@ -53,7 +53,7 @@ import InferredAuthImplicitApiKey private func main() async throws { let client = InferredAuthImplicitApiKeyClient() - _ = try await client.auth.getToken() + _ = try await client.auth.getToken(apiKey: "api_key") } try await main() diff --git a/seed/swift-sdk/inferred-auth-implicit-api-key/Tests/Core/ClientErrorTests.swift b/seed/swift-sdk/inferred-auth-implicit-api-key/Tests/Core/ClientErrorTests.swift index 83ddfc7e30fb..10369fb8bf46 100644 --- a/seed/swift-sdk/inferred-auth-implicit-api-key/Tests/Core/ClientErrorTests.swift +++ b/seed/swift-sdk/inferred-auth-implicit-api-key/Tests/Core/ClientErrorTests.swift @@ -19,7 +19,10 @@ import Testing ) do { - _ = try await client.auth.getToken(requestOptions: RequestOptions(additionalHeaders: stub.headers)) + _ = try await client.auth.getToken( + apiKey: "api_key", + requestOptions: RequestOptions(additionalHeaders: stub.headers) + ) Issue.record("Expected error to be thrown") } catch let error as InferredAuthImplicitApiKeyError { @@ -49,7 +52,10 @@ import Testing ) do { - _ = try await client.auth.getToken(requestOptions: RequestOptions(additionalHeaders: stub.headers)) + _ = try await client.auth.getToken( + apiKey: "api_key", + requestOptions: RequestOptions(additionalHeaders: stub.headers) + ) Issue.record("Expected error to be thrown") } catch let error as InferredAuthImplicitApiKeyError { @@ -79,7 +85,10 @@ import Testing ) do { - _ = try await client.auth.getToken(requestOptions: RequestOptions(additionalHeaders: stub.headers)) + _ = try await client.auth.getToken( + apiKey: "api_key", + requestOptions: RequestOptions(additionalHeaders: stub.headers) + ) Issue.record("Expected error to be thrown") } catch let error as InferredAuthImplicitApiKeyError { @@ -111,7 +120,10 @@ import Testing ) do { - _ = try await client.auth.getToken(requestOptions: RequestOptions(additionalHeaders: stub.headers)) + _ = try await client.auth.getToken( + apiKey: "api_key", + requestOptions: RequestOptions(additionalHeaders: stub.headers) + ) Issue.record("Expected error to be thrown") } catch let error as InferredAuthImplicitApiKeyError { @@ -141,7 +153,10 @@ import Testing ) do { - _ = try await client.auth.getToken(requestOptions: RequestOptions(additionalHeaders: stub.headers)) + _ = try await client.auth.getToken( + apiKey: "api_key", + requestOptions: RequestOptions(additionalHeaders: stub.headers) + ) Issue.record("Expected error to be thrown") } catch let error as InferredAuthImplicitApiKeyError { @@ -173,7 +188,10 @@ import Testing ) do { - _ = try await client.auth.getToken(requestOptions: RequestOptions(additionalHeaders: stub.headers)) + _ = try await client.auth.getToken( + apiKey: "api_key", + requestOptions: RequestOptions(additionalHeaders: stub.headers) + ) Issue.record("Expected error to be thrown") } catch let error as InferredAuthImplicitApiKeyError { @@ -203,7 +221,10 @@ import Testing ) do { - _ = try await client.auth.getToken(requestOptions: RequestOptions(additionalHeaders: stub.headers)) + _ = try await client.auth.getToken( + apiKey: "api_key", + requestOptions: RequestOptions(additionalHeaders: stub.headers) + ) Issue.record("Expected error to be thrown") } catch let error as InferredAuthImplicitApiKeyError { diff --git a/seed/swift-sdk/inferred-auth-implicit-api-key/Tests/Core/ClientRetryTests.swift b/seed/swift-sdk/inferred-auth-implicit-api-key/Tests/Core/ClientRetryTests.swift index bbd727568c1c..278da9c059e8 100644 --- a/seed/swift-sdk/inferred-auth-implicit-api-key/Tests/Core/ClientRetryTests.swift +++ b/seed/swift-sdk/inferred-auth-implicit-api-key/Tests/Core/ClientRetryTests.swift @@ -20,7 +20,10 @@ import Testing ) do { - _ = try await client.auth.getToken(requestOptions: RequestOptions(additionalHeaders: stub.headers)) + _ = try await client.auth.getToken( + apiKey: "api_key", + requestOptions: RequestOptions(additionalHeaders: stub.headers) + ) } catch { } @@ -44,7 +47,10 @@ import Testing ) do { - _ = try await client.auth.getToken(requestOptions: RequestOptions(additionalHeaders: stub.headers)) + _ = try await client.auth.getToken( + apiKey: "api_key", + requestOptions: RequestOptions(additionalHeaders: stub.headers) + ) } catch { } @@ -68,7 +74,10 @@ import Testing ) do { - _ = try await client.auth.getToken(requestOptions: RequestOptions(additionalHeaders: stub.headers)) + _ = try await client.auth.getToken( + apiKey: "api_key", + requestOptions: RequestOptions(additionalHeaders: stub.headers) + ) } catch { } @@ -91,7 +100,10 @@ import Testing ) do { - _ = try await client.auth.getToken(requestOptions: RequestOptions(additionalHeaders: stub.headers)) + _ = try await client.auth.getToken( + apiKey: "api_key", + requestOptions: RequestOptions(additionalHeaders: stub.headers) + ) } catch { } @@ -113,7 +125,10 @@ import Testing ) do { - _ = try await client.auth.getToken(requestOptions: RequestOptions(additionalHeaders: stub.headers)) + _ = try await client.auth.getToken( + apiKey: "api_key", + requestOptions: RequestOptions(additionalHeaders: stub.headers) + ) Issue.record("Expected error to be thrown") } catch { @@ -136,7 +151,10 @@ import Testing ) do { - _ = try await client.auth.getToken(requestOptions: RequestOptions(additionalHeaders: stub.headers)) + _ = try await client.auth.getToken( + apiKey: "api_key", + requestOptions: RequestOptions(additionalHeaders: stub.headers) + ) Issue.record("Expected error to be thrown") } catch { @@ -159,7 +177,10 @@ import Testing ) do { - _ = try await client.auth.getToken(requestOptions: RequestOptions(additionalHeaders: stub.headers)) + _ = try await client.auth.getToken( + apiKey: "api_key", + requestOptions: RequestOptions(additionalHeaders: stub.headers) + ) Issue.record("Expected error to be thrown") } catch { @@ -187,7 +208,10 @@ import Testing let startTime = Date() do { - _ = try await client.auth.getToken(requestOptions: RequestOptions(additionalHeaders: stub.headers)) + _ = try await client.auth.getToken( + apiKey: "api_key", + requestOptions: RequestOptions(additionalHeaders: stub.headers) + ) } catch { } @@ -225,7 +249,10 @@ import Testing let startTime = Date() do { - _ = try await client.auth.getToken(requestOptions: RequestOptions(additionalHeaders: stub.headers)) + _ = try await client.auth.getToken( + apiKey: "api_key", + requestOptions: RequestOptions(additionalHeaders: stub.headers) + ) } catch { } @@ -259,7 +286,10 @@ import Testing let startTime = Date() do { - _ = try await client.auth.getToken(requestOptions: RequestOptions(additionalHeaders: stub.headers)) + _ = try await client.auth.getToken( + apiKey: "api_key", + requestOptions: RequestOptions(additionalHeaders: stub.headers) + ) } catch { } @@ -304,7 +334,10 @@ import Testing ) do { - _ = try await client.auth.getToken(requestOptions: RequestOptions(maxRetries: 5, additionalHeaders: stub.headers)) + _ = try await client.auth.getToken( + apiKey: "api_key", + requestOptions: RequestOptions(maxRetries: 5, additionalHeaders: stub.headers) + ) } catch { } @@ -323,7 +356,10 @@ import Testing ) do { - _ = try await client.auth.getToken(requestOptions: RequestOptions(maxRetries: 0, additionalHeaders: stub.headers)) + _ = try await client.auth.getToken( + apiKey: "api_key", + requestOptions: RequestOptions(maxRetries: 0, additionalHeaders: stub.headers) + ) Issue.record("Expected error to be thrown") } catch { @@ -346,7 +382,10 @@ import Testing ) do { - _ = try await client.auth.getToken(requestOptions: RequestOptions(additionalHeaders: stub.headers)) + _ = try await client.auth.getToken( + apiKey: "api_key", + requestOptions: RequestOptions(additionalHeaders: stub.headers) + ) } catch { } diff --git a/seed/swift-sdk/inferred-auth-implicit-api-key/Tests/Snippets/Example0.swift b/seed/swift-sdk/inferred-auth-implicit-api-key/Tests/Snippets/Example0.swift index 972424bb1b67..ac4426874b5f 100644 --- a/seed/swift-sdk/inferred-auth-implicit-api-key/Tests/Snippets/Example0.swift +++ b/seed/swift-sdk/inferred-auth-implicit-api-key/Tests/Snippets/Example0.swift @@ -5,6 +5,6 @@ enum Example0 { static func snippet() async throws { let client = InferredAuthImplicitApiKeyClient(baseURL: "https://api.fern.com") - _ = try await client.auth.getToken() + _ = try await client.auth.getToken(apiKey: "api_key") } } diff --git a/seed/swift-sdk/inferred-auth-implicit-api-key/Tests/Wire/Resources/Auth/AuthClientWireTests.swift b/seed/swift-sdk/inferred-auth-implicit-api-key/Tests/Wire/Resources/Auth/AuthClientWireTests.swift index 5bcf3737f6e8..6aca923c83b2 100644 --- a/seed/swift-sdk/inferred-auth-implicit-api-key/Tests/Wire/Resources/Auth/AuthClientWireTests.swift +++ b/seed/swift-sdk/inferred-auth-implicit-api-key/Tests/Wire/Resources/Auth/AuthClientWireTests.swift @@ -27,7 +27,10 @@ import InferredAuthImplicitApiKey expiresIn: 1, scope: Optional("scope") ) - let response = try await client.auth.getToken(requestOptions: RequestOptions(additionalHeaders: stub.headers)) + let response = try await client.auth.getToken( + apiKey: "api_key", + requestOptions: RequestOptions(additionalHeaders: stub.headers) + ) try #require(response == expectedResponse) } } \ No newline at end of file diff --git a/seed/swift-sdk/inferred-auth-implicit-api-key/reference.md b/seed/swift-sdk/inferred-auth-implicit-api-key/reference.md index 5b97b15b309d..1249ef7f626b 100644 --- a/seed/swift-sdk/inferred-auth-implicit-api-key/reference.md +++ b/seed/swift-sdk/inferred-auth-implicit-api-key/reference.md @@ -19,7 +19,7 @@ import InferredAuthImplicitApiKey private func main() async throws { let client = InferredAuthImplicitApiKeyClient() - _ = try await client.auth.getToken() + _ = try await client.auth.getToken(apiKey: "api_key") } try await main() diff --git a/seed/swift-sdk/inferred-auth-implicit-no-expiry/README.md b/seed/swift-sdk/inferred-auth-implicit-no-expiry/README.md index 86b115adcc47..53d60ecc66a9 100644 --- a/seed/swift-sdk/inferred-auth-implicit-no-expiry/README.md +++ b/seed/swift-sdk/inferred-auth-implicit-no-expiry/README.md @@ -54,13 +54,16 @@ import InferredAuthImplicitNoExpiry private func main() async throws { let client = InferredAuthImplicitNoExpiryClient() - _ = try await client.auth.getTokenWithClientCredentials(request: .init( - clientId: "client_id", - clientSecret: "client_secret", - audience: .httpsApiExampleCom, - grantType: .clientCredentials, - scope: "scope" - )) + _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", + request: .init( + clientId: "client_id", + clientSecret: "client_secret", + audience: .httpsApiExampleCom, + grantType: .clientCredentials, + scope: "scope" + ) + ) } try await main() diff --git a/seed/swift-sdk/inferred-auth-implicit-no-expiry/Tests/Core/ClientErrorTests.swift b/seed/swift-sdk/inferred-auth-implicit-no-expiry/Tests/Core/ClientErrorTests.swift index f4a5265e53ba..0061651b9862 100644 --- a/seed/swift-sdk/inferred-auth-implicit-no-expiry/Tests/Core/ClientErrorTests.swift +++ b/seed/swift-sdk/inferred-auth-implicit-no-expiry/Tests/Core/ClientErrorTests.swift @@ -20,6 +20,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -59,6 +60,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -98,6 +100,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -139,6 +142,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -178,6 +182,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -219,6 +224,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -258,6 +264,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", diff --git a/seed/swift-sdk/inferred-auth-implicit-no-expiry/Tests/Core/ClientRetryTests.swift b/seed/swift-sdk/inferred-auth-implicit-no-expiry/Tests/Core/ClientRetryTests.swift index 40611e1c507a..2059648eb04a 100644 --- a/seed/swift-sdk/inferred-auth-implicit-no-expiry/Tests/Core/ClientRetryTests.swift +++ b/seed/swift-sdk/inferred-auth-implicit-no-expiry/Tests/Core/ClientRetryTests.swift @@ -21,6 +21,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -54,6 +55,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -87,6 +89,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -119,6 +122,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -150,6 +154,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -182,6 +187,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -214,6 +220,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -251,6 +258,7 @@ import Testing let startTime = Date() do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -298,6 +306,7 @@ import Testing let startTime = Date() do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -341,6 +350,7 @@ import Testing let startTime = Date() do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -395,6 +405,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -423,6 +434,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -455,6 +467,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", diff --git a/seed/swift-sdk/inferred-auth-implicit-no-expiry/Tests/Snippets/Example0.swift b/seed/swift-sdk/inferred-auth-implicit-no-expiry/Tests/Snippets/Example0.swift index 85c532884de4..abdb0d368af6 100644 --- a/seed/swift-sdk/inferred-auth-implicit-no-expiry/Tests/Snippets/Example0.swift +++ b/seed/swift-sdk/inferred-auth-implicit-no-expiry/Tests/Snippets/Example0.swift @@ -5,12 +5,15 @@ enum Example0 { static func snippet() async throws { let client = InferredAuthImplicitNoExpiryClient(baseURL: "https://api.fern.com") - _ = try await client.auth.getTokenWithClientCredentials(request: .init( - clientId: "client_id", - clientSecret: "client_secret", - audience: .httpsApiExampleCom, - grantType: .clientCredentials, - scope: "scope" - )) + _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", + request: .init( + clientId: "client_id", + clientSecret: "client_secret", + audience: .httpsApiExampleCom, + grantType: .clientCredentials, + scope: "scope" + ) + ) } } diff --git a/seed/swift-sdk/inferred-auth-implicit-no-expiry/Tests/Snippets/Example1.swift b/seed/swift-sdk/inferred-auth-implicit-no-expiry/Tests/Snippets/Example1.swift index 518374ea22a0..063c4626c7b0 100644 --- a/seed/swift-sdk/inferred-auth-implicit-no-expiry/Tests/Snippets/Example1.swift +++ b/seed/swift-sdk/inferred-auth-implicit-no-expiry/Tests/Snippets/Example1.swift @@ -5,13 +5,16 @@ enum Example1 { static func snippet() async throws { let client = InferredAuthImplicitNoExpiryClient(baseURL: "https://api.fern.com") - _ = try await client.auth.refreshToken(request: .init( - clientId: "client_id", - clientSecret: "client_secret", - refreshToken: "refresh_token", - audience: .httpsApiExampleCom, - grantType: .refreshToken, - scope: "scope" - )) + _ = try await client.auth.refreshToken( + xApiKey: "X-Api-Key", + request: .init( + clientId: "client_id", + clientSecret: "client_secret", + refreshToken: "refresh_token", + audience: .httpsApiExampleCom, + grantType: .refreshToken, + scope: "scope" + ) + ) } } diff --git a/seed/swift-sdk/inferred-auth-implicit-no-expiry/Tests/Wire/Resources/Auth/AuthClientWireTests.swift b/seed/swift-sdk/inferred-auth-implicit-no-expiry/Tests/Wire/Resources/Auth/AuthClientWireTests.swift index 093311820392..7555a2263d38 100644 --- a/seed/swift-sdk/inferred-auth-implicit-no-expiry/Tests/Wire/Resources/Auth/AuthClientWireTests.swift +++ b/seed/swift-sdk/inferred-auth-implicit-no-expiry/Tests/Wire/Resources/Auth/AuthClientWireTests.swift @@ -24,6 +24,7 @@ import InferredAuthImplicitNoExpiry refreshToken: Optional("refresh_token") ) let response = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -57,6 +58,7 @@ import InferredAuthImplicitNoExpiry refreshToken: Optional("refresh_token") ) let response = try await client.auth.refreshToken( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", diff --git a/seed/swift-sdk/inferred-auth-implicit-no-expiry/reference.md b/seed/swift-sdk/inferred-auth-implicit-no-expiry/reference.md index fdd61227d663..c87e37881472 100644 --- a/seed/swift-sdk/inferred-auth-implicit-no-expiry/reference.md +++ b/seed/swift-sdk/inferred-auth-implicit-no-expiry/reference.md @@ -19,13 +19,16 @@ import InferredAuthImplicitNoExpiry private func main() async throws { let client = InferredAuthImplicitNoExpiryClient() - _ = try await client.auth.getTokenWithClientCredentials(request: .init( - clientId: "client_id", - clientSecret: "client_secret", - audience: .httpsApiExampleCom, - grantType: .clientCredentials, - scope: "scope" - )) + _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", + request: .init( + clientId: "client_id", + clientSecret: "client_secret", + audience: .httpsApiExampleCom, + grantType: .clientCredentials, + scope: "scope" + ) + ) } try await main() @@ -90,14 +93,17 @@ import InferredAuthImplicitNoExpiry private func main() async throws { let client = InferredAuthImplicitNoExpiryClient() - _ = try await client.auth.refreshToken(request: .init( - clientId: "client_id", - clientSecret: "client_secret", - refreshToken: "refresh_token", - audience: .httpsApiExampleCom, - grantType: .refreshToken, - scope: "scope" - )) + _ = try await client.auth.refreshToken( + xApiKey: "X-Api-Key", + request: .init( + clientId: "client_id", + clientSecret: "client_secret", + refreshToken: "refresh_token", + audience: .httpsApiExampleCom, + grantType: .refreshToken, + scope: "scope" + ) + ) } try await main() diff --git a/seed/swift-sdk/inferred-auth-implicit/README.md b/seed/swift-sdk/inferred-auth-implicit/README.md index 0341a2d1613f..6ed89899e08c 100644 --- a/seed/swift-sdk/inferred-auth-implicit/README.md +++ b/seed/swift-sdk/inferred-auth-implicit/README.md @@ -54,13 +54,16 @@ import InferredAuthImplicit private func main() async throws { let client = InferredAuthImplicitClient() - _ = try await client.auth.getTokenWithClientCredentials(request: .init( - clientId: "client_id", - clientSecret: "client_secret", - audience: .httpsApiExampleCom, - grantType: .clientCredentials, - scope: "scope" - )) + _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", + request: .init( + clientId: "client_id", + clientSecret: "client_secret", + audience: .httpsApiExampleCom, + grantType: .clientCredentials, + scope: "scope" + ) + ) } try await main() diff --git a/seed/swift-sdk/inferred-auth-implicit/Tests/Core/ClientErrorTests.swift b/seed/swift-sdk/inferred-auth-implicit/Tests/Core/ClientErrorTests.swift index fef8aa4c0ca3..ae45bcaf06ed 100644 --- a/seed/swift-sdk/inferred-auth-implicit/Tests/Core/ClientErrorTests.swift +++ b/seed/swift-sdk/inferred-auth-implicit/Tests/Core/ClientErrorTests.swift @@ -20,6 +20,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -59,6 +60,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -98,6 +100,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -139,6 +142,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -178,6 +182,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -219,6 +224,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -258,6 +264,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", diff --git a/seed/swift-sdk/inferred-auth-implicit/Tests/Core/ClientRetryTests.swift b/seed/swift-sdk/inferred-auth-implicit/Tests/Core/ClientRetryTests.swift index f0edcc62c5a8..34a6578022ff 100644 --- a/seed/swift-sdk/inferred-auth-implicit/Tests/Core/ClientRetryTests.swift +++ b/seed/swift-sdk/inferred-auth-implicit/Tests/Core/ClientRetryTests.swift @@ -21,6 +21,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -54,6 +55,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -87,6 +89,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -119,6 +122,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -150,6 +154,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -182,6 +187,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -214,6 +220,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -251,6 +258,7 @@ import Testing let startTime = Date() do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -298,6 +306,7 @@ import Testing let startTime = Date() do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -341,6 +350,7 @@ import Testing let startTime = Date() do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -395,6 +405,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -423,6 +434,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -455,6 +467,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", diff --git a/seed/swift-sdk/inferred-auth-implicit/Tests/Snippets/Example0.swift b/seed/swift-sdk/inferred-auth-implicit/Tests/Snippets/Example0.swift index 36329a8d0c7e..97daf8282402 100644 --- a/seed/swift-sdk/inferred-auth-implicit/Tests/Snippets/Example0.swift +++ b/seed/swift-sdk/inferred-auth-implicit/Tests/Snippets/Example0.swift @@ -5,12 +5,15 @@ enum Example0 { static func snippet() async throws { let client = InferredAuthImplicitClient(baseURL: "https://api.fern.com") - _ = try await client.auth.getTokenWithClientCredentials(request: .init( - clientId: "client_id", - clientSecret: "client_secret", - audience: .httpsApiExampleCom, - grantType: .clientCredentials, - scope: "scope" - )) + _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", + request: .init( + clientId: "client_id", + clientSecret: "client_secret", + audience: .httpsApiExampleCom, + grantType: .clientCredentials, + scope: "scope" + ) + ) } } diff --git a/seed/swift-sdk/inferred-auth-implicit/Tests/Snippets/Example1.swift b/seed/swift-sdk/inferred-auth-implicit/Tests/Snippets/Example1.swift index 4b7f4bc0d12b..52c913242b79 100644 --- a/seed/swift-sdk/inferred-auth-implicit/Tests/Snippets/Example1.swift +++ b/seed/swift-sdk/inferred-auth-implicit/Tests/Snippets/Example1.swift @@ -5,13 +5,16 @@ enum Example1 { static func snippet() async throws { let client = InferredAuthImplicitClient(baseURL: "https://api.fern.com") - _ = try await client.auth.refreshToken(request: .init( - clientId: "client_id", - clientSecret: "client_secret", - refreshToken: "refresh_token", - audience: .httpsApiExampleCom, - grantType: .refreshToken, - scope: "scope" - )) + _ = try await client.auth.refreshToken( + xApiKey: "X-Api-Key", + request: .init( + clientId: "client_id", + clientSecret: "client_secret", + refreshToken: "refresh_token", + audience: .httpsApiExampleCom, + grantType: .refreshToken, + scope: "scope" + ) + ) } } diff --git a/seed/swift-sdk/inferred-auth-implicit/Tests/Wire/Resources/Auth/AuthClientWireTests.swift b/seed/swift-sdk/inferred-auth-implicit/Tests/Wire/Resources/Auth/AuthClientWireTests.swift index 5e4e71f57f73..5c4df62bc328 100644 --- a/seed/swift-sdk/inferred-auth-implicit/Tests/Wire/Resources/Auth/AuthClientWireTests.swift +++ b/seed/swift-sdk/inferred-auth-implicit/Tests/Wire/Resources/Auth/AuthClientWireTests.swift @@ -26,6 +26,7 @@ import InferredAuthImplicit refreshToken: Optional("refresh_token") ) let response = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -61,6 +62,7 @@ import InferredAuthImplicit refreshToken: Optional("refresh_token") ) let response = try await client.auth.refreshToken( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", diff --git a/seed/swift-sdk/inferred-auth-implicit/reference.md b/seed/swift-sdk/inferred-auth-implicit/reference.md index 491883c2a65d..b366df704081 100644 --- a/seed/swift-sdk/inferred-auth-implicit/reference.md +++ b/seed/swift-sdk/inferred-auth-implicit/reference.md @@ -19,13 +19,16 @@ import InferredAuthImplicit private func main() async throws { let client = InferredAuthImplicitClient() - _ = try await client.auth.getTokenWithClientCredentials(request: .init( - clientId: "client_id", - clientSecret: "client_secret", - audience: .httpsApiExampleCom, - grantType: .clientCredentials, - scope: "scope" - )) + _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", + request: .init( + clientId: "client_id", + clientSecret: "client_secret", + audience: .httpsApiExampleCom, + grantType: .clientCredentials, + scope: "scope" + ) + ) } try await main() @@ -90,14 +93,17 @@ import InferredAuthImplicit private func main() async throws { let client = InferredAuthImplicitClient() - _ = try await client.auth.refreshToken(request: .init( - clientId: "client_id", - clientSecret: "client_secret", - refreshToken: "refresh_token", - audience: .httpsApiExampleCom, - grantType: .refreshToken, - scope: "scope" - )) + _ = try await client.auth.refreshToken( + xApiKey: "X-Api-Key", + request: .init( + clientId: "client_id", + clientSecret: "client_secret", + refreshToken: "refresh_token", + audience: .httpsApiExampleCom, + grantType: .refreshToken, + scope: "scope" + ) + ) } try await main() diff --git a/seed/swift-sdk/literal/Sources/Requests/Requests+SendLiteralsInlinedRequest.swift b/seed/swift-sdk/literal/Sources/Requests/Requests+SendLiteralsInlinedRequest.swift index 146323c3b1c0..f5d9e2e8f5fe 100644 --- a/seed/swift-sdk/literal/Sources/Requests/Requests+SendLiteralsInlinedRequest.swift +++ b/seed/swift-sdk/literal/Sources/Requests/Requests+SendLiteralsInlinedRequest.swift @@ -6,7 +6,7 @@ extension Requests { public let context: YoureSuperWise? public let query: String public let temperature: Double? - public let stream: JSONValue + public let stream: Bool public let aliasedContext: SomeAliasedLiteral public let maybeContext: SomeAliasedLiteral? public let objectWithLiteral: ATopLevelLiteral @@ -18,7 +18,7 @@ extension Requests { context: YoureSuperWise? = nil, query: String, temperature: Double? = nil, - stream: JSONValue, + stream: Bool, aliasedContext: SomeAliasedLiteral, maybeContext: SomeAliasedLiteral? = nil, objectWithLiteral: ATopLevelLiteral, @@ -41,7 +41,7 @@ extension Requests { self.context = try container.decodeIfPresent(YoureSuperWise.self, forKey: .context) self.query = try container.decode(String.self, forKey: .query) self.temperature = try container.decodeIfPresent(Double.self, forKey: .temperature) - self.stream = try container.decode(JSONValue.self, forKey: .stream) + self.stream = try container.decode(Bool.self, forKey: .stream) self.aliasedContext = try container.decode(SomeAliasedLiteral.self, forKey: .aliasedContext) self.maybeContext = try container.decodeIfPresent(SomeAliasedLiteral.self, forKey: .maybeContext) self.objectWithLiteral = try container.decode(ATopLevelLiteral.self, forKey: .objectWithLiteral) diff --git a/seed/swift-sdk/literal/Sources/Resources/Query/QueryClient.swift b/seed/swift-sdk/literal/Sources/Resources/Query/QueryClient.swift index f0237547034f..32ceb33812c0 100644 --- a/seed/swift-sdk/literal/Sources/Resources/Query/QueryClient.swift +++ b/seed/swift-sdk/literal/Sources/Resources/Query/QueryClient.swift @@ -7,23 +7,27 @@ public final class QueryClient: Sendable { self.httpClient = HTTPClient(config: config) } - public func send(prompt: JSONValue, optionalPrompt: JSONValue? = nil, aliasPrompt: AliasToPrompt, aliasOptionalPrompt: AliasToPrompt? = nil, query: String, stream: JSONValue, optionalStream: JSONValue? = nil, aliasStream: AliasToStream, aliasOptionalStream: AliasToStream? = nil, requestOptions: RequestOptions? = nil) async throws -> SendResponse { + public func send(prompt: YouAreAHelpfulAssistant, optionalPrompt: YouAreAHelpfulAssistant? = nil, aliasPrompt: AliasToPrompt, aliasOptionalPrompt: AliasToPrompt? = nil, query: String, stream: Bool, optionalStream: Bool? = nil, aliasStream: AliasToStream, aliasOptionalStream: AliasToStream? = nil, requestOptions: RequestOptions? = nil) async throws -> SendResponse { return try await httpClient.performRequest( method: .post, path: "/query", queryParams: [ - "prompt": .unknown(prompt), - "optional_prompt": optionalPrompt.map { .unknown($0) }, - "alias_prompt": .unknown(aliasPrompt), + "prompt": .string(prompt.rawValue), + "optional_prompt": optionalPrompt.map { .string($0.rawValue) }, + "alias_prompt": .string(aliasPrompt.rawValue), "alias_optional_prompt": aliasOptionalPrompt.map { .unknown($0) }, "query": .string(query), - "stream": .unknown(stream), - "optional_stream": optionalStream.map { .unknown($0) }, - "alias_stream": .unknown(aliasStream), + "stream": .bool(stream), + "optional_stream": optionalStream.map { .bool($0) }, + "alias_stream": .bool(aliasStream), "alias_optional_stream": aliasOptionalStream.map { .unknown($0) } ], requestOptions: requestOptions, responseType: SendResponse.self ) } + + public enum YouAreAHelpfulAssistant: String, Codable, Hashable, CaseIterable, Sendable { + case youAreAHelpfulAssistant = "You are a helpful assistant" + } } \ No newline at end of file diff --git a/seed/swift-sdk/literal/Sources/Schemas/AliasToStream.swift b/seed/swift-sdk/literal/Sources/Schemas/AliasToStream.swift index 0b2444b8f153..133a14212274 100644 --- a/seed/swift-sdk/literal/Sources/Schemas/AliasToStream.swift +++ b/seed/swift-sdk/literal/Sources/Schemas/AliasToStream.swift @@ -1,3 +1,3 @@ import Foundation -public typealias AliasToStream = JSONValue +public typealias AliasToStream = Bool diff --git a/seed/swift-sdk/literal/Sources/Schemas/DiscriminatedLiteral.swift b/seed/swift-sdk/literal/Sources/Schemas/DiscriminatedLiteral.swift index faf481576dfd..5a6444f7a2d5 100644 --- a/seed/swift-sdk/literal/Sources/Schemas/DiscriminatedLiteral.swift +++ b/seed/swift-sdk/literal/Sources/Schemas/DiscriminatedLiteral.swift @@ -4,7 +4,7 @@ public enum DiscriminatedLiteral: Codable, Hashable, Sendable { case customName(String) case defaultName(Bob) case george(Bool) - case literalGeorge(JSONValue) + case literalGeorge(Bool) public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) @@ -17,7 +17,7 @@ public enum DiscriminatedLiteral: Codable, Hashable, Sendable { case "george": self = .george(try container.decode(Bool.self, forKey: .value)) case "literalGeorge": - self = .literalGeorge(try container.decode(JSONValue.self, forKey: .value)) + self = .literalGeorge(try container.decode(Bool.self, forKey: .value)) default: throw DecodingError.dataCorrupted( DecodingError.Context( diff --git a/seed/swift-sdk/literal/Sources/Schemas/SendRequest.swift b/seed/swift-sdk/literal/Sources/Schemas/SendRequest.swift index ce7d307c90da..a32849ab7acd 100644 --- a/seed/swift-sdk/literal/Sources/Schemas/SendRequest.swift +++ b/seed/swift-sdk/literal/Sources/Schemas/SendRequest.swift @@ -3,7 +3,7 @@ import Foundation public struct SendRequest: Codable, Hashable, Sendable { public let prompt: YouAreAHelpfulAssistant public let query: String - public let stream: JSONValue + public let stream: Bool public let ending: Ending public let context: SomeLiteral public let maybeContext: SomeLiteral? @@ -14,7 +14,7 @@ public struct SendRequest: Codable, Hashable, Sendable { public init( prompt: YouAreAHelpfulAssistant, query: String, - stream: JSONValue, + stream: Bool, ending: Ending, context: SomeLiteral, maybeContext: SomeLiteral? = nil, @@ -35,7 +35,7 @@ public struct SendRequest: Codable, Hashable, Sendable { let container = try decoder.container(keyedBy: CodingKeys.self) self.prompt = try container.decode(YouAreAHelpfulAssistant.self, forKey: .prompt) self.query = try container.decode(String.self, forKey: .query) - self.stream = try container.decode(JSONValue.self, forKey: .stream) + self.stream = try container.decode(Bool.self, forKey: .stream) self.ending = try container.decode(Ending.self, forKey: .ending) self.context = try container.decode(SomeLiteral.self, forKey: .context) self.maybeContext = try container.decodeIfPresent(SomeLiteral.self, forKey: .maybeContext) diff --git a/seed/swift-sdk/literal/Sources/Schemas/SendResponse.swift b/seed/swift-sdk/literal/Sources/Schemas/SendResponse.swift index 0be93f737249..2d1285ecaa1d 100644 --- a/seed/swift-sdk/literal/Sources/Schemas/SendResponse.swift +++ b/seed/swift-sdk/literal/Sources/Schemas/SendResponse.swift @@ -3,14 +3,14 @@ import Foundation public struct SendResponse: Codable, Hashable, Sendable { public let message: String public let status: Int - public let success: JSONValue + public let success: Bool /// Additional properties that are not explicitly defined in the schema public let additionalProperties: [String: JSONValue] public init( message: String, status: Int, - success: JSONValue, + success: Bool, additionalProperties: [String: JSONValue] = .init() ) { self.message = message @@ -23,7 +23,7 @@ public struct SendResponse: Codable, Hashable, Sendable { let container = try decoder.container(keyedBy: CodingKeys.self) self.message = try container.decode(String.self, forKey: .message) self.status = try container.decode(Int.self, forKey: .status) - self.success = try container.decode(JSONValue.self, forKey: .success) + self.success = try container.decode(Bool.self, forKey: .success) self.additionalProperties = try decoder.decodeAdditionalProperties(using: CodingKeys.self) } diff --git a/seed/swift-sdk/literal/Sources/Schemas/UndiscriminatedLiteral.swift b/seed/swift-sdk/literal/Sources/Schemas/UndiscriminatedLiteral.swift index e8c554e5a8b7..2b63e1f3cdbf 100644 --- a/seed/swift-sdk/literal/Sources/Schemas/UndiscriminatedLiteral.swift +++ b/seed/swift-sdk/literal/Sources/Schemas/UndiscriminatedLiteral.swift @@ -1,24 +1,21 @@ import Foundation public enum UndiscriminatedLiteral: Codable, Hashable, Sendable { - case bool(Bool) - case ending(Ending) - case jsonValue(JSONValue) case string(String) + case ending(Ending) case value(Value) + case bool(Bool) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(Bool.self) { - self = .bool(value) + if let value = try? container.decode(String.self) { + self = .string(value) } else if let value = try? container.decode(Ending.self) { self = .ending(value) - } else if let value = try? container.decode(JSONValue.self) { - self = .jsonValue(value) - } else if let value = try? container.decode(String.self) { - self = .string(value) } else if let value = try? container.decode(Value.self) { self = .value(value) + } else if let value = try? container.decode(Bool.self) { + self = .bool(value) } else { throw DecodingError.dataCorruptedError( in: container, @@ -30,16 +27,14 @@ public enum UndiscriminatedLiteral: Codable, Hashable, Sendable { public func encode(to encoder: Encoder) throws -> Void { var container = encoder.singleValueContainer() switch self { - case .bool(let value): + case .string(let value): try container.encode(value) case .ending(let value): try container.encode(value) - case .jsonValue(let value): - try container.encode(value) - case .string(let value): - try container.encode(value) case .value(let value): try container.encode(value) + case .bool(let value): + try container.encode(value) } } diff --git a/seed/swift-sdk/literal/Tests/Snippets/Example8.swift b/seed/swift-sdk/literal/Tests/Snippets/Example8.swift index 67d07b997f65..20953ffc6939 100644 --- a/seed/swift-sdk/literal/Tests/Snippets/Example8.swift +++ b/seed/swift-sdk/literal/Tests/Snippets/Example8.swift @@ -9,6 +9,7 @@ enum Example8 { prompt: .youAreAHelpfulAssistant, query: "What is the weather today", stream: false, + ending: .ending, context: .youreSuperWise, containerObject: ContainerObject( nestedObjects: [ diff --git a/seed/swift-sdk/literal/Tests/Wire/Resources/Headers/HeadersClientWireTests.swift b/seed/swift-sdk/literal/Tests/Wire/Resources/Headers/HeadersClientWireTests.swift index 78a33025cf98..3f6d8e1a6b52 100644 --- a/seed/swift-sdk/literal/Tests/Wire/Resources/Headers/HeadersClientWireTests.swift +++ b/seed/swift-sdk/literal/Tests/Wire/Resources/Headers/HeadersClientWireTests.swift @@ -23,7 +23,7 @@ import Literal let expectedResponse = SendResponse( message: "The weather is sunny", status: 200, - success: JSONValue.bool(true) + success: true ) let response = try await client.headers.send( request: .init(query: "What is the weather today"), @@ -52,7 +52,7 @@ import Literal let expectedResponse = SendResponse( message: "message", status: 1, - success: JSONValue.bool(true) + success: true ) let response = try await client.headers.send( request: .init(query: "query"), diff --git a/seed/swift-sdk/literal/Tests/Wire/Resources/Inlined/InlinedClientWireTests.swift b/seed/swift-sdk/literal/Tests/Wire/Resources/Inlined/InlinedClientWireTests.swift index d6128e4bb691..bf035e564d14 100644 --- a/seed/swift-sdk/literal/Tests/Wire/Resources/Inlined/InlinedClientWireTests.swift +++ b/seed/swift-sdk/literal/Tests/Wire/Resources/Inlined/InlinedClientWireTests.swift @@ -23,7 +23,7 @@ import Literal let expectedResponse = SendResponse( message: "The weather is sunny", status: 200, - success: JSONValue.bool(true) + success: true ) let response = try await client.inlined.send( request: .init( @@ -65,7 +65,7 @@ import Literal let expectedResponse = SendResponse( message: "message", status: 1, - success: JSONValue.bool(true) + success: true ) let response = try await client.inlined.send( request: .init( diff --git a/seed/swift-sdk/literal/Tests/Wire/Resources/Path/PathClientWireTests.swift b/seed/swift-sdk/literal/Tests/Wire/Resources/Path/PathClientWireTests.swift index b582ff197660..2366ff0eeee4 100644 --- a/seed/swift-sdk/literal/Tests/Wire/Resources/Path/PathClientWireTests.swift +++ b/seed/swift-sdk/literal/Tests/Wire/Resources/Path/PathClientWireTests.swift @@ -23,7 +23,7 @@ import Literal let expectedResponse = SendResponse( message: "The weather is sunny", status: 200, - success: JSONValue.bool(true) + success: true ) let response = try await client.path.send( id: "123", @@ -52,7 +52,7 @@ import Literal let expectedResponse = SendResponse( message: "message", status: 1, - success: JSONValue.bool(true) + success: true ) let response = try await client.path.send( id: "123", diff --git a/seed/swift-sdk/literal/Tests/Wire/Resources/Query/QueryClientWireTests.swift b/seed/swift-sdk/literal/Tests/Wire/Resources/Query/QueryClientWireTests.swift index 205123022017..602bab61cb6c 100644 --- a/seed/swift-sdk/literal/Tests/Wire/Resources/Query/QueryClientWireTests.swift +++ b/seed/swift-sdk/literal/Tests/Wire/Resources/Query/QueryClientWireTests.swift @@ -23,7 +23,7 @@ import Literal let expectedResponse = SendResponse( message: "The weather is sunny", status: 200, - success: JSONValue.bool(true) + success: true ) let response = try await client.query.send( prompt: .youAreAHelpfulAssistant, @@ -60,7 +60,7 @@ import Literal let expectedResponse = SendResponse( message: "message", status: 1, - success: JSONValue.bool(true) + success: true ) let response = try await client.query.send( prompt: .youAreAHelpfulAssistant, diff --git a/seed/swift-sdk/literal/Tests/Wire/Resources/Reference/ReferenceClientWireTests.swift b/seed/swift-sdk/literal/Tests/Wire/Resources/Reference/ReferenceClientWireTests.swift index 9d9fa04dd8b7..47033baf50b8 100644 --- a/seed/swift-sdk/literal/Tests/Wire/Resources/Reference/ReferenceClientWireTests.swift +++ b/seed/swift-sdk/literal/Tests/Wire/Resources/Reference/ReferenceClientWireTests.swift @@ -23,13 +23,14 @@ import Literal let expectedResponse = SendResponse( message: "The weather is sunny", status: 200, - success: JSONValue.bool(true) + success: true ) let response = try await client.reference.send( request: SendRequest( prompt: .youAreAHelpfulAssistant, query: "What is the weather today", stream: false, + ending: .ending, context: .youreSuperWise, containerObject: ContainerObject( nestedObjects: [ @@ -66,7 +67,7 @@ import Literal let expectedResponse = SendResponse( message: "message", status: 1, - success: JSONValue.bool(true) + success: true ) let response = try await client.reference.send( request: SendRequest( diff --git a/seed/swift-sdk/literal/reference.md b/seed/swift-sdk/literal/reference.md index 7b29102e50e3..d480b07f68e5 100644 --- a/seed/swift-sdk/literal/reference.md +++ b/seed/swift-sdk/literal/reference.md @@ -187,7 +187,7 @@ try await main() ## Query -
client.query.send(prompt: JSONValue, optionalPrompt: JSONValue?, aliasPrompt: AliasToPrompt, aliasOptionalPrompt: AliasToPrompt?, query: String, stream: JSONValue, optionalStream: JSONValue?, aliasStream: AliasToStream, aliasOptionalStream: AliasToStream?, requestOptions: RequestOptions?) -> SendResponse +
client.query.send(prompt: JSONValue, optionalPrompt: JSONValue?, aliasPrompt: AliasToPrompt, aliasOptionalPrompt: AliasToPrompt?, query: String, stream: Bool, optionalStream: Bool?, aliasStream: AliasToStream, aliasOptionalStream: AliasToStream?, requestOptions: RequestOptions?) -> SendResponse
@@ -274,7 +274,7 @@ try await main()
-**stream:** `JSONValue` +**stream:** `Bool`
@@ -282,7 +282,7 @@ try await main()
-**optionalStream:** `JSONValue?` +**optionalStream:** `Bool?`
@@ -342,6 +342,7 @@ private func main() async throws { prompt: .youAreAHelpfulAssistant, query: "What is the weather today", stream: false, + ending: .ending, context: .youreSuperWise, containerObject: ContainerObject( nestedObjects: [ diff --git a/seed/swift-sdk/literals-unions/Sources/Schemas/UnionOverLiteral.swift b/seed/swift-sdk/literals-unions/Sources/Schemas/UnionOverLiteral.swift index b8a5c7c35e01..8cff228a02a7 100644 --- a/seed/swift-sdk/literals-unions/Sources/Schemas/UnionOverLiteral.swift +++ b/seed/swift-sdk/literals-unions/Sources/Schemas/UnionOverLiteral.swift @@ -2,15 +2,15 @@ import Foundation /// An undiscriminated union over a literal. public enum UnionOverLiteral: Codable, Hashable, Sendable { - case literalString(LiteralString) case string(String) + case literalString(LiteralString) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(LiteralString.self) { - self = .literalString(value) - } else if let value = try? container.decode(String.self) { + if let value = try? container.decode(String.self) { self = .string(value) + } else if let value = try? container.decode(LiteralString.self) { + self = .literalString(value) } else { throw DecodingError.dataCorruptedError( in: container, @@ -22,10 +22,10 @@ public enum UnionOverLiteral: Codable, Hashable, Sendable { public func encode(to encoder: Encoder) throws -> Void { var container = encoder.singleValueContainer() switch self { - case .literalString(let value): - try container.encode(value) case .string(let value): try container.encode(value) + case .literalString(let value): + try container.encode(value) } } } \ No newline at end of file diff --git a/seed/swift-sdk/nullable/no-custom-config/Sources/Schemas/WeirdNumber.swift b/seed/swift-sdk/nullable/no-custom-config/Sources/Schemas/WeirdNumber.swift index e9c8d810c271..db920a3674eb 100644 --- a/seed/swift-sdk/nullable/no-custom-config/Sources/Schemas/WeirdNumber.swift +++ b/seed/swift-sdk/nullable/no-custom-config/Sources/Schemas/WeirdNumber.swift @@ -1,21 +1,21 @@ import Foundation public enum WeirdNumber: Codable, Hashable, Sendable { - case double(Double) case int(Int) case nullableFloat(Nullable) case optionalNullableString(Nullable?) + case double(Double) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(Double.self) { - self = .double(value) - } else if let value = try? container.decode(Int.self) { + if let value = try? container.decode(Int.self) { self = .int(value) } else if let value = try? container.decode(Nullable.self) { self = .nullableFloat(value) } else if let value = try? container.decode(Nullable?.self) { self = .optionalNullableString(value) + } else if let value = try? container.decode(Double.self) { + self = .double(value) } else { throw DecodingError.dataCorruptedError( in: container, @@ -27,14 +27,14 @@ public enum WeirdNumber: Codable, Hashable, Sendable { public func encode(to encoder: Encoder) throws -> Void { var container = encoder.singleValueContainer() switch self { - case .double(let value): - try container.encode(value) case .int(let value): try container.encode(value) case .nullableFloat(let value): try container.encode(value) case .optionalNullableString(let value): try container.encode(value) + case .double(let value): + try container.encode(value) } } } \ No newline at end of file diff --git a/seed/swift-sdk/nullable/nullable-as-optional/Sources/Schemas/WeirdNumber.swift b/seed/swift-sdk/nullable/nullable-as-optional/Sources/Schemas/WeirdNumber.swift index e9c8d810c271..db920a3674eb 100644 --- a/seed/swift-sdk/nullable/nullable-as-optional/Sources/Schemas/WeirdNumber.swift +++ b/seed/swift-sdk/nullable/nullable-as-optional/Sources/Schemas/WeirdNumber.swift @@ -1,21 +1,21 @@ import Foundation public enum WeirdNumber: Codable, Hashable, Sendable { - case double(Double) case int(Int) case nullableFloat(Nullable) case optionalNullableString(Nullable?) + case double(Double) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(Double.self) { - self = .double(value) - } else if let value = try? container.decode(Int.self) { + if let value = try? container.decode(Int.self) { self = .int(value) } else if let value = try? container.decode(Nullable.self) { self = .nullableFloat(value) } else if let value = try? container.decode(Nullable?.self) { self = .optionalNullableString(value) + } else if let value = try? container.decode(Double.self) { + self = .double(value) } else { throw DecodingError.dataCorruptedError( in: container, @@ -27,14 +27,14 @@ public enum WeirdNumber: Codable, Hashable, Sendable { public func encode(to encoder: Encoder) throws -> Void { var container = encoder.singleValueContainer() switch self { - case .double(let value): - try container.encode(value) case .int(let value): try container.encode(value) case .nullableFloat(let value): try container.encode(value) case .optionalNullableString(let value): try container.encode(value) + case .double(let value): + try container.encode(value) } } } \ No newline at end of file diff --git a/seed/swift-sdk/openapi-request-body-ref/Tests/Snippets/Example3.swift b/seed/swift-sdk/openapi-request-body-ref/Tests/Snippets/Example3.swift index c03ab4e74451..7667a807ce30 100644 --- a/seed/swift-sdk/openapi-request-body-ref/Tests/Snippets/Example3.swift +++ b/seed/swift-sdk/openapi-request-body-ref/Tests/Snippets/Example3.swift @@ -5,9 +5,12 @@ enum Example3 { static func snippet() async throws { let client = ApiClient(baseURL: "https://api.fern.com") - _ = try await client.vendor.createVendor(request: .init( - name: "name", - address: "address" - )) + _ = try await client.vendor.createVendor( + idempotencyKey: "idempotencyKey", + request: .init( + name: "name", + address: "address" + ) + ) } } diff --git a/seed/swift-sdk/openapi-request-body-ref/Tests/Snippets/Example4.swift b/seed/swift-sdk/openapi-request-body-ref/Tests/Snippets/Example4.swift index 561efeb284d5..f456cd6c6a10 100644 --- a/seed/swift-sdk/openapi-request-body-ref/Tests/Snippets/Example4.swift +++ b/seed/swift-sdk/openapi-request-body-ref/Tests/Snippets/Example4.swift @@ -6,10 +6,10 @@ enum Example4 { let client = ApiClient(baseURL: "https://api.fern.com") _ = try await client.catalog.createCatalogImage(request: .init( - imageFile: .init(data: Data("".utf8)), request: CreateCatalogImageRequest( catalogObjectId: "catalog_object_id" - ) + ), + imageFile: .init(data: Data("".utf8)) )) } } diff --git a/seed/swift-sdk/openapi-request-body-ref/Tests/Wire/Resources/Catalog/CatalogClientWireTests.swift b/seed/swift-sdk/openapi-request-body-ref/Tests/Wire/Resources/Catalog/CatalogClientWireTests.swift index ee0bff0d22ec..e757e7e8f0f3 100644 --- a/seed/swift-sdk/openapi-request-body-ref/Tests/Wire/Resources/Catalog/CatalogClientWireTests.swift +++ b/seed/swift-sdk/openapi-request-body-ref/Tests/Wire/Resources/Catalog/CatalogClientWireTests.swift @@ -35,10 +35,10 @@ import Api ) let response = try await client.catalog.createCatalogImage( request: .init( - imageFile: .init(data: Data("".utf8)), request: CreateCatalogImageRequest( catalogObjectId: "catalog_object_id" - ) + ), + imageFile: .init(data: Data("".utf8)) ), requestOptions: RequestOptions(additionalHeaders: stub.headers) ) diff --git a/seed/swift-sdk/openapi-request-body-ref/Tests/Wire/Resources/Vendor/VendorClientWireTests.swift b/seed/swift-sdk/openapi-request-body-ref/Tests/Wire/Resources/Vendor/VendorClientWireTests.swift index 76cd6e2bbe55..a7e2598a68c6 100644 --- a/seed/swift-sdk/openapi-request-body-ref/Tests/Wire/Resources/Vendor/VendorClientWireTests.swift +++ b/seed/swift-sdk/openapi-request-body-ref/Tests/Wire/Resources/Vendor/VendorClientWireTests.swift @@ -152,6 +152,7 @@ import Api )) ) let response = try await client.vendor.createVendor( + idempotencyKey: "idempotencyKey", request: .init( name: "name", address: "address" diff --git a/seed/swift-sdk/openapi-request-body-ref/reference.md b/seed/swift-sdk/openapi-request-body-ref/reference.md index 54420c3c3950..9b86a35471d2 100644 --- a/seed/swift-sdk/openapi-request-body-ref/reference.md +++ b/seed/swift-sdk/openapi-request-body-ref/reference.md @@ -156,10 +156,10 @@ private func main() async throws { let client = ApiClient() _ = try await client.catalog.createCatalogImage(request: .init( - imageFile: .init(data: Data("".utf8)), request: CreateCatalogImageRequest( catalogObjectId: "catalog_object_id" - ) + ), + imageFile: .init(data: Data("".utf8)) )) } diff --git a/seed/swift-sdk/pagination/custom-pager-with-exception-handler/Sources/Schemas/SearchRequestQuery.swift b/seed/swift-sdk/pagination/custom-pager-with-exception-handler/Sources/Schemas/SearchRequestQuery.swift index d38d0545ed5e..e69f9aa26bd6 100644 --- a/seed/swift-sdk/pagination/custom-pager-with-exception-handler/Sources/Schemas/SearchRequestQuery.swift +++ b/seed/swift-sdk/pagination/custom-pager-with-exception-handler/Sources/Schemas/SearchRequestQuery.swift @@ -1,15 +1,15 @@ import Foundation public enum SearchRequestQuery: Codable, Hashable, Sendable { - case multipleFilterSearchRequest(MultipleFilterSearchRequest) case singleFilterSearchRequest(SingleFilterSearchRequest) + case multipleFilterSearchRequest(MultipleFilterSearchRequest) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(MultipleFilterSearchRequest.self) { - self = .multipleFilterSearchRequest(value) - } else if let value = try? container.decode(SingleFilterSearchRequest.self) { + if let value = try? container.decode(SingleFilterSearchRequest.self) { self = .singleFilterSearchRequest(value) + } else if let value = try? container.decode(MultipleFilterSearchRequest.self) { + self = .multipleFilterSearchRequest(value) } else { throw DecodingError.dataCorruptedError( in: container, @@ -21,10 +21,10 @@ public enum SearchRequestQuery: Codable, Hashable, Sendable { public func encode(to encoder: Encoder) throws -> Void { var container = encoder.singleValueContainer() switch self { - case .multipleFilterSearchRequest(let value): - try container.encode(value) case .singleFilterSearchRequest(let value): try container.encode(value) + case .multipleFilterSearchRequest(let value): + try container.encode(value) } } } \ No newline at end of file diff --git a/seed/swift-sdk/pagination/custom-pager-with-exception-handler/Tests/Wire/Resources/InlineUsers/InlineUsers/InlineUsersInlineUsersClientWireTests.swift b/seed/swift-sdk/pagination/custom-pager-with-exception-handler/Tests/Wire/Resources/InlineUsers/InlineUsers/InlineUsersInlineUsersClientWireTests.swift index 50e10bc48626..a56b4a27ba1c 100644 --- a/seed/swift-sdk/pagination/custom-pager-with-exception-handler/Tests/Wire/Resources/InlineUsers/InlineUsers/InlineUsersInlineUsersClientWireTests.swift +++ b/seed/swift-sdk/pagination/custom-pager-with-exception-handler/Tests/Wire/Resources/InlineUsers/InlineUsers/InlineUsersInlineUsersClientWireTests.swift @@ -590,7 +590,6 @@ import Pagination urlSession: stub.urlSession ) let expectedResponse = ListUsersExtendedResponse( - totalCount: 1, data: UserListContainer( users: [ User( @@ -603,7 +602,8 @@ import Pagination ) ] ), - next: Optional(UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!) + next: Optional(UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!), + totalCount: 1 ) let response = try await client.inlineUsers.inlineUsers.listWithExtendedResults( cursor: UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!, @@ -642,7 +642,6 @@ import Pagination urlSession: stub.urlSession ) let expectedResponse = ListUsersExtendedOptionalListResponse( - totalCount: 1, data: UserOptionalListContainer( users: Optional([ User( @@ -655,7 +654,8 @@ import Pagination ) ]) ), - next: Optional(UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!) + next: Optional(UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!), + totalCount: 1 ) let response = try await client.inlineUsers.inlineUsers.listWithExtendedResultsAndOptionalData( cursor: UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!, diff --git a/seed/swift-sdk/pagination/custom-pager-with-exception-handler/Tests/Wire/Resources/Users/UsersClientWireTests.swift b/seed/swift-sdk/pagination/custom-pager-with-exception-handler/Tests/Wire/Resources/Users/UsersClientWireTests.swift index e5c7b8d95d8a..0b608c450c67 100644 --- a/seed/swift-sdk/pagination/custom-pager-with-exception-handler/Tests/Wire/Resources/Users/UsersClientWireTests.swift +++ b/seed/swift-sdk/pagination/custom-pager-with-exception-handler/Tests/Wire/Resources/Users/UsersClientWireTests.swift @@ -792,7 +792,6 @@ import Pagination urlSession: stub.urlSession ) let expectedResponse = ListUsersExtendedResponseType( - totalCount: 1, data: UserListContainerType( users: [ UserType( @@ -805,7 +804,8 @@ import Pagination ) ] ), - next: Optional(UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!) + next: Optional(UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!), + totalCount: 1 ) let response = try await client.users.listWithExtendedResults( cursor: UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!, @@ -844,7 +844,6 @@ import Pagination urlSession: stub.urlSession ) let expectedResponse = ListUsersExtendedOptionalListResponseType( - totalCount: 1, data: UserOptionalListContainerType( users: Optional([ UserType( @@ -857,7 +856,8 @@ import Pagination ) ]) ), - next: Optional(UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!) + next: Optional(UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!), + totalCount: 1 ) let response = try await client.users.listWithExtendedResultsAndOptionalData( cursor: UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!, diff --git a/seed/swift-sdk/pagination/custom-pager/Sources/Schemas/SearchRequestQuery.swift b/seed/swift-sdk/pagination/custom-pager/Sources/Schemas/SearchRequestQuery.swift index d38d0545ed5e..e69f9aa26bd6 100644 --- a/seed/swift-sdk/pagination/custom-pager/Sources/Schemas/SearchRequestQuery.swift +++ b/seed/swift-sdk/pagination/custom-pager/Sources/Schemas/SearchRequestQuery.swift @@ -1,15 +1,15 @@ import Foundation public enum SearchRequestQuery: Codable, Hashable, Sendable { - case multipleFilterSearchRequest(MultipleFilterSearchRequest) case singleFilterSearchRequest(SingleFilterSearchRequest) + case multipleFilterSearchRequest(MultipleFilterSearchRequest) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(MultipleFilterSearchRequest.self) { - self = .multipleFilterSearchRequest(value) - } else if let value = try? container.decode(SingleFilterSearchRequest.self) { + if let value = try? container.decode(SingleFilterSearchRequest.self) { self = .singleFilterSearchRequest(value) + } else if let value = try? container.decode(MultipleFilterSearchRequest.self) { + self = .multipleFilterSearchRequest(value) } else { throw DecodingError.dataCorruptedError( in: container, @@ -21,10 +21,10 @@ public enum SearchRequestQuery: Codable, Hashable, Sendable { public func encode(to encoder: Encoder) throws -> Void { var container = encoder.singleValueContainer() switch self { - case .multipleFilterSearchRequest(let value): - try container.encode(value) case .singleFilterSearchRequest(let value): try container.encode(value) + case .multipleFilterSearchRequest(let value): + try container.encode(value) } } } \ No newline at end of file diff --git a/seed/swift-sdk/pagination/custom-pager/Tests/Wire/Resources/InlineUsers/InlineUsers/InlineUsersInlineUsersClientWireTests.swift b/seed/swift-sdk/pagination/custom-pager/Tests/Wire/Resources/InlineUsers/InlineUsers/InlineUsersInlineUsersClientWireTests.swift index 50e10bc48626..a56b4a27ba1c 100644 --- a/seed/swift-sdk/pagination/custom-pager/Tests/Wire/Resources/InlineUsers/InlineUsers/InlineUsersInlineUsersClientWireTests.swift +++ b/seed/swift-sdk/pagination/custom-pager/Tests/Wire/Resources/InlineUsers/InlineUsers/InlineUsersInlineUsersClientWireTests.swift @@ -590,7 +590,6 @@ import Pagination urlSession: stub.urlSession ) let expectedResponse = ListUsersExtendedResponse( - totalCount: 1, data: UserListContainer( users: [ User( @@ -603,7 +602,8 @@ import Pagination ) ] ), - next: Optional(UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!) + next: Optional(UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!), + totalCount: 1 ) let response = try await client.inlineUsers.inlineUsers.listWithExtendedResults( cursor: UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!, @@ -642,7 +642,6 @@ import Pagination urlSession: stub.urlSession ) let expectedResponse = ListUsersExtendedOptionalListResponse( - totalCount: 1, data: UserOptionalListContainer( users: Optional([ User( @@ -655,7 +654,8 @@ import Pagination ) ]) ), - next: Optional(UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!) + next: Optional(UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!), + totalCount: 1 ) let response = try await client.inlineUsers.inlineUsers.listWithExtendedResultsAndOptionalData( cursor: UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!, diff --git a/seed/swift-sdk/pagination/custom-pager/Tests/Wire/Resources/Users/UsersClientWireTests.swift b/seed/swift-sdk/pagination/custom-pager/Tests/Wire/Resources/Users/UsersClientWireTests.swift index e5c7b8d95d8a..0b608c450c67 100644 --- a/seed/swift-sdk/pagination/custom-pager/Tests/Wire/Resources/Users/UsersClientWireTests.swift +++ b/seed/swift-sdk/pagination/custom-pager/Tests/Wire/Resources/Users/UsersClientWireTests.swift @@ -792,7 +792,6 @@ import Pagination urlSession: stub.urlSession ) let expectedResponse = ListUsersExtendedResponseType( - totalCount: 1, data: UserListContainerType( users: [ UserType( @@ -805,7 +804,8 @@ import Pagination ) ] ), - next: Optional(UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!) + next: Optional(UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!), + totalCount: 1 ) let response = try await client.users.listWithExtendedResults( cursor: UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!, @@ -844,7 +844,6 @@ import Pagination urlSession: stub.urlSession ) let expectedResponse = ListUsersExtendedOptionalListResponseType( - totalCount: 1, data: UserOptionalListContainerType( users: Optional([ UserType( @@ -857,7 +856,8 @@ import Pagination ) ]) ), - next: Optional(UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!) + next: Optional(UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!), + totalCount: 1 ) let response = try await client.users.listWithExtendedResultsAndOptionalData( cursor: UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!, diff --git a/seed/swift-sdk/pagination/no-custom-config/Sources/Schemas/SearchRequestQuery.swift b/seed/swift-sdk/pagination/no-custom-config/Sources/Schemas/SearchRequestQuery.swift index d38d0545ed5e..e69f9aa26bd6 100644 --- a/seed/swift-sdk/pagination/no-custom-config/Sources/Schemas/SearchRequestQuery.swift +++ b/seed/swift-sdk/pagination/no-custom-config/Sources/Schemas/SearchRequestQuery.swift @@ -1,15 +1,15 @@ import Foundation public enum SearchRequestQuery: Codable, Hashable, Sendable { - case multipleFilterSearchRequest(MultipleFilterSearchRequest) case singleFilterSearchRequest(SingleFilterSearchRequest) + case multipleFilterSearchRequest(MultipleFilterSearchRequest) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(MultipleFilterSearchRequest.self) { - self = .multipleFilterSearchRequest(value) - } else if let value = try? container.decode(SingleFilterSearchRequest.self) { + if let value = try? container.decode(SingleFilterSearchRequest.self) { self = .singleFilterSearchRequest(value) + } else if let value = try? container.decode(MultipleFilterSearchRequest.self) { + self = .multipleFilterSearchRequest(value) } else { throw DecodingError.dataCorruptedError( in: container, @@ -21,10 +21,10 @@ public enum SearchRequestQuery: Codable, Hashable, Sendable { public func encode(to encoder: Encoder) throws -> Void { var container = encoder.singleValueContainer() switch self { - case .multipleFilterSearchRequest(let value): - try container.encode(value) case .singleFilterSearchRequest(let value): try container.encode(value) + case .multipleFilterSearchRequest(let value): + try container.encode(value) } } } \ No newline at end of file diff --git a/seed/swift-sdk/pagination/no-custom-config/Tests/Wire/Resources/InlineUsers/InlineUsers/InlineUsersInlineUsersClientWireTests.swift b/seed/swift-sdk/pagination/no-custom-config/Tests/Wire/Resources/InlineUsers/InlineUsers/InlineUsersInlineUsersClientWireTests.swift index 50e10bc48626..a56b4a27ba1c 100644 --- a/seed/swift-sdk/pagination/no-custom-config/Tests/Wire/Resources/InlineUsers/InlineUsers/InlineUsersInlineUsersClientWireTests.swift +++ b/seed/swift-sdk/pagination/no-custom-config/Tests/Wire/Resources/InlineUsers/InlineUsers/InlineUsersInlineUsersClientWireTests.swift @@ -590,7 +590,6 @@ import Pagination urlSession: stub.urlSession ) let expectedResponse = ListUsersExtendedResponse( - totalCount: 1, data: UserListContainer( users: [ User( @@ -603,7 +602,8 @@ import Pagination ) ] ), - next: Optional(UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!) + next: Optional(UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!), + totalCount: 1 ) let response = try await client.inlineUsers.inlineUsers.listWithExtendedResults( cursor: UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!, @@ -642,7 +642,6 @@ import Pagination urlSession: stub.urlSession ) let expectedResponse = ListUsersExtendedOptionalListResponse( - totalCount: 1, data: UserOptionalListContainer( users: Optional([ User( @@ -655,7 +654,8 @@ import Pagination ) ]) ), - next: Optional(UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!) + next: Optional(UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!), + totalCount: 1 ) let response = try await client.inlineUsers.inlineUsers.listWithExtendedResultsAndOptionalData( cursor: UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!, diff --git a/seed/swift-sdk/pagination/no-custom-config/Tests/Wire/Resources/Users/UsersClientWireTests.swift b/seed/swift-sdk/pagination/no-custom-config/Tests/Wire/Resources/Users/UsersClientWireTests.swift index e5c7b8d95d8a..0b608c450c67 100644 --- a/seed/swift-sdk/pagination/no-custom-config/Tests/Wire/Resources/Users/UsersClientWireTests.swift +++ b/seed/swift-sdk/pagination/no-custom-config/Tests/Wire/Resources/Users/UsersClientWireTests.swift @@ -792,7 +792,6 @@ import Pagination urlSession: stub.urlSession ) let expectedResponse = ListUsersExtendedResponseType( - totalCount: 1, data: UserListContainerType( users: [ UserType( @@ -805,7 +804,8 @@ import Pagination ) ] ), - next: Optional(UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!) + next: Optional(UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!), + totalCount: 1 ) let response = try await client.users.listWithExtendedResults( cursor: UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!, @@ -844,7 +844,6 @@ import Pagination urlSession: stub.urlSession ) let expectedResponse = ListUsersExtendedOptionalListResponseType( - totalCount: 1, data: UserOptionalListContainerType( users: Optional([ UserType( @@ -857,7 +856,8 @@ import Pagination ) ]) ), - next: Optional(UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!) + next: Optional(UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!), + totalCount: 1 ) let response = try await client.users.listWithExtendedResultsAndOptionalData( cursor: UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!, diff --git a/seed/swift-sdk/plain-text/Sources/Resources/Service/ServiceClient.swift b/seed/swift-sdk/plain-text/Sources/Resources/Service/ServiceClient.swift index 99ae3568bb9b..d4e862db6c05 100644 --- a/seed/swift-sdk/plain-text/Sources/Resources/Service/ServiceClient.swift +++ b/seed/swift-sdk/plain-text/Sources/Resources/Service/ServiceClient.swift @@ -7,30 +7,30 @@ public final class ServiceClient: Sendable { self.httpClient = HTTPClient(config: config) } - public func getText(requestOptions: RequestOptions? = nil) async throws -> JSONValue { + public func getText(requestOptions: RequestOptions? = nil) async throws -> String { return try await httpClient.performRequest( method: .post, path: "/text", requestOptions: requestOptions, - responseType: JSONValue.self + responseType: String.self ) } - public func getCsv(requestOptions: RequestOptions? = nil) async throws -> JSONValue { + public func getCsv(requestOptions: RequestOptions? = nil) async throws -> String { return try await httpClient.performRequest( method: .get, path: "/csv", requestOptions: requestOptions, - responseType: JSONValue.self + responseType: String.self ) } - public func getXml(requestOptions: RequestOptions? = nil) async throws -> JSONValue { + public func getXml(requestOptions: RequestOptions? = nil) async throws -> String { return try await httpClient.performRequest( method: .get, path: "/xml", requestOptions: requestOptions, - responseType: JSONValue.self + responseType: String.self ) } } \ No newline at end of file diff --git a/seed/swift-sdk/plain-text/reference.md b/seed/swift-sdk/plain-text/reference.md index 2adb5112942e..559b63da024a 100644 --- a/seed/swift-sdk/plain-text/reference.md +++ b/seed/swift-sdk/plain-text/reference.md @@ -1,6 +1,6 @@ # Reference ## Service -
client.service.getText(requestOptions: RequestOptions?) -> JSONValue +
client.service.getText(requestOptions: RequestOptions?) -> String
@@ -49,7 +49,7 @@ try await main()
-
client.service.getCsv(requestOptions: RequestOptions?) -> JSONValue +
client.service.getCsv(requestOptions: RequestOptions?) -> String
@@ -98,7 +98,7 @@ try await main()
-
client.service.getXml(requestOptions: RequestOptions?) -> JSONValue +
client.service.getXml(requestOptions: RequestOptions?) -> String
diff --git a/seed/swift-sdk/property-access/Sources/Schemas/UserOrAdmin.swift b/seed/swift-sdk/property-access/Sources/Schemas/UserOrAdmin.swift index 3c18ebd67b20..29a14fc9be2d 100644 --- a/seed/swift-sdk/property-access/Sources/Schemas/UserOrAdmin.swift +++ b/seed/swift-sdk/property-access/Sources/Schemas/UserOrAdmin.swift @@ -2,15 +2,15 @@ import Foundation /// Example of an undiscriminated union public enum UserOrAdmin: Codable, Hashable, Sendable { - case admin(Admin) case user(User) + case admin(Admin) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(Admin.self) { - self = .admin(value) - } else if let value = try? container.decode(User.self) { + if let value = try? container.decode(User.self) { self = .user(value) + } else if let value = try? container.decode(Admin.self) { + self = .admin(value) } else { throw DecodingError.dataCorruptedError( in: container, @@ -22,10 +22,10 @@ public enum UserOrAdmin: Codable, Hashable, Sendable { public func encode(to encoder: Encoder) throws -> Void { var container = encoder.singleValueContainer() switch self { - case .admin(let value): - try container.encode(value) case .user(let value): try container.encode(value) + case .admin(let value): + try container.encode(value) } } } \ No newline at end of file diff --git a/seed/swift-sdk/query-parameters-openapi-as-objects/Sources/Schemas/SearchRequestNeighbor.swift b/seed/swift-sdk/query-parameters-openapi-as-objects/Sources/Schemas/SearchRequestNeighbor.swift index 009a82976fe6..c95c8344a29f 100644 --- a/seed/swift-sdk/query-parameters-openapi-as-objects/Sources/Schemas/SearchRequestNeighbor.swift +++ b/seed/swift-sdk/query-parameters-openapi-as-objects/Sources/Schemas/SearchRequestNeighbor.swift @@ -1,21 +1,21 @@ import Foundation public enum SearchRequestNeighbor: Codable, Hashable, Sendable { - case int(Int) + case user(User) case nestedUser(NestedUser) case string(String) - case user(User) + case int(Int) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(Int.self) { - self = .int(value) + if let value = try? container.decode(User.self) { + self = .user(value) } else if let value = try? container.decode(NestedUser.self) { self = .nestedUser(value) } else if let value = try? container.decode(String.self) { self = .string(value) - } else if let value = try? container.decode(User.self) { - self = .user(value) + } else if let value = try? container.decode(Int.self) { + self = .int(value) } else { throw DecodingError.dataCorruptedError( in: container, @@ -27,13 +27,13 @@ public enum SearchRequestNeighbor: Codable, Hashable, Sendable { public func encode(to encoder: Encoder) throws -> Void { var container = encoder.singleValueContainer() switch self { - case .int(let value): + case .user(let value): try container.encode(value) case .nestedUser(let value): try container.encode(value) case .string(let value): try container.encode(value) - case .user(let value): + case .int(let value): try container.encode(value) } } diff --git a/seed/swift-sdk/query-parameters-openapi-as-objects/Sources/Schemas/SearchRequestNeighborRequired.swift b/seed/swift-sdk/query-parameters-openapi-as-objects/Sources/Schemas/SearchRequestNeighborRequired.swift index bbc8697c7cd0..0236eca5725c 100644 --- a/seed/swift-sdk/query-parameters-openapi-as-objects/Sources/Schemas/SearchRequestNeighborRequired.swift +++ b/seed/swift-sdk/query-parameters-openapi-as-objects/Sources/Schemas/SearchRequestNeighborRequired.swift @@ -1,21 +1,21 @@ import Foundation public enum SearchRequestNeighborRequired: Codable, Hashable, Sendable { - case int(Int) + case user(User) case nestedUser(NestedUser) case string(String) - case user(User) + case int(Int) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(Int.self) { - self = .int(value) + if let value = try? container.decode(User.self) { + self = .user(value) } else if let value = try? container.decode(NestedUser.self) { self = .nestedUser(value) } else if let value = try? container.decode(String.self) { self = .string(value) - } else if let value = try? container.decode(User.self) { - self = .user(value) + } else if let value = try? container.decode(Int.self) { + self = .int(value) } else { throw DecodingError.dataCorruptedError( in: container, @@ -27,13 +27,13 @@ public enum SearchRequestNeighborRequired: Codable, Hashable, Sendable { public func encode(to encoder: Encoder) throws -> Void { var container = encoder.singleValueContainer() switch self { - case .int(let value): + case .user(let value): try container.encode(value) case .nestedUser(let value): try container.encode(value) case .string(let value): try container.encode(value) - case .user(let value): + case .int(let value): try container.encode(value) } } diff --git a/seed/swift-sdk/query-parameters-openapi/Sources/Schemas/SearchRequestNeighbor.swift b/seed/swift-sdk/query-parameters-openapi/Sources/Schemas/SearchRequestNeighbor.swift index 009a82976fe6..c95c8344a29f 100644 --- a/seed/swift-sdk/query-parameters-openapi/Sources/Schemas/SearchRequestNeighbor.swift +++ b/seed/swift-sdk/query-parameters-openapi/Sources/Schemas/SearchRequestNeighbor.swift @@ -1,21 +1,21 @@ import Foundation public enum SearchRequestNeighbor: Codable, Hashable, Sendable { - case int(Int) + case user(User) case nestedUser(NestedUser) case string(String) - case user(User) + case int(Int) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(Int.self) { - self = .int(value) + if let value = try? container.decode(User.self) { + self = .user(value) } else if let value = try? container.decode(NestedUser.self) { self = .nestedUser(value) } else if let value = try? container.decode(String.self) { self = .string(value) - } else if let value = try? container.decode(User.self) { - self = .user(value) + } else if let value = try? container.decode(Int.self) { + self = .int(value) } else { throw DecodingError.dataCorruptedError( in: container, @@ -27,13 +27,13 @@ public enum SearchRequestNeighbor: Codable, Hashable, Sendable { public func encode(to encoder: Encoder) throws -> Void { var container = encoder.singleValueContainer() switch self { - case .int(let value): + case .user(let value): try container.encode(value) case .nestedUser(let value): try container.encode(value) case .string(let value): try container.encode(value) - case .user(let value): + case .int(let value): try container.encode(value) } } diff --git a/seed/swift-sdk/query-parameters-openapi/Sources/Schemas/SearchRequestNeighborRequired.swift b/seed/swift-sdk/query-parameters-openapi/Sources/Schemas/SearchRequestNeighborRequired.swift index bbc8697c7cd0..0236eca5725c 100644 --- a/seed/swift-sdk/query-parameters-openapi/Sources/Schemas/SearchRequestNeighborRequired.swift +++ b/seed/swift-sdk/query-parameters-openapi/Sources/Schemas/SearchRequestNeighborRequired.swift @@ -1,21 +1,21 @@ import Foundation public enum SearchRequestNeighborRequired: Codable, Hashable, Sendable { - case int(Int) + case user(User) case nestedUser(NestedUser) case string(String) - case user(User) + case int(Int) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(Int.self) { - self = .int(value) + if let value = try? container.decode(User.self) { + self = .user(value) } else if let value = try? container.decode(NestedUser.self) { self = .nestedUser(value) } else if let value = try? container.decode(String.self) { self = .string(value) - } else if let value = try? container.decode(User.self) { - self = .user(value) + } else if let value = try? container.decode(Int.self) { + self = .int(value) } else { throw DecodingError.dataCorruptedError( in: container, @@ -27,13 +27,13 @@ public enum SearchRequestNeighborRequired: Codable, Hashable, Sendable { public func encode(to encoder: Encoder) throws -> Void { var container = encoder.singleValueContainer() switch self { - case .int(let value): + case .user(let value): try container.encode(value) case .nestedUser(let value): try container.encode(value) case .string(let value): try container.encode(value) - case .user(let value): + case .int(let value): try container.encode(value) } } diff --git a/seed/swift-sdk/required-nullable/no-custom-config/Tests/Snippets/Example2.swift b/seed/swift-sdk/required-nullable/no-custom-config/Tests/Snippets/Example2.swift index f13238b4b9b6..e4bbafd9d748 100644 --- a/seed/swift-sdk/required-nullable/no-custom-config/Tests/Snippets/Example2.swift +++ b/seed/swift-sdk/required-nullable/no-custom-config/Tests/Snippets/Example2.swift @@ -7,6 +7,7 @@ enum Example2 { _ = try await client.updateFoo( id: "id", + xIdempotencyKey: "X-Idempotency-Key", request: .init( nullableText: .value("nullable_text"), nullableNumber: .value(1.1), diff --git a/seed/swift-sdk/required-nullable/no-custom-config/reference.md b/seed/swift-sdk/required-nullable/no-custom-config/reference.md index 2c5ebe468337..3c5723ad15a7 100644 --- a/seed/swift-sdk/required-nullable/no-custom-config/reference.md +++ b/seed/swift-sdk/required-nullable/no-custom-config/reference.md @@ -104,6 +104,7 @@ private func main() async throws { _ = try await client.updateFoo( id: "id", + xIdempotencyKey: "X-Idempotency-Key", request: .init( nullableText: .value("nullable_text"), nullableNumber: .value(1.1), diff --git a/seed/swift-sdk/required-nullable/nullable-as-optional/Tests/Snippets/Example2.swift b/seed/swift-sdk/required-nullable/nullable-as-optional/Tests/Snippets/Example2.swift index f13238b4b9b6..e4bbafd9d748 100644 --- a/seed/swift-sdk/required-nullable/nullable-as-optional/Tests/Snippets/Example2.swift +++ b/seed/swift-sdk/required-nullable/nullable-as-optional/Tests/Snippets/Example2.swift @@ -7,6 +7,7 @@ enum Example2 { _ = try await client.updateFoo( id: "id", + xIdempotencyKey: "X-Idempotency-Key", request: .init( nullableText: .value("nullable_text"), nullableNumber: .value(1.1), diff --git a/seed/swift-sdk/required-nullable/nullable-as-optional/reference.md b/seed/swift-sdk/required-nullable/nullable-as-optional/reference.md index 2c5ebe468337..3c5723ad15a7 100644 --- a/seed/swift-sdk/required-nullable/nullable-as-optional/reference.md +++ b/seed/swift-sdk/required-nullable/nullable-as-optional/reference.md @@ -104,6 +104,7 @@ private func main() async throws { _ = try await client.updateFoo( id: "id", + xIdempotencyKey: "X-Idempotency-Key", request: .init( nullableText: .value("nullable_text"), nullableNumber: .value(1.1), diff --git a/seed/swift-sdk/response-property/Tests/Wire/Resources/Service/ServiceClientWireTests.swift b/seed/swift-sdk/response-property/Tests/Wire/Resources/Service/ServiceClientWireTests.swift index ca54cc5a77ba..cd9378d6e5c5 100644 --- a/seed/swift-sdk/response-property/Tests/Wire/Resources/Service/ServiceClientWireTests.swift +++ b/seed/swift-sdk/response-property/Tests/Wire/Resources/Service/ServiceClientWireTests.swift @@ -26,14 +26,14 @@ import ResponseProperty urlSession: stub.urlSession ) let expectedResponse = Response( - data: Movie( - id: "id", - name: "name" - ), metadata: [ "metadata": "metadata" ], - docs: "docs" + docs: "docs", + data: Movie( + id: "id", + name: "name" + ) ) let response = try await client.service.getMovie( request: "string", @@ -65,14 +65,14 @@ import ResponseProperty urlSession: stub.urlSession ) let expectedResponse = Response( - data: Movie( - id: "id", - name: "name" - ), metadata: [ "metadata": "metadata" ], - docs: "docs" + docs: "docs", + data: Movie( + id: "id", + name: "name" + ) ) let response = try await client.service.getMovieDocs( request: "string", @@ -129,14 +129,14 @@ import ResponseProperty urlSession: stub.urlSession ) let expectedResponse = Response( - data: Movie( - id: "id", - name: "name" - ), metadata: [ "metadata": "metadata" ], - docs: "docs" + docs: "docs", + data: Movie( + id: "id", + name: "name" + ) ) let response = try await client.service.getMovieMetadata( request: "string", @@ -168,14 +168,14 @@ import ResponseProperty urlSession: stub.urlSession ) let expectedResponse = Optional(Response( - data: Movie( - id: "id", - name: "name" - ), metadata: [ "metadata": "metadata" ], - docs: "docs" + docs: "docs", + data: Movie( + id: "id", + name: "name" + ) )) let response = try await client.service.getOptionalMovie( request: "string", diff --git a/seed/swift-sdk/seed.yml b/seed/swift-sdk/seed.yml index e6469aea8ee5..9f8f077161d9 100644 --- a/seed/swift-sdk/seed.yml +++ b/seed/swift-sdk/seed.yml @@ -133,40 +133,17 @@ allowedFailures: - examples:no-custom-config - examples:readme-config - exhaustive - - extra-properties - - file-upload-openapi - - idempotency-headers - - inferred-auth-explicit - - inferred-auth-implicit - - inferred-auth-implicit-no-expiry - - inferred-auth-implicit-api-key - - literal - multi-url-environment - multi-url-environment-no-default - multi-url-environment-reference - - nullable:no-custom-config - - nullable:nullable-as-optional - oauth-client-credentials-with-variables - - pagination:no-custom-config - - pagination:custom-pager - - pagination:custom-pager-with-exception-handler - - plain-text - query-parameters - request-parameters - - required-nullable:no-custom-config - - required-nullable:nullable-as-optional - - response-property - streaming - streaming-parameter - trace - undiscriminated-unions - # Java-specific fixture for LocalDate support - - unions-with-local-date # Server URL templating not yet supported in Swift SDK - server-sent-events-openapi - server-url-templating - variables - - websocket-inferred-auth - # Multipart with $ref body — Swift snippet generator emits args in wrong - # positional order; tracked separately under FER-10087 follow-up. - - openapi-request-body-ref diff --git a/seed/swift-sdk/server-sent-events-openapi/Sources/Requests/Requests+StreamXFernStreamingConditionRequest.swift b/seed/swift-sdk/server-sent-events-openapi/Sources/Requests/Requests+StreamXFernStreamingConditionRequest.swift index b641173a6246..706beb056e7d 100644 --- a/seed/swift-sdk/server-sent-events-openapi/Sources/Requests/Requests+StreamXFernStreamingConditionRequest.swift +++ b/seed/swift-sdk/server-sent-events-openapi/Sources/Requests/Requests+StreamXFernStreamingConditionRequest.swift @@ -5,13 +5,13 @@ extension Requests { /// The prompt or query to complete. public let query: String /// Whether to stream the response. - public let stream: JSONValue + public let stream: Bool /// Additional properties that are not explicitly defined in the schema public let additionalProperties: [String: JSONValue] public init( query: String, - stream: JSONValue, + stream: Bool, additionalProperties: [String: JSONValue] = .init() ) { self.query = query @@ -22,7 +22,7 @@ extension Requests { public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) self.query = try container.decode(String.self, forKey: .query) - self.stream = try container.decode(JSONValue.self, forKey: .stream) + self.stream = try container.decode(Bool.self, forKey: .stream) self.additionalProperties = try decoder.decodeAdditionalProperties(using: CodingKeys.self) } diff --git a/seed/swift-sdk/server-sent-events-openapi/Sources/Requests/Requests+StreamXFernStreamingConditionStreamRequest.swift b/seed/swift-sdk/server-sent-events-openapi/Sources/Requests/Requests+StreamXFernStreamingConditionStreamRequest.swift index 197cd42df4dd..ef4473406059 100644 --- a/seed/swift-sdk/server-sent-events-openapi/Sources/Requests/Requests+StreamXFernStreamingConditionStreamRequest.swift +++ b/seed/swift-sdk/server-sent-events-openapi/Sources/Requests/Requests+StreamXFernStreamingConditionStreamRequest.swift @@ -5,13 +5,13 @@ extension Requests { /// The prompt or query to complete. public let query: String /// Whether to stream the response. - public let stream: JSONValue + public let stream: Bool /// Additional properties that are not explicitly defined in the schema public let additionalProperties: [String: JSONValue] public init( query: String, - stream: JSONValue, + stream: Bool, additionalProperties: [String: JSONValue] = .init() ) { self.query = query @@ -22,7 +22,7 @@ extension Requests { public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) self.query = try container.decode(String.self, forKey: .query) - self.stream = try container.decode(JSONValue.self, forKey: .stream) + self.stream = try container.decode(Bool.self, forKey: .stream) self.additionalProperties = try decoder.decodeAdditionalProperties(using: CodingKeys.self) } diff --git a/seed/swift-sdk/server-sent-events-openapi/Sources/Requests/Requests+StreamXFernStreamingNullableConditionRequest.swift b/seed/swift-sdk/server-sent-events-openapi/Sources/Requests/Requests+StreamXFernStreamingNullableConditionRequest.swift index 09f84f775d84..973e914a6d51 100644 --- a/seed/swift-sdk/server-sent-events-openapi/Sources/Requests/Requests+StreamXFernStreamingNullableConditionRequest.swift +++ b/seed/swift-sdk/server-sent-events-openapi/Sources/Requests/Requests+StreamXFernStreamingNullableConditionRequest.swift @@ -5,13 +5,13 @@ extension Requests { /// The prompt or query to complete. public let query: String /// Whether to stream the response. This field is nullable (OAS 3.1 type array), which previously caused the const literal to be overwritten by the nullable type during spread in the importer. - public let stream: JSONValue + public let stream: Bool /// Additional properties that are not explicitly defined in the schema public let additionalProperties: [String: JSONValue] public init( query: String, - stream: JSONValue, + stream: Bool, additionalProperties: [String: JSONValue] = .init() ) { self.query = query @@ -22,7 +22,7 @@ extension Requests { public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) self.query = try container.decode(String.self, forKey: .query) - self.stream = try container.decode(JSONValue.self, forKey: .stream) + self.stream = try container.decode(Bool.self, forKey: .stream) self.additionalProperties = try decoder.decodeAdditionalProperties(using: CodingKeys.self) } diff --git a/seed/swift-sdk/server-sent-events-openapi/Sources/Requests/Requests+StreamXFernStreamingNullableConditionStreamRequest.swift b/seed/swift-sdk/server-sent-events-openapi/Sources/Requests/Requests+StreamXFernStreamingNullableConditionStreamRequest.swift index bfaa84347e0a..0c5de18d3375 100644 --- a/seed/swift-sdk/server-sent-events-openapi/Sources/Requests/Requests+StreamXFernStreamingNullableConditionStreamRequest.swift +++ b/seed/swift-sdk/server-sent-events-openapi/Sources/Requests/Requests+StreamXFernStreamingNullableConditionStreamRequest.swift @@ -5,13 +5,13 @@ extension Requests { /// The prompt or query to complete. public let query: String /// Whether to stream the response. This field is nullable (OAS 3.1 type array), which previously caused the const literal to be overwritten by the nullable type during spread in the importer. - public let stream: JSONValue + public let stream: Bool /// Additional properties that are not explicitly defined in the schema public let additionalProperties: [String: JSONValue] public init( query: String, - stream: JSONValue, + stream: Bool, additionalProperties: [String: JSONValue] = .init() ) { self.query = query @@ -22,7 +22,7 @@ extension Requests { public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) self.query = try container.decode(String.self, forKey: .query) - self.stream = try container.decode(JSONValue.self, forKey: .stream) + self.stream = try container.decode(Bool.self, forKey: .stream) self.additionalProperties = try decoder.decodeAdditionalProperties(using: CodingKeys.self) } diff --git a/seed/swift-sdk/server-sent-events-openapi/Sources/Requests/Requests+StreamXFernStreamingSharedSchemaRequest.swift b/seed/swift-sdk/server-sent-events-openapi/Sources/Requests/Requests+StreamXFernStreamingSharedSchemaRequest.swift index c68c3fb9571f..e99b4dd8f16c 100644 --- a/seed/swift-sdk/server-sent-events-openapi/Sources/Requests/Requests+StreamXFernStreamingSharedSchemaRequest.swift +++ b/seed/swift-sdk/server-sent-events-openapi/Sources/Requests/Requests+StreamXFernStreamingSharedSchemaRequest.swift @@ -7,14 +7,14 @@ extension Requests { /// The model to use. public let model: String /// Whether to stream the response. - public let stream: JSONValue + public let stream: Bool /// Additional properties that are not explicitly defined in the schema public let additionalProperties: [String: JSONValue] public init( prompt: String, model: String, - stream: JSONValue, + stream: Bool, additionalProperties: [String: JSONValue] = .init() ) { self.prompt = prompt @@ -27,7 +27,7 @@ extension Requests { let container = try decoder.container(keyedBy: CodingKeys.self) self.prompt = try container.decode(String.self, forKey: .prompt) self.model = try container.decode(String.self, forKey: .model) - self.stream = try container.decode(JSONValue.self, forKey: .stream) + self.stream = try container.decode(Bool.self, forKey: .stream) self.additionalProperties = try decoder.decodeAdditionalProperties(using: CodingKeys.self) } diff --git a/seed/swift-sdk/server-sent-events-openapi/Sources/Requests/Requests+StreamXFernStreamingSharedSchemaStreamRequest.swift b/seed/swift-sdk/server-sent-events-openapi/Sources/Requests/Requests+StreamXFernStreamingSharedSchemaStreamRequest.swift index 61a80aa9eb5c..cc778ac6e11c 100644 --- a/seed/swift-sdk/server-sent-events-openapi/Sources/Requests/Requests+StreamXFernStreamingSharedSchemaStreamRequest.swift +++ b/seed/swift-sdk/server-sent-events-openapi/Sources/Requests/Requests+StreamXFernStreamingSharedSchemaStreamRequest.swift @@ -7,14 +7,14 @@ extension Requests { /// The model to use. public let model: String /// Whether to stream the response. - public let stream: JSONValue + public let stream: Bool /// Additional properties that are not explicitly defined in the schema public let additionalProperties: [String: JSONValue] public init( prompt: String, model: String, - stream: JSONValue, + stream: Bool, additionalProperties: [String: JSONValue] = .init() ) { self.prompt = prompt @@ -27,7 +27,7 @@ extension Requests { let container = try decoder.container(keyedBy: CodingKeys.self) self.prompt = try container.decode(String.self, forKey: .prompt) self.model = try container.decode(String.self, forKey: .model) - self.stream = try container.decode(JSONValue.self, forKey: .stream) + self.stream = try container.decode(Bool.self, forKey: .stream) self.additionalProperties = try decoder.decodeAdditionalProperties(using: CodingKeys.self) } diff --git a/seed/swift-sdk/streaming/Sources/Requests/Requests+GenerateStreamRequest.swift b/seed/swift-sdk/streaming/Sources/Requests/Requests+GenerateStreamRequest.swift index 6a92f9788fee..8ff9846ef7e8 100644 --- a/seed/swift-sdk/streaming/Sources/Requests/Requests+GenerateStreamRequest.swift +++ b/seed/swift-sdk/streaming/Sources/Requests/Requests+GenerateStreamRequest.swift @@ -2,13 +2,13 @@ import Foundation extension Requests { public struct GenerateStreamRequest: Codable, Hashable, Sendable { - public let stream: JSONValue + public let stream: Bool public let numEvents: Int /// Additional properties that are not explicitly defined in the schema public let additionalProperties: [String: JSONValue] public init( - stream: JSONValue, + stream: Bool, numEvents: Int, additionalProperties: [String: JSONValue] = .init() ) { @@ -19,7 +19,7 @@ extension Requests { public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - self.stream = try container.decode(JSONValue.self, forKey: .stream) + self.stream = try container.decode(Bool.self, forKey: .stream) self.numEvents = try container.decode(Int.self, forKey: .numEvents) self.additionalProperties = try decoder.decodeAdditionalProperties(using: CodingKeys.self) } diff --git a/seed/swift-sdk/streaming/Sources/Requests/Requests+Generateequest.swift b/seed/swift-sdk/streaming/Sources/Requests/Requests+Generateequest.swift index 3af96aa6333f..38a7522f1f1f 100644 --- a/seed/swift-sdk/streaming/Sources/Requests/Requests+Generateequest.swift +++ b/seed/swift-sdk/streaming/Sources/Requests/Requests+Generateequest.swift @@ -2,13 +2,13 @@ import Foundation extension Requests { public struct Generateequest: Codable, Hashable, Sendable { - public let stream: JSONValue + public let stream: Bool public let numEvents: Int /// Additional properties that are not explicitly defined in the schema public let additionalProperties: [String: JSONValue] public init( - stream: JSONValue, + stream: Bool, numEvents: Int, additionalProperties: [String: JSONValue] = .init() ) { @@ -19,7 +19,7 @@ extension Requests { public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - self.stream = try container.decode(JSONValue.self, forKey: .stream) + self.stream = try container.decode(Bool.self, forKey: .stream) self.numEvents = try container.decode(Int.self, forKey: .numEvents) self.additionalProperties = try decoder.decodeAdditionalProperties(using: CodingKeys.self) } diff --git a/seed/swift-sdk/trace/Tests/Snippets/Example11.swift b/seed/swift-sdk/trace/Tests/Snippets/Example11.swift index e2c4a9b2870f..1d7b16c65dd4 100644 --- a/seed/swift-sdk/trace/Tests/Snippets/Example11.swift +++ b/seed/swift-sdk/trace/Tests/Snippets/Example11.swift @@ -8,6 +8,6 @@ enum Example11 { token: "" ) - _ = try await client.migration.getAttemptedMigrations() + _ = try await client.migration.getAttemptedMigrations(adminKeyHeader: "admin-key-header") } } diff --git a/seed/swift-sdk/trace/Tests/Snippets/Example2.swift b/seed/swift-sdk/trace/Tests/Snippets/Example2.swift index eca0c460628d..49dd9b9d807d 100644 --- a/seed/swift-sdk/trace/Tests/Snippets/Example2.swift +++ b/seed/swift-sdk/trace/Tests/Snippets/Example2.swift @@ -13,7 +13,7 @@ enum Example2 { request: TestSubmissionUpdate( updateTime: try! Date("2024-01-15T09:30:00Z", strategy: .iso8601), updateInfo: TestSubmissionUpdateInfo.running( - + .queueingSubmission ) ) ) diff --git a/seed/swift-sdk/trace/Tests/Snippets/Example20.swift b/seed/swift-sdk/trace/Tests/Snippets/Example20.swift index 55946939c8e0..bfa84947c4b7 100644 --- a/seed/swift-sdk/trace/Tests/Snippets/Example20.swift +++ b/seed/swift-sdk/trace/Tests/Snippets/Example20.swift @@ -13,10 +13,10 @@ enum Example20 { problemDescription: ProblemDescription( boards: [ ProblemDescriptionBoard.html( - + "boards" ), ProblemDescriptionBoard.html( - + "boards" ) ] ), @@ -55,15 +55,15 @@ enum Example20 { id: "id", params: [ VariableValue.integerValue( - + 1 ), VariableValue.integerValue( - + 1 ) ] ), expectedResult: VariableValue.integerValue( - + 1 ) ), TestCaseWithExpectedResult( @@ -71,15 +71,15 @@ enum Example20 { id: "id", params: [ VariableValue.integerValue( - + 1 ), VariableValue.integerValue( - + 1 ) ] ), expectedResult: VariableValue.integerValue( - + 1 ) ) ], diff --git a/seed/swift-sdk/trace/Tests/Snippets/Example21.swift b/seed/swift-sdk/trace/Tests/Snippets/Example21.swift index 0f950d3488bd..fd85b7247721 100644 --- a/seed/swift-sdk/trace/Tests/Snippets/Example21.swift +++ b/seed/swift-sdk/trace/Tests/Snippets/Example21.swift @@ -15,10 +15,10 @@ enum Example21 { problemDescription: ProblemDescription( boards: [ ProblemDescriptionBoard.html( - + "boards" ), ProblemDescriptionBoard.html( - + "boards" ) ] ), @@ -57,15 +57,15 @@ enum Example21 { id: "id", params: [ VariableValue.integerValue( - + 1 ), VariableValue.integerValue( - + 1 ) ] ), expectedResult: VariableValue.integerValue( - + 1 ) ), TestCaseWithExpectedResult( @@ -73,15 +73,15 @@ enum Example21 { id: "id", params: [ VariableValue.integerValue( - + 1 ), VariableValue.integerValue( - + 1 ) ] ), expectedResult: VariableValue.integerValue( - + 1 ) ) ], diff --git a/seed/swift-sdk/trace/Tests/Snippets/Example4.swift b/seed/swift-sdk/trace/Tests/Snippets/Example4.swift index e5d692f1eace..323379adf167 100644 --- a/seed/swift-sdk/trace/Tests/Snippets/Example4.swift +++ b/seed/swift-sdk/trace/Tests/Snippets/Example4.swift @@ -13,7 +13,7 @@ enum Example4 { request: WorkspaceSubmissionUpdate( updateTime: try! Date("2024-01-15T09:30:00Z", strategy: .iso8601), updateInfo: WorkspaceSubmissionUpdateInfo.running( - + .queueingSubmission ) ) ) diff --git a/seed/swift-sdk/trace/Tests/Snippets/Example5.swift b/seed/swift-sdk/trace/Tests/Snippets/Example5.swift index 4545b07d7800..4a7b7d0b33fa 100644 --- a/seed/swift-sdk/trace/Tests/Snippets/Example5.swift +++ b/seed/swift-sdk/trace/Tests/Snippets/Example5.swift @@ -15,11 +15,11 @@ enum Example5 { result: TestCaseResultWithStdout( result: TestCaseResult( expectedResult: VariableValue.integerValue( - + 1 ), actualResult: ActualResult.value( VariableValue.integerValue( - + 1 ) ), passed: true @@ -31,7 +31,7 @@ enum Example5 { submissionId: UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!, lineNumber: 1, returnValue: DebugVariableValue.integerValue( - + 1 ), expressionLocation: ExpressionLocation( start: 1, @@ -46,14 +46,14 @@ enum Example5 { Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ), Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ) @@ -66,7 +66,7 @@ enum Example5 { submissionId: UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!, lineNumber: 1, returnValue: DebugVariableValue.integerValue( - + 1 ), expressionLocation: ExpressionLocation( start: 1, @@ -81,14 +81,14 @@ enum Example5 { Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ), Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ) diff --git a/seed/swift-sdk/trace/Tests/Snippets/Example6.swift b/seed/swift-sdk/trace/Tests/Snippets/Example6.swift index 1a8b242b163d..86efe58c7cf7 100644 --- a/seed/swift-sdk/trace/Tests/Snippets/Example6.swift +++ b/seed/swift-sdk/trace/Tests/Snippets/Example6.swift @@ -20,7 +20,7 @@ enum Example6 { directory: "directory" ), returnValue: DebugVariableValue.integerValue( - + 1 ), expressionLocation: ExpressionLocation( start: 1, @@ -35,14 +35,14 @@ enum Example6 { Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ), Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ) @@ -59,7 +59,7 @@ enum Example6 { directory: "directory" ), returnValue: DebugVariableValue.integerValue( - + 1 ), expressionLocation: ExpressionLocation( start: 1, @@ -74,14 +74,14 @@ enum Example6 { Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ), Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ) diff --git a/seed/swift-sdk/trace/Tests/Snippets/Example7.swift b/seed/swift-sdk/trace/Tests/Snippets/Example7.swift index b5fae38e7bc0..7e17df6d59f6 100644 --- a/seed/swift-sdk/trace/Tests/Snippets/Example7.swift +++ b/seed/swift-sdk/trace/Tests/Snippets/Example7.swift @@ -31,7 +31,7 @@ enum Example7 { submissionId: UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!, lineNumber: 1, returnValue: DebugVariableValue.integerValue( - + 1 ), expressionLocation: ExpressionLocation( start: 1, @@ -46,14 +46,14 @@ enum Example7 { Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ), Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ) @@ -66,7 +66,7 @@ enum Example7 { submissionId: UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!, lineNumber: 1, returnValue: DebugVariableValue.integerValue( - + 1 ), expressionLocation: ExpressionLocation( start: 1, @@ -81,14 +81,14 @@ enum Example7 { Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ), Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ) diff --git a/seed/swift-sdk/trace/Tests/Snippets/Example8.swift b/seed/swift-sdk/trace/Tests/Snippets/Example8.swift index 7378f48d84c0..3e13ae5bd668 100644 --- a/seed/swift-sdk/trace/Tests/Snippets/Example8.swift +++ b/seed/swift-sdk/trace/Tests/Snippets/Example8.swift @@ -19,7 +19,7 @@ enum Example8 { directory: "directory" ), returnValue: DebugVariableValue.integerValue( - + 1 ), expressionLocation: ExpressionLocation( start: 1, @@ -34,14 +34,14 @@ enum Example8 { Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ), Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ) @@ -58,7 +58,7 @@ enum Example8 { directory: "directory" ), returnValue: DebugVariableValue.integerValue( - + 1 ), expressionLocation: ExpressionLocation( start: 1, @@ -73,14 +73,14 @@ enum Example8 { Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ), Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ) diff --git a/seed/swift-sdk/trace/Tests/Wire/Resources/Migration/MigrationClientWireTests.swift b/seed/swift-sdk/trace/Tests/Wire/Resources/Migration/MigrationClientWireTests.swift index a31558ac7b2e..5f4aa836cf43 100644 --- a/seed/swift-sdk/trace/Tests/Wire/Resources/Migration/MigrationClientWireTests.swift +++ b/seed/swift-sdk/trace/Tests/Wire/Resources/Migration/MigrationClientWireTests.swift @@ -36,7 +36,10 @@ import Trace status: .running ) ] - let response = try await client.migration.getAttemptedMigrations(requestOptions: RequestOptions(additionalHeaders: stub.headers)) + let response = try await client.migration.getAttemptedMigrations( + adminKeyHeader: "admin-key-header", + requestOptions: RequestOptions(additionalHeaders: stub.headers) + ) try #require(response == expectedResponse) } } \ No newline at end of file diff --git a/seed/swift-sdk/trace/Tests/Wire/Resources/Playlist/PlaylistClientWireTests.swift b/seed/swift-sdk/trace/Tests/Wire/Resources/Playlist/PlaylistClientWireTests.swift index e5928f33ca30..34b4e049bc7a 100644 --- a/seed/swift-sdk/trace/Tests/Wire/Resources/Playlist/PlaylistClientWireTests.swift +++ b/seed/swift-sdk/trace/Tests/Wire/Resources/Playlist/PlaylistClientWireTests.swift @@ -26,13 +26,13 @@ import Trace urlSession: stub.urlSession ) let expectedResponse = Playlist( - playlistId: "playlist_id", - ownerId: "owner-id", name: "name", problems: [ "problems", "problems" - ] + ], + playlistId: "playlist_id", + ownerId: "owner-id" ) let response = try await client.playlist.createPlaylist( serviceParam: "1", @@ -85,22 +85,22 @@ import Trace ) let expectedResponse = [ Playlist( - playlistId: "playlist_id", - ownerId: "owner-id", name: "name", problems: [ "problems", "problems" - ] + ], + playlistId: "playlist_id", + ownerId: "owner-id" ), Playlist( - playlistId: "playlist_id", - ownerId: "owner-id", name: "name", problems: [ "problems", "problems" - ] + ], + playlistId: "playlist_id", + ownerId: "owner-id" ) ] let response = try await client.playlist.getPlaylists( @@ -136,13 +136,13 @@ import Trace urlSession: stub.urlSession ) let expectedResponse = Playlist( - playlistId: "playlist_id", - ownerId: "owner-id", name: "name", problems: [ "problems", "problems" - ] + ], + playlistId: "playlist_id", + ownerId: "owner-id" ) let response = try await client.playlist.getPlaylist( serviceParam: "1", @@ -175,13 +175,13 @@ import Trace urlSession: stub.urlSession ) let expectedResponse = Optional(Playlist( - playlistId: "playlist_id", - ownerId: "owner-id", name: "name", problems: [ "problems", "problems" - ] + ], + playlistId: "playlist_id", + ownerId: "owner-id" )) let response = try await client.playlist.updatePlaylist( serviceParam: "1", diff --git a/seed/swift-sdk/trace/Tests/Wire/Resources/Problem/ProblemClientWireTests.swift b/seed/swift-sdk/trace/Tests/Wire/Resources/Problem/ProblemClientWireTests.swift index 86bee94d2149..5558c8538ae5 100644 --- a/seed/swift-sdk/trace/Tests/Wire/Resources/Problem/ProblemClientWireTests.swift +++ b/seed/swift-sdk/trace/Tests/Wire/Resources/Problem/ProblemClientWireTests.swift @@ -27,10 +27,10 @@ import Trace problemDescription: ProblemDescription( boards: [ ProblemDescriptionBoard.html( - + "boards" ), ProblemDescriptionBoard.html( - + "boards" ) ] ), @@ -69,15 +69,15 @@ import Trace id: "id", params: [ VariableValue.integerValue( - + 1 ), VariableValue.integerValue( - + 1 ) ] ), expectedResult: VariableValue.integerValue( - + 1 ) ), TestCaseWithExpectedResult( @@ -85,15 +85,15 @@ import Trace id: "id", params: [ VariableValue.integerValue( - + 1 ), VariableValue.integerValue( - + 1 ) ] ), expectedResult: VariableValue.integerValue( - + 1 ) ) ], @@ -130,10 +130,10 @@ import Trace problemDescription: ProblemDescription( boards: [ ProblemDescriptionBoard.html( - + "boards" ), ProblemDescriptionBoard.html( - + "boards" ) ] ), @@ -172,15 +172,15 @@ import Trace id: "id", params: [ VariableValue.integerValue( - + 1 ), VariableValue.integerValue( - + 1 ) ] ), expectedResult: VariableValue.integerValue( - + 1 ) ), TestCaseWithExpectedResult( @@ -188,15 +188,15 @@ import Trace id: "id", params: [ VariableValue.integerValue( - + 1 ), VariableValue.integerValue( - + 1 ) ] ), expectedResult: VariableValue.integerValue( - + 1 ) ) ], diff --git a/seed/swift-sdk/trace/reference.md b/seed/swift-sdk/trace/reference.md index 138fa59b2483..29e4aaf7e48d 100644 --- a/seed/swift-sdk/trace/reference.md +++ b/seed/swift-sdk/trace/reference.md @@ -142,7 +142,7 @@ private func main() async throws { request: TestSubmissionUpdate( updateTime: try! Date("2024-01-15T09:30:00Z", strategy: .iso8601), updateInfo: TestSubmissionUpdateInfo.running( - + .queueingSubmission ) ) ) @@ -283,7 +283,7 @@ private func main() async throws { request: WorkspaceSubmissionUpdate( updateTime: try! Date("2024-01-15T09:30:00Z", strategy: .iso8601), updateInfo: WorkspaceSubmissionUpdateInfo.running( - + .queueingSubmission ) ) ) @@ -358,11 +358,11 @@ private func main() async throws { result: TestCaseResultWithStdout( result: TestCaseResult( expectedResult: VariableValue.integerValue( - + 1 ), actualResult: ActualResult.value( VariableValue.integerValue( - + 1 ) ), passed: true @@ -374,7 +374,7 @@ private func main() async throws { submissionId: UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!, lineNumber: 1, returnValue: DebugVariableValue.integerValue( - + 1 ), expressionLocation: ExpressionLocation( start: 1, @@ -389,14 +389,14 @@ private func main() async throws { Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ), Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ) @@ -409,7 +409,7 @@ private func main() async throws { submissionId: UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!, lineNumber: 1, returnValue: DebugVariableValue.integerValue( - + 1 ), expressionLocation: ExpressionLocation( start: 1, @@ -424,14 +424,14 @@ private func main() async throws { Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ), Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ) @@ -527,7 +527,7 @@ private func main() async throws { directory: "directory" ), returnValue: DebugVariableValue.integerValue( - + 1 ), expressionLocation: ExpressionLocation( start: 1, @@ -542,14 +542,14 @@ private func main() async throws { Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ), Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ) @@ -566,7 +566,7 @@ private func main() async throws { directory: "directory" ), returnValue: DebugVariableValue.integerValue( - + 1 ), expressionLocation: ExpressionLocation( start: 1, @@ -581,14 +581,14 @@ private func main() async throws { Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ), Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ) @@ -694,7 +694,7 @@ private func main() async throws { submissionId: UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!, lineNumber: 1, returnValue: DebugVariableValue.integerValue( - + 1 ), expressionLocation: ExpressionLocation( start: 1, @@ -709,14 +709,14 @@ private func main() async throws { Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ), Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ) @@ -729,7 +729,7 @@ private func main() async throws { submissionId: UUID(uuidString: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")!, lineNumber: 1, returnValue: DebugVariableValue.integerValue( - + 1 ), expressionLocation: ExpressionLocation( start: 1, @@ -744,14 +744,14 @@ private func main() async throws { Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ), Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ) @@ -838,7 +838,7 @@ private func main() async throws { directory: "directory" ), returnValue: DebugVariableValue.integerValue( - + 1 ), expressionLocation: ExpressionLocation( start: 1, @@ -853,14 +853,14 @@ private func main() async throws { Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ), Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ) @@ -877,7 +877,7 @@ private func main() async throws { directory: "directory" ), returnValue: DebugVariableValue.integerValue( - + 1 ), expressionLocation: ExpressionLocation( start: 1, @@ -892,14 +892,14 @@ private func main() async throws { Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ), Scope( variables: [ "variables": DebugVariableValue.integerValue( - + 1 ) ] ) @@ -1085,7 +1085,7 @@ import Trace private func main() async throws { let client = TraceClient(token: "") - _ = try await client.migration.getAttemptedMigrations() + _ = try await client.migration.getAttemptedMigrations(adminKeyHeader: "admin-key-header") } try await main() @@ -1649,10 +1649,10 @@ private func main() async throws { problemDescription: ProblemDescription( boards: [ ProblemDescriptionBoard.html( - + "boards" ), ProblemDescriptionBoard.html( - + "boards" ) ] ), @@ -1691,15 +1691,15 @@ private func main() async throws { id: "id", params: [ VariableValue.integerValue( - + 1 ), VariableValue.integerValue( - + 1 ) ] ), expectedResult: VariableValue.integerValue( - + 1 ) ), TestCaseWithExpectedResult( @@ -1707,15 +1707,15 @@ private func main() async throws { id: "id", params: [ VariableValue.integerValue( - + 1 ), VariableValue.integerValue( - + 1 ) ] ), expectedResult: VariableValue.integerValue( - + 1 ) ) ], @@ -1798,10 +1798,10 @@ private func main() async throws { problemDescription: ProblemDescription( boards: [ ProblemDescriptionBoard.html( - + "boards" ), ProblemDescriptionBoard.html( - + "boards" ) ] ), @@ -1840,15 +1840,15 @@ private func main() async throws { id: "id", params: [ VariableValue.integerValue( - + 1 ), VariableValue.integerValue( - + 1 ) ] ), expectedResult: VariableValue.integerValue( - + 1 ) ), TestCaseWithExpectedResult( @@ -1856,15 +1856,15 @@ private func main() async throws { id: "id", params: [ VariableValue.integerValue( - + 1 ), VariableValue.integerValue( - + 1 ) ] ), expectedResult: VariableValue.integerValue( - + 1 ) ) ], diff --git a/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/Key.swift b/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/Key.swift index ba6da34362ee..d2068bfdfcab 100644 --- a/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/Key.swift +++ b/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/Key.swift @@ -1,15 +1,15 @@ import Foundation public enum Key: Codable, Hashable, Sendable { - case `default`(Default) case keyType(KeyType) + case `default`(Default) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(Default.self) { - self = .default(value) - } else if let value = try? container.decode(KeyType.self) { + if let value = try? container.decode(KeyType.self) { self = .keyType(value) + } else if let value = try? container.decode(Default.self) { + self = .default(value) } else { throw DecodingError.dataCorruptedError( in: container, @@ -21,10 +21,10 @@ public enum Key: Codable, Hashable, Sendable { public func encode(to encoder: Encoder) throws -> Void { var container = encoder.singleValueContainer() switch self { - case .default(let value): - try container.encode(value) case .keyType(let value): try container.encode(value) + case .default(let value): + try container.encode(value) } } diff --git a/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/MetadataUnion.swift b/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/MetadataUnion.swift index f2ab538b03cd..0d58770021ce 100644 --- a/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/MetadataUnion.swift +++ b/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/MetadataUnion.swift @@ -1,15 +1,15 @@ import Foundation public enum MetadataUnion: Codable, Hashable, Sendable { - case namedMetadata(NamedMetadata) case optionalMetadata(OptionalMetadata) + case namedMetadata(NamedMetadata) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(NamedMetadata.self) { - self = .namedMetadata(value) - } else if let value = try? container.decode(OptionalMetadata.self) { + if let value = try? container.decode(OptionalMetadata.self) { self = .optionalMetadata(value) + } else if let value = try? container.decode(NamedMetadata.self) { + self = .namedMetadata(value) } else { throw DecodingError.dataCorruptedError( in: container, @@ -21,10 +21,10 @@ public enum MetadataUnion: Codable, Hashable, Sendable { public func encode(to encoder: Encoder) throws -> Void { var container = encoder.singleValueContainer() switch self { - case .namedMetadata(let value): - try container.encode(value) case .optionalMetadata(let value): try container.encode(value) + case .namedMetadata(let value): + try container.encode(value) } } } \ No newline at end of file diff --git a/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/MyUnion.swift b/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/MyUnion.swift index 1021d3b45f1a..1116fc747e0d 100644 --- a/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/MyUnion.swift +++ b/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/MyUnion.swift @@ -2,16 +2,20 @@ import Foundation /// Several different types are accepted. public enum MyUnion: Codable, Hashable, Sendable { + case string(String) + case stringArray([String]) case int(Int) case intArray([Int]) case intArrayArray([[Int]]) case jsonValue(JSONValue) - case string(String) - case stringArray([String]) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(Int.self) { + if let value = try? container.decode(String.self) { + self = .string(value) + } else if let value = try? container.decode([String].self) { + self = .stringArray(value) + } else if let value = try? container.decode(Int.self) { self = .int(value) } else if let value = try? container.decode([Int].self) { self = .intArray(value) @@ -19,10 +23,6 @@ public enum MyUnion: Codable, Hashable, Sendable { self = .intArrayArray(value) } else if let value = try? container.decode(JSONValue.self) { self = .jsonValue(value) - } else if let value = try? container.decode(String.self) { - self = .string(value) - } else if let value = try? container.decode([String].self) { - self = .stringArray(value) } else { throw DecodingError.dataCorruptedError( in: container, @@ -34,6 +34,10 @@ public enum MyUnion: Codable, Hashable, Sendable { public func encode(to encoder: Encoder) throws -> Void { var container = encoder.singleValueContainer() switch self { + case .string(let value): + try container.encode(value) + case .stringArray(let value): + try container.encode(value) case .int(let value): try container.encode(value) case .intArray(let value): @@ -42,10 +46,6 @@ public enum MyUnion: Codable, Hashable, Sendable { try container.encode(value) case .jsonValue(let value): try container.encode(value) - case .string(let value): - try container.encode(value) - case .stringArray(let value): - try container.encode(value) } } } \ No newline at end of file diff --git a/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/NestedUnionL1.swift b/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/NestedUnionL1.swift index 61ebfbb2236f..7073e708b6f4 100644 --- a/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/NestedUnionL1.swift +++ b/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/NestedUnionL1.swift @@ -4,8 +4,8 @@ import Foundation public enum NestedUnionL1: Codable, Hashable, Sendable { case int(Int) case jsonValue(JSONValue) - case nestedUnionL2(NestedUnionL2) case stringArray([String]) + case nestedUnionL2(NestedUnionL2) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() @@ -13,10 +13,10 @@ public enum NestedUnionL1: Codable, Hashable, Sendable { self = .int(value) } else if let value = try? container.decode(JSONValue.self) { self = .jsonValue(value) - } else if let value = try? container.decode(NestedUnionL2.self) { - self = .nestedUnionL2(value) } else if let value = try? container.decode([String].self) { self = .stringArray(value) + } else if let value = try? container.decode(NestedUnionL2.self) { + self = .nestedUnionL2(value) } else { throw DecodingError.dataCorruptedError( in: container, @@ -32,10 +32,10 @@ public enum NestedUnionL1: Codable, Hashable, Sendable { try container.encode(value) case .jsonValue(let value): try container.encode(value) - case .nestedUnionL2(let value): - try container.encode(value) case .stringArray(let value): try container.encode(value) + case .nestedUnionL2(let value): + try container.encode(value) } } } \ No newline at end of file diff --git a/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/NestedUnionRoot.swift b/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/NestedUnionRoot.swift index 1b3a1ade9f72..3e0b31546cfb 100644 --- a/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/NestedUnionRoot.swift +++ b/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/NestedUnionRoot.swift @@ -2,18 +2,18 @@ import Foundation /// Nested union root. public enum NestedUnionRoot: Codable, Hashable, Sendable { - case nestedUnionL1(NestedUnionL1) case string(String) case stringArray([String]) + case nestedUnionL1(NestedUnionL1) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(NestedUnionL1.self) { - self = .nestedUnionL1(value) - } else if let value = try? container.decode(String.self) { + if let value = try? container.decode(String.self) { self = .string(value) } else if let value = try? container.decode([String].self) { self = .stringArray(value) + } else if let value = try? container.decode(NestedUnionL1.self) { + self = .nestedUnionL1(value) } else { throw DecodingError.dataCorruptedError( in: container, @@ -25,12 +25,12 @@ public enum NestedUnionRoot: Codable, Hashable, Sendable { public func encode(to encoder: Encoder) throws -> Void { var container = encoder.singleValueContainer() switch self { - case .nestedUnionL1(let value): - try container.encode(value) case .string(let value): try container.encode(value) case .stringArray(let value): try container.encode(value) + case .nestedUnionL1(let value): + try container.encode(value) } } } \ No newline at end of file diff --git a/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/PaymentMethodUnion.swift b/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/PaymentMethodUnion.swift index 7efe7564dd70..a30df596b484 100644 --- a/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/PaymentMethodUnion.swift +++ b/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/PaymentMethodUnion.swift @@ -3,15 +3,15 @@ import Foundation /// Tests that nested properties with camelCase wire names are properly /// converted from snake_case Ruby keys when passed as Hash values. public enum PaymentMethodUnion: Codable, Hashable, Sendable { - case convertToken(ConvertToken) case tokenizeCard(TokenizeCard) + case convertToken(ConvertToken) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(ConvertToken.self) { - self = .convertToken(value) - } else if let value = try? container.decode(TokenizeCard.self) { + if let value = try? container.decode(TokenizeCard.self) { self = .tokenizeCard(value) + } else if let value = try? container.decode(ConvertToken.self) { + self = .convertToken(value) } else { throw DecodingError.dataCorruptedError( in: container, @@ -23,10 +23,10 @@ public enum PaymentMethodUnion: Codable, Hashable, Sendable { public func encode(to encoder: Encoder) throws -> Void { var container = encoder.singleValueContainer() switch self { - case .convertToken(let value): - try container.encode(value) case .tokenizeCard(let value): try container.encode(value) + case .convertToken(let value): + try container.encode(value) } } } \ No newline at end of file diff --git a/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/UnionWithDuplicateTypes.swift b/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/UnionWithDuplicateTypes.swift index 5b60a28ebb05..9db023743798 100644 --- a/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/UnionWithDuplicateTypes.swift +++ b/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/UnionWithDuplicateTypes.swift @@ -2,21 +2,21 @@ import Foundation /// Duplicate types. public enum UnionWithDuplicateTypes: Codable, Hashable, Sendable { - case int(Int) - case jsonValue(JSONValue) case string(String) case stringArray([String]) + case int(Int) + case jsonValue(JSONValue) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(Int.self) { - self = .int(value) - } else if let value = try? container.decode(JSONValue.self) { - self = .jsonValue(value) - } else if let value = try? container.decode(String.self) { + if let value = try? container.decode(String.self) { self = .string(value) } else if let value = try? container.decode([String].self) { self = .stringArray(value) + } else if let value = try? container.decode(Int.self) { + self = .int(value) + } else if let value = try? container.decode(JSONValue.self) { + self = .jsonValue(value) } else { throw DecodingError.dataCorruptedError( in: container, @@ -28,14 +28,14 @@ public enum UnionWithDuplicateTypes: Codable, Hashable, Sendable { public func encode(to encoder: Encoder) throws -> Void { var container = encoder.singleValueContainer() switch self { - case .int(let value): - try container.encode(value) - case .jsonValue(let value): - try container.encode(value) case .string(let value): try container.encode(value) case .stringArray(let value): try container.encode(value) + case .int(let value): + try container.encode(value) + case .jsonValue(let value): + try container.encode(value) } } } \ No newline at end of file diff --git a/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/UnionWithIdenticalPrimitives.swift b/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/UnionWithIdenticalPrimitives.swift index 7385fbd9c474..9b38e6357d6b 100644 --- a/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/UnionWithIdenticalPrimitives.swift +++ b/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/UnionWithIdenticalPrimitives.swift @@ -2,16 +2,16 @@ import Foundation /// Mix of primitives where some resolve to the same Java type. public enum UnionWithIdenticalPrimitives: Codable, Hashable, Sendable { - case double(Double) case int(Int) + case double(Double) case string(String) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(Double.self) { - self = .double(value) - } else if let value = try? container.decode(Int.self) { + if let value = try? container.decode(Int.self) { self = .int(value) + } else if let value = try? container.decode(Double.self) { + self = .double(value) } else if let value = try? container.decode(String.self) { self = .string(value) } else { @@ -25,10 +25,10 @@ public enum UnionWithIdenticalPrimitives: Codable, Hashable, Sendable { public func encode(to encoder: Encoder) throws -> Void { var container = encoder.singleValueContainer() switch self { - case .double(let value): - try container.encode(value) case .int(let value): try container.encode(value) + case .double(let value): + try container.encode(value) case .string(let value): try container.encode(value) } diff --git a/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/UnionWithReservedNames.swift b/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/UnionWithReservedNames.swift index a4899c4a09c2..c36958f4f959 100644 --- a/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/UnionWithReservedNames.swift +++ b/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/UnionWithReservedNames.swift @@ -2,18 +2,18 @@ import Foundation /// Tests that union members named 'Type' or 'Value' don't collide with internal properties public enum UnionWithReservedNames: Codable, Hashable, Sendable { - case string(String) case type(`Type`) case value(Value) + case string(String) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(String.self) { - self = .string(value) - } else if let value = try? container.decode(`Type`.self) { + if let value = try? container.decode(`Type`.self) { self = .type(value) } else if let value = try? container.decode(Value.self) { self = .value(value) + } else if let value = try? container.decode(String.self) { + self = .string(value) } else { throw DecodingError.dataCorruptedError( in: container, @@ -25,12 +25,12 @@ public enum UnionWithReservedNames: Codable, Hashable, Sendable { public func encode(to encoder: Encoder) throws -> Void { var container = encoder.singleValueContainer() switch self { - case .string(let value): - try container.encode(value) case .type(let value): try container.encode(value) case .value(let value): try container.encode(value) + case .string(let value): + try container.encode(value) } } diff --git a/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/UnionWithTypeAliases.swift b/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/UnionWithTypeAliases.swift index 7abe5ab5eb9f..4b7c62532fc7 100644 --- a/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/UnionWithTypeAliases.swift +++ b/seed/swift-sdk/undiscriminated-unions/Sources/Schemas/UnionWithTypeAliases.swift @@ -7,18 +7,18 @@ import Foundation /// public static implicit operator UnionWithTypeAliases(string value) => ... /// causing CS0557 compiler error. public enum UnionWithTypeAliases: Codable, Hashable, Sendable { - case name(Name) case string(String) case userId(UserId) + case name(Name) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(Name.self) { - self = .name(value) - } else if let value = try? container.decode(String.self) { + if let value = try? container.decode(String.self) { self = .string(value) } else if let value = try? container.decode(UserId.self) { self = .userId(value) + } else if let value = try? container.decode(Name.self) { + self = .name(value) } else { throw DecodingError.dataCorruptedError( in: container, @@ -30,12 +30,12 @@ public enum UnionWithTypeAliases: Codable, Hashable, Sendable { public func encode(to encoder: Encoder) throws -> Void { var container = encoder.singleValueContainer() switch self { - case .name(let value): - try container.encode(value) case .string(let value): try container.encode(value) case .userId(let value): try container.encode(value) + case .name(let value): + try container.encode(value) } } } \ No newline at end of file diff --git a/seed/swift-sdk/undiscriminated-unions/Tests/Wire/Resources/Union/UnionClientWireTests.swift b/seed/swift-sdk/undiscriminated-unions/Tests/Wire/Resources/Union/UnionClientWireTests.swift index 226da50c2b1c..becd8066fca8 100644 --- a/seed/swift-sdk/undiscriminated-unions/Tests/Wire/Resources/Union/UnionClientWireTests.swift +++ b/seed/swift-sdk/undiscriminated-unions/Tests/Wire/Resources/Union/UnionClientWireTests.swift @@ -8,7 +8,7 @@ import UndiscriminatedUnions stub.setResponse( body: Data( #""" - string + "string" """#.utf8 ) ) @@ -201,7 +201,7 @@ import UndiscriminatedUnions stub.setResponse( body: Data( #""" - string + "string" """#.utf8 ) ) diff --git a/seed/swift-sdk/unions-with-local-date/Tests/Snippets/Example6.swift b/seed/swift-sdk/unions-with-local-date/Tests/Snippets/Example6.swift index 6e19b8940761..20b2cf78e37f 100644 --- a/seed/swift-sdk/unions-with-local-date/Tests/Snippets/Example6.swift +++ b/seed/swift-sdk/unions-with-local-date/Tests/Snippets/Example6.swift @@ -6,7 +6,7 @@ enum Example6 { let client = UnionsClient(baseURL: "https://api.fern.com") _ = try await client.types.update(request: UnionWithTime.date( - + CalendarDate("1994-01-01")! )) } } diff --git a/seed/swift-sdk/unions-with-local-date/Tests/Snippets/Example7.swift b/seed/swift-sdk/unions-with-local-date/Tests/Snippets/Example7.swift index ada6034c4846..6c87983d7377 100644 --- a/seed/swift-sdk/unions-with-local-date/Tests/Snippets/Example7.swift +++ b/seed/swift-sdk/unions-with-local-date/Tests/Snippets/Example7.swift @@ -6,7 +6,7 @@ enum Example7 { let client = UnionsClient(baseURL: "https://api.fern.com") _ = try await client.types.update(request: UnionWithTime.datetime( - + try! Date("1994-01-01T01:01:01Z", strategy: .iso8601) )) } } diff --git a/seed/swift-sdk/unions-with-local-date/Tests/Wire/Resources/Types/TypesClientWireTests.swift b/seed/swift-sdk/unions-with-local-date/Tests/Wire/Resources/Types/TypesClientWireTests.swift index 42e04859b0f0..fab3dcdff4de 100644 --- a/seed/swift-sdk/unions-with-local-date/Tests/Wire/Resources/Types/TypesClientWireTests.swift +++ b/seed/swift-sdk/unions-with-local-date/Tests/Wire/Resources/Types/TypesClientWireTests.swift @@ -91,7 +91,7 @@ import Unions let expectedResponse = true let response = try await client.types.update( request: UnionWithTime.date( - + CalendarDate("1994-01-01")! ), requestOptions: RequestOptions(additionalHeaders: stub.headers) ) @@ -114,7 +114,7 @@ import Unions let expectedResponse = true let response = try await client.types.update( request: UnionWithTime.datetime( - + try! Date("1994-01-01T01:01:01Z", strategy: .iso8601) ), requestOptions: RequestOptions(additionalHeaders: stub.headers) ) diff --git a/seed/swift-sdk/unions-with-local-date/reference.md b/seed/swift-sdk/unions-with-local-date/reference.md index babaf97416b1..2cbc0ad18703 100644 --- a/seed/swift-sdk/unions-with-local-date/reference.md +++ b/seed/swift-sdk/unions-with-local-date/reference.md @@ -264,7 +264,7 @@ private func main() async throws { let client = UnionsClient() _ = try await client.types.update(request: UnionWithTime.date( - + CalendarDate("1994-01-01")! )) } diff --git a/seed/swift-sdk/websocket-inferred-auth/README.md b/seed/swift-sdk/websocket-inferred-auth/README.md index 459d06ca7299..350f8dbd6cf7 100644 --- a/seed/swift-sdk/websocket-inferred-auth/README.md +++ b/seed/swift-sdk/websocket-inferred-auth/README.md @@ -54,13 +54,16 @@ import WebsocketAuth private func main() async throws { let client = WebsocketAuthClient() - _ = try await client.auth.getTokenWithClientCredentials(request: .init( - clientId: "client_id", - clientSecret: "client_secret", - audience: .httpsApiExampleCom, - grantType: .clientCredentials, - scope: "scope" - )) + _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", + request: .init( + clientId: "client_id", + clientSecret: "client_secret", + audience: .httpsApiExampleCom, + grantType: .clientCredentials, + scope: "scope" + ) + ) } try await main() diff --git a/seed/swift-sdk/websocket-inferred-auth/Tests/Core/ClientErrorTests.swift b/seed/swift-sdk/websocket-inferred-auth/Tests/Core/ClientErrorTests.swift index a39d4339f673..bf1c7a19bc12 100644 --- a/seed/swift-sdk/websocket-inferred-auth/Tests/Core/ClientErrorTests.swift +++ b/seed/swift-sdk/websocket-inferred-auth/Tests/Core/ClientErrorTests.swift @@ -20,6 +20,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -59,6 +60,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -98,6 +100,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -139,6 +142,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -178,6 +182,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -219,6 +224,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -258,6 +264,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", diff --git a/seed/swift-sdk/websocket-inferred-auth/Tests/Core/ClientRetryTests.swift b/seed/swift-sdk/websocket-inferred-auth/Tests/Core/ClientRetryTests.swift index 1898354a3199..f7da18da36af 100644 --- a/seed/swift-sdk/websocket-inferred-auth/Tests/Core/ClientRetryTests.swift +++ b/seed/swift-sdk/websocket-inferred-auth/Tests/Core/ClientRetryTests.swift @@ -21,6 +21,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -54,6 +55,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -87,6 +89,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -119,6 +122,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -150,6 +154,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -182,6 +187,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -214,6 +220,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -251,6 +258,7 @@ import Testing let startTime = Date() do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -298,6 +306,7 @@ import Testing let startTime = Date() do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -341,6 +350,7 @@ import Testing let startTime = Date() do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -395,6 +405,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -423,6 +434,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -455,6 +467,7 @@ import Testing do { _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", diff --git a/seed/swift-sdk/websocket-inferred-auth/Tests/Snippets/Example0.swift b/seed/swift-sdk/websocket-inferred-auth/Tests/Snippets/Example0.swift index 293f943241b6..2285dc783f90 100644 --- a/seed/swift-sdk/websocket-inferred-auth/Tests/Snippets/Example0.swift +++ b/seed/swift-sdk/websocket-inferred-auth/Tests/Snippets/Example0.swift @@ -5,12 +5,15 @@ enum Example0 { static func snippet() async throws { let client = WebsocketAuthClient(baseURL: "https://api.fern.com") - _ = try await client.auth.getTokenWithClientCredentials(request: .init( - clientId: "client_id", - clientSecret: "client_secret", - audience: .httpsApiExampleCom, - grantType: .clientCredentials, - scope: "scope" - )) + _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", + request: .init( + clientId: "client_id", + clientSecret: "client_secret", + audience: .httpsApiExampleCom, + grantType: .clientCredentials, + scope: "scope" + ) + ) } } diff --git a/seed/swift-sdk/websocket-inferred-auth/Tests/Snippets/Example1.swift b/seed/swift-sdk/websocket-inferred-auth/Tests/Snippets/Example1.swift index f157712181e0..1eadaee803ca 100644 --- a/seed/swift-sdk/websocket-inferred-auth/Tests/Snippets/Example1.swift +++ b/seed/swift-sdk/websocket-inferred-auth/Tests/Snippets/Example1.swift @@ -5,13 +5,16 @@ enum Example1 { static func snippet() async throws { let client = WebsocketAuthClient(baseURL: "https://api.fern.com") - _ = try await client.auth.refreshToken(request: .init( - clientId: "client_id", - clientSecret: "client_secret", - refreshToken: "refresh_token", - audience: .httpsApiExampleCom, - grantType: .refreshToken, - scope: "scope" - )) + _ = try await client.auth.refreshToken( + xApiKey: "X-Api-Key", + request: .init( + clientId: "client_id", + clientSecret: "client_secret", + refreshToken: "refresh_token", + audience: .httpsApiExampleCom, + grantType: .refreshToken, + scope: "scope" + ) + ) } } diff --git a/seed/swift-sdk/websocket-inferred-auth/Tests/Wire/Resources/Auth/AuthClientWireTests.swift b/seed/swift-sdk/websocket-inferred-auth/Tests/Wire/Resources/Auth/AuthClientWireTests.swift index e46d9a7765de..02a50eae2236 100644 --- a/seed/swift-sdk/websocket-inferred-auth/Tests/Wire/Resources/Auth/AuthClientWireTests.swift +++ b/seed/swift-sdk/websocket-inferred-auth/Tests/Wire/Resources/Auth/AuthClientWireTests.swift @@ -24,6 +24,7 @@ import WebsocketAuth refreshToken: Optional("refresh_token") ) let response = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", @@ -57,6 +58,7 @@ import WebsocketAuth refreshToken: Optional("refresh_token") ) let response = try await client.auth.refreshToken( + xApiKey: "X-Api-Key", request: .init( clientId: "client_id", clientSecret: "client_secret", diff --git a/seed/swift-sdk/websocket-inferred-auth/reference.md b/seed/swift-sdk/websocket-inferred-auth/reference.md index 373cee0eeeea..6748ef62ab64 100644 --- a/seed/swift-sdk/websocket-inferred-auth/reference.md +++ b/seed/swift-sdk/websocket-inferred-auth/reference.md @@ -19,13 +19,16 @@ import WebsocketAuth private func main() async throws { let client = WebsocketAuthClient() - _ = try await client.auth.getTokenWithClientCredentials(request: .init( - clientId: "client_id", - clientSecret: "client_secret", - audience: .httpsApiExampleCom, - grantType: .clientCredentials, - scope: "scope" - )) + _ = try await client.auth.getTokenWithClientCredentials( + xApiKey: "X-Api-Key", + request: .init( + clientId: "client_id", + clientSecret: "client_secret", + audience: .httpsApiExampleCom, + grantType: .clientCredentials, + scope: "scope" + ) + ) } try await main() @@ -90,14 +93,17 @@ import WebsocketAuth private func main() async throws { let client = WebsocketAuthClient() - _ = try await client.auth.refreshToken(request: .init( - clientId: "client_id", - clientSecret: "client_secret", - refreshToken: "refresh_token", - audience: .httpsApiExampleCom, - grantType: .refreshToken, - scope: "scope" - )) + _ = try await client.auth.refreshToken( + xApiKey: "X-Api-Key", + request: .init( + clientId: "client_id", + clientSecret: "client_secret", + refreshToken: "refresh_token", + audience: .httpsApiExampleCom, + grantType: .refreshToken, + scope: "scope" + ) + ) } try await main()