Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Nov 20, 2025

Description

Linear ticket: Refs https://buildwithfern.slack.com/archives/C09NULAN2H3/p1763394573684379

This PR adds support for wildcard status codes (4XX and 5XX) in the IR schema and passes this information through to the FDR SDK. This is part of a larger effort to properly represent and display wildcard status codes in the OpenAPI parser and frontend.

Context: When parsing OpenAPI specs with 4XX or 5XX response codes, we were converting them to base values (400/500) but losing the information that they represent wildcards. This PR adds an isWildcardStatusCode field to track this information through the IR.

Changes Made

  • Added isWildcardStatusCode: optional<boolean> field to HttpResponse and ErrorDeclaration types in IR schema
  • Updated OpenAPI v3 parser to detect wildcard status codes using regex /^[45]XX$/i and set the flag appropriately
  • Updated FDR converter to pass through isWildcard field to FDR SDK (set to true for wildcards, undefined for non-wildcards)
  • Updated all IR generators (openapi, openrpc, protoc-gen-fern, ir-generator) to include isWildcardStatusCode: undefined for non-wildcard responses
  • Updated test snapshots to include the new field
  • Updated README.md generator (not applicable)

Testing

  • Unit tests added/updated - Updated existing test snapshots to include new field
  • Manual testing completed - Verified TypeScript compilation passes and tests pass locally

Note: The gRPC test was skipped locally due to missing buf/protoc-gen-openapi dependencies (requires Go). The gRPC IR snapshot was updated manually based on the expected output format.

Important Review Points

  1. TypeScript Type Handling: The FDR converter uses isWildcard: condition === true ? true : undefined instead of conditional spread operators. This is because FDR SDK types define isWildcard: boolean | undefined (required property that can be undefined) not isWildcard?: boolean (optional property). The property must exist on the object.

  2. Wildcard Detection: The regex /^[45]XX$/i detects 4XX and 5XX patterns (case-insensitive). When detected, the status code is set to the base value (400 for 4XX, 500 for 5XX) and isWildcardStatusCode is set to true.

  3. Manual Snapshot Updates: The gRPC IR snapshot (grpc-comments-ir.snap) was updated manually because the test requires Go tooling that isn't installed on the VM. Please verify these changes are correct.

  4. Backward Compatibility: All non-wildcard responses now include isWildcardStatusCode: undefined. This should be backward compatible since the field is optional in the schema.


Requested by: [email protected] ([email protected])
Session: https://app.devin.ai/sessions/a0f73c8e74ac4d37858f2c845136bbe8

…to FDR

- Add isWildcardStatusCode field to IR schema (errors.yml and http.yml)
- Update IR SDK TypeScript interfaces and serialization
- Update OpenAPI parser to detect 4XX/5XX wildcards and set isWildcardStatusCode=true
- Update IR-to-FDR converter to pass isWildcardStatusCode as isWildcard to FDR
- Update test snapshots with new isWildcard field

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

🤖 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

@devin-ai-integration devin-ai-integration bot changed the title feat(openapi): add isWildcardStatusCode field to IR and pass through to FDR feat(openapi): add support for 4XX/5XX wildcard status codes in OpenAPI v3 Nov 20, 2025
@devin-ai-integration devin-ai-integration bot changed the title feat(openapi): add support for 4XX/5XX wildcard status codes in OpenAPI v3 feat(openapi): add support for 4XX/5XX wildcard status codes Nov 20, 2025
@devin-ai-integration devin-ai-integration bot changed the title feat(openapi): add support for 4XX/5XX wildcard status codes feat(openapi): add isWildcardStatusCode field to IR and conditionally emit to FDR Nov 20, 2025
@devin-ai-integration devin-ai-integration bot changed the title feat(openapi): add isWildcardStatusCode field to IR and conditionally emit to FDR feat(cli): add isWildcardStatusCode field to IR and pass through to FDR Nov 20, 2025
@devin-ai-integration devin-ai-integration bot changed the title feat(cli): add isWildcardStatusCode field to IR and pass through to FDR feat(cli): add isWildcardStatusCode field to IR for 4XX/5XX support Nov 20, 2025
…rom IR generators

The IR SDK serializer automatically includes optional fields in the serialized output
when they are defined on the TypeScript interface (structural typing). Explicitly
setting isWildcardStatusCode to undefined was redundant and could cause serialization
inconsistencies between undefined and null in different contexts.

This change removes the explicit undefined assignments and lets the IR SDK handle
the field serialization, which correctly includes 'isWildcardStatusCode: undefined'
for non-wildcard status codes in the IR snapshots.

Co-Authored-By: [email protected] <[email protected]>
…ructural typing

TypeScript's structural typing requires the isWildcardStatusCode property to exist
on ErrorDeclaration and HttpResponse objects because the IR SDK defines it as
'isWildcardStatusCode: boolean | undefined' (not optional). This is different from
an optional property 'isWildcardStatusCode?: boolean'.

The IR SDK serializer includes the field in the output even when undefined, which
is the expected behavior for the snapshots. This fixes the TypeScript compilation
errors in CI.

Co-Authored-By: [email protected] <[email protected]>
…comments

The IR SDK generator adds JSDoc comments from the YAML schema docs to the
generated TypeScript types. This commit regenerates the IR SDK to include
the documentation comments for the isWildcardStatusCode field that were
added to the YAML schema in a previous commit.

This fixes the 'run' CI check which verifies that generated code matches
the committed code by running 'git diff --exit-code' after generation.

Co-Authored-By: [email protected] <[email protected]>
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.

2 participants