Effect CommunityEC
Effect Community8mo ago
2 replies
colorless

Swagger not showing all URL params with Schema.extend + discriminated union

Hi! I'm having an issue where my Swagger documentation isn't displaying all the URL parameters I've defined.
My endpoint uses Schema.extend to combine common parameters with a discriminated union, but the generated Swagger docs seem to be missing some of the parameters.
Setup:

URL params schema: Schema.extend(CommonParams, DiscriminatedParams) where DiscriminatedParams is a union of two different structs

const CommonParams = Schema.Struct({
  bob: Schema.optional(Schema.NumberFromString),
  alice: Schema.optional(Schema.NumberFromString),
});

const DiscriminatedParams = Schema.Union(
  Schema.Struct({
    foo: Schema.String,
    bar: Schema.NumberFromString,
  }),
  Schema.Struct({
    baz: Schema.Literal("hello", "world"),
  }),
);

const ExtendedParams = Schema.extend(
  CommonParams,
  DiscriminatedParams,
);

/**
 * type ExtendedParams = {
 *     readonly bob?: number | undefined;
 *     readonly alice?: number | undefined;
 * } & ({
 *     readonly foo: string;
 *     readonly bar: number;
 * } | {
 *     readonly baz: "hello" | "world";
 * })
 */
type ExtendedParams = typeof ExtendedParams.Type;


Question:
Is this a known limitation of the Swagger integration with complex schema types like extended discriminated unions? Or am I missing something in how I should structure the schema for proper Swagger documentation generation?
Any guidance on best practices for documenting complex URL parameter schemas would be appreciated!

Screenshot attached
Link to Effect playground: https://effect.website/play/#f43478993992
get_attachment_url.png
Effect Documentation
Was this page helpful?