Skip to content

Add a dedicated MediaType module - #7539

Draft
fubhy wants to merge 15 commits into
mainfrom
media-type
Draft

Add a dedicated MediaType module#7539
fubhy wants to merge 15 commits into
mainfrom
media-type

Conversation

@fubhy

@fubhy fubhy commented Aug 31, 2026

Copy link
Copy Markdown
Member

Summary

  • add a strict, immutable effect/unstable/http/MediaType value with validated construction, Input conversion, deterministic formatting, structured suffix access, parameter matching, and common predicates
  • add Schema.MediaType, Schema.MediaTypeFromString, canonical JSON and StringTree codecs, declaration revival, and Config.MediaType
  • accept media type values, strings, or structured parts in HttpApiSchema content-type options and normalize them into parsed encoding, stream, and response-alternative metadata
  • use parsed media-type essences for HTTP API dispatch and multipart handling, formatting only at OpenAPI and HTTP wire boundaries
  • distinguish missing response content types from explicitly empty or malformed fields
  • update the OpenAPI generator to pass custom content-type strings through normalized HttpApiSchema input boundaries
  • use the current string-key convention for MediaType.TypeId
  • reject invalid escaped DEL quoted pairs and keep structured parse diagnostics
  • keep MediaType parser coverage focused on distinct syntax, normalization, and failure behavior

Testing

  • pnpm lint-fix
  • pnpm test --run packages/effect/test/schema/Schema.test.ts packages/effect/test/schema/representation/builtInRevivers.test.ts packages/effect/test/Config.test.ts packages/effect/test/unstable/http/MediaType.test.ts packages/effect/test/unstable/http/Multipart.test.ts
  • pnpm test --run packages/effect/test/unstable/httpapi/HttpApiSchema.test.ts packages/effect/test/unstable/httpapi/HttpApiEndpoint.test.ts packages/effect/test/unstable/httpapi/HttpApiClient.test.ts packages/effect/test/unstable/httpapi/HttpApiBuilder.test.ts packages/effect/test/unstable/httpapi/OpenApi.test.ts
  • pnpm test --run packages/tools/openapi-generator/test/OpenApiGenerator.test.ts packages/platform/node/test/OpenApi.test.ts packages/platform/node/test/HttpApi.test.ts
  • pnpm test-types Config.tst.ts SchemaBuiltInAtomicDeclarationRevivers.tst.ts MediaType.tst.ts HttpApiSchema.tst.ts HttpApiEndpoint.tst.ts HttpApiClient.tst.ts
  • pnpm check
  • git diff --check

pnpm jsdocs --check continues to report the existing repository-wide baseline diagnostics; the newly added APIs are indexed without new diagnostics.

@changeset-bot

changeset-bot Bot commented Aug 31, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1b25b4c

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

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

@effect-slopcop effect-slopcop Bot added enhancement New feature or request 4.0 labels Aug 31, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
arbitrary-combinators.ts 33.76 KB 33.76 KB 0.00 KB (0.00%)
basic.ts 7.00 KB 7.00 KB 0.00 KB (0.00%)
batching.ts 9.87 KB 9.87 KB 0.00 KB (0.00%)
brand.ts 6.56 KB 6.56 KB 0.00 KB (0.00%)
cache.ts 10.74 KB 10.74 KB 0.00 KB (0.00%)
config.ts 21.45 KB 21.45 KB 0.00 KB (0.00%)
differ.ts 20.32 KB 20.32 KB 0.00 KB (0.00%)
http-client.ts 21.77 KB 21.77 KB 0.00 KB (0.00%)
logger.ts 10.94 KB 10.94 KB 0.00 KB (0.00%)
metric.ts 8.98 KB 8.98 KB 0.00 KB (0.00%)
optic.ts 6.73 KB 6.73 KB 0.00 KB (0.00%)
pubsub.ts 15.12 KB 15.12 KB 0.00 KB (0.00%)
queue.ts 11.84 KB 11.84 KB 0.00 KB (0.00%)
schedule.ts 10.86 KB 10.86 KB 0.00 KB (0.00%)
schema-binary.ts 39.42 KB 39.42 KB 0.00 KB (0.00%)
schema-class.ts 20.07 KB 20.07 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 31.02 KB 31.02 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 26.21 KB 26.21 KB 0.00 KB (0.00%)
schema-string-transformation.ts 13.66 KB 13.66 KB 0.00 KB (0.00%)
schema-string.ts 11.18 KB 11.18 KB 0.00 KB (0.00%)
schema-template-literal.ts 15.47 KB 15.47 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 33.31 KB 33.31 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 24.51 KB 24.51 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 19.29 KB 19.29 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 19.42 KB 19.42 KB 0.00 KB (0.00%)
schema-toFormatter.ts 19.51 KB 19.51 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 23.45 KB 23.45 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 19.56 KB 19.56 KB 0.00 KB (0.00%)
schema.ts 19.28 KB 19.28 KB 0.00 KB (0.00%)
stm.ts 12.74 KB 12.74 KB 0.00 KB (0.00%)
stream.ts 9.83 KB 9.83 KB 0.00 KB (0.00%)

@fubhy
fubhy requested a review from tim-smart August 31, 2026 18:40
@fubhy
fubhy force-pushed the media-type branch 2 times, most recently from e6ead06 to e43debc Compare September 1, 2026 06:50
Comment thread packages/effect/test/Config.test.ts Outdated
Comment thread packages/effect/src/unstable/http/MediaType.ts
Comment thread packages/effect/src/unstable/httpapi/HttpApiClient.ts Outdated
Comment thread packages/effect/src/unstable/httpapi/HttpApiBuilder.ts Outdated
Comment thread packages/tools/openapi-generator/src/HttpApiTransformer.ts Outdated
Comment thread packages/effect/src/unstable/http/MediaType.ts Outdated
Comment thread packages/effect/src/unstable/http/MediaType.ts Outdated
Comment thread packages/effect/src/unstable/httpapi/OpenApi.ts Outdated
Comment thread .changeset/parsed-media-types.md Outdated
@fubhy
fubhy marked this pull request as draft September 1, 2026 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.0 enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants