Skip to content

Conversation

@jsklan
Copy link
Contributor

@jsklan jsklan commented Jan 26, 2026

Description

Refs: Request from @jsklan

Link to Devin run

Enables wire tests for the Swift SDK exhaustive fixture by fixing several issues in the dynamic snippet generator and wire test generator.

Changes Made

Swift Dynamic Snippets (EndpointSnippetGenerator.ts)

  • Added endpoint-level header handling that filters out service-level headers (service-level headers are handled at client constructor level, not in endpoint method calls)
  • Fixed referenced body types to be passed directly instead of wrapped in .init(body: ...)

Swift Dynamic Snippets (DynamicTypeLiteralMapper.ts)

  • Added comprehensive JSONValue conversion system for set types (Swift sets are represented as JSONValue.array([...]))
  • Handles nested types within sets including primitives, objects, lists, and optionals

Swift Wire Test Generator (WireTestFunctionGenerator.ts)

  • Fixed enum and union types to use full type names (e.g., Animal.dog instead of .dog) for proper Swift type inference
  • Fixed set types to use JSONValue conversion in test assertions
  • Fixed response body formatting to distinguish between string responses (raw UTF-8) and other types (JSON-encoded) - this matches how the Swift SDK's HTTPClient handles different response types

Test Definitions

  • Added user-specified examples to set<T> endpoints in exhaustive fixture to ensure autogenerated examples include request body values (with proper response fields)

Testing

  • Seed tests pass for swift-sdk exhaustive fixture (including wire tests)
  • Lint checks pass
  • Swift dynamic snippets unit test snapshots updated
  • IR generator test snapshots updated (examples.json, exhaustive.json)
  • fern check passes for exhaustive fixture

Review Checklist

  • Verify the JSONValue conversion in DynamicTypeLiteralMapper.ts handles all type cases correctly
  • Check that isStringResponseType() in WireTestFunctionGenerator.ts correctly resolves type aliases
  • Verify the service-level header filtering logic in EndpointSnippetGenerator.ts correctly identifies headers from this.context.ir.headers
  • Verify referenced body type handling doesn't break other endpoints that use simple request bodies

Updates since last revision

  • Reverted the dynamic IR change (DynamicSnippetsConverter.ts) that was filtering service-level headers at the IR level - this was breaking other generators (e.g., PHP SDK)
  • Moved the service-level header filtering to the Swift dynamic snippet generator specifically (EndpointSnippetGenerator.ts), so it only affects Swift and not other generators
  • Fixed biome formatting issue

jsklan and others added 2 commits January 26, 2026 13:52
- Fix dynamic IR to only include endpoint-level headers (not service-level)
- Fix Swift dynamic snippet generator to handle endpoint-level headers
- Fix Swift dynamic snippet generator to handle referenced body types correctly
- Fix Swift dynamic snippet generator to convert set types to JSONValue expressions
- Fix wire test generator to use full type names for enum and union types
- Fix wire test generator to handle set types with JSONValue conversion
- Fix wire test generator to properly format string vs JSON response types
- Add user-specified examples to set<T> endpoints in exhaustive fixture

Co-Authored-By: [email protected] <[email protected]>
@devin-ai-integration
Copy link
Contributor

devin-ai-integration bot commented Jan 26, 2026

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@fern-support fern-support changed the title fix: Enable wire tests for Swift SDK exhaustive fixture fix(swift): Enable wire tests for Swift SDK exhaustive fixture Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants