We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"@effect/platform": "^0.69.24"
add a schema to a handler in http platform
const s1 = Schema.Union(Schema.Struct({ _tag: Schema.Literal('s1') }), Schema.Struct({ _tag: Schema.Literal('s2') })); const s1Annotated = s1.annotations({ jsonSchema: { discriminator: { propertyName: '_tag', }, }, });
use in a api:
HttpApiGroup.make('resource') .add( HttpApiEndpoint.put('myResource', '/res') .setPayload(s1Annotated)
generate swagger docs:
const HttpLive = HttpApiBuilder.serve(errorLogger).pipe( Layer.provide(HttpApiSwagger.layer()),
then extract the openapi definition from the generated docs and inspect it
add the discriminator clause to the part describing the data structure like this
anyOf: - $ref: '#/components/schemas/S1' - $ref: '#/components/schemas/S2' discriminator: propertyName: _tag
only the discriminator clause, without the anyOf clause
discriminator: propertyName: _tag
this can actually be fixed by adding noop filter to the data structure and attaching the jsonSchema to it.
return union.pipe(Schema.filter((x) => true)).annotations({ jsonSchema: { discriminator: { propertyName: '_tag', mapping, }, }, });
this is because the jsonSchema annotation is handled differently for the refinements https://github.com/Effect-TS/effect/blame/c8d20b0827a30e95a0fe192113e82b72c8bfb5cd/packages/platform/src/OpenApiJsonSchema.ts#L350
The text was updated successfully, but these errors were encountered:
No branches or pull requests
What version of Effect is running?
"@effect/platform": "^0.69.24"
What steps can reproduce the bug?
add a schema to a handler in http platform
use in a api:
generate swagger docs:
then extract the openapi definition from the generated docs and inspect it
What is the expected behavior?
add the discriminator clause to the part describing the data structure like this
What do you see instead?
only the discriminator clause, without the anyOf clause
Additional information
this can actually be fixed by adding noop filter to the data structure and attaching the jsonSchema to it.
this is because the jsonSchema annotation is handled differently for the refinements
https://github.com/Effect-TS/effect/blame/c8d20b0827a30e95a0fe192113e82b72c8bfb5cd/packages/platform/src/OpenApiJsonSchema.ts#L350
The text was updated successfully, but these errors were encountered: