Skip to content

Fix incompatible OpenAPI schema examples#6427

Draft
coyaSONG wants to merge 1 commit into
Effect-TS:mainfrom
coyaSONG:agent/fix-openapi-invalid-examples
Draft

Fix incompatible OpenAPI schema examples#6427
coyaSONG wants to merge 1 commit into
Effect-TS:mainfrom
coyaSONG:agent/fix-openapi-invalid-examples

Conversation

@coyaSONG

Copy link
Copy Markdown
Contributor

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

OpenAPI 3.0 singular example values are normalized to Effect Schema examples annotations, but the generator previously copied them without checking their JSON type. Invalid real-world specifications could therefore generate annotations that fail TypeScript compilation.

This change filters schema examples against an explicitly declared JSON Schema type, including type arrays. It preserves compatible examples, leaves schemas without an explicit type unchanged, and emits an invalid-schema-example-dropped warning for each incompatible value. When every example is incompatible, the annotation is omitted.

Validation:

  • pnpm lint-fix
  • pnpm --filter @effect/openapi-generator test --run (70 tests)
  • pnpm check
  • end-to-end openapigen reproduction followed by strict tsc --noEmit

This contribution was implemented and validated with OpenAI Codex assistance.

Related

@github-project-automation github-project-automation Bot moved this to Discussion Ongoing in PR Backlog Jul 16, 2026
@changeset-bot

changeset-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7d5102a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 27 packages
Name Type
@effect/openapi-generator Patch
effect Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/vitest Patch
@effect/ai-anthropic Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@IMax153 IMax153 added the 4.0 label Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Discussion Ongoing

Development

Successfully merging this pull request may close these issues.

@effect/openapi-generator can emit type-invalid annotations for invalid schema examples

2 participants