diff --git a/packages/effect/src/Schema.ts b/packages/effect/src/Schema.ts index 7803c3cd48e..5eecb17fbfb 100644 --- a/packages/effect/src/Schema.ts +++ b/packages/effect/src/Schema.ts @@ -2993,10 +2993,10 @@ export const brand = ( const ast = AST.annotations( self.ast, toASTAnnotations({ - // add a default title annotation containing the brand - title: String(self.ast) + ` & Brand<${util_.formatUnknown(brand)}>`, - ...annotations, - [AST.BrandAnnotationId]: annotation + title: `${String(self.ast)} & Brand<${util_.formatUnknown(brand)}>`, + description: `${String(self.ast)} & Brand<${util_.formatUnknown(brand)}>`, + [AST.BrandAnnotationId]: annotation, + ...annotations }) ) return makeBrandClass(ast) @@ -4258,7 +4258,7 @@ export const lowercased = * @since 3.10.0 */ export class Lowercased extends String$.pipe( - lowercased({ identifier: "Lowercased", title: "Lowercased" }) + lowercased({ identifier: "Lowercased" }) ) {} /** @@ -4289,7 +4289,7 @@ export const capitalized = * @since 3.10.0 */ export class Capitalized extends String$.pipe( - capitalized({ identifier: "Capitalized", title: "Capitalized" }) + capitalized({ identifier: "Capitalized" }) ) {} /** @@ -4320,7 +4320,7 @@ export const uncapitalized = * @since 3.10.0 */ export class Uncapitalized extends String$.pipe( - uncapitalized({ identifier: "Uncapitalized", title: "Uncapitalized" }) + uncapitalized({ identifier: "Uncapitalized" }) ) {} /** @@ -4351,7 +4351,7 @@ export const uppercased = * @since 3.10.0 */ export class Uppercased extends String$.pipe( - uppercased({ identifier: "Uppercased", title: "Uppercased" }) + uppercased({ identifier: "Uppercased" }) ) {} /** @@ -4470,7 +4470,7 @@ export class Uncapitalize extends transform( * @since 3.10.0 */ export class Trimmed extends String$.pipe( - trimmed({ identifier: "Trimmed", title: "Trimmed" }) + trimmed({ identifier: "Trimmed" }) ) {} /** @@ -4490,7 +4490,7 @@ export class Trimmed extends String$.pipe( * @since 3.10.0 */ export class NonEmptyTrimmedString extends Trimmed.pipe( - nonEmptyString({ identifier: "NonEmptyTrimmedString", title: "NonEmptyTrimmedString" }) + nonEmptyString({ identifier: "NonEmptyTrimmedString" }) ) {} /** @@ -4584,7 +4584,7 @@ export const parseJson: { * @since 3.10.0 */ export class NonEmptyString extends String$.pipe( - nonEmptyString({ identifier: "NonEmptyString", title: "NonEmptyString" }) + nonEmptyString({ identifier: "NonEmptyString" }) ) {} /** @@ -4607,7 +4607,6 @@ export class UUID extends String$.pipe( pattern(uuidRegexp, { schemaId: UUIDSchemaId, identifier: "UUID", - title: "UUID", jsonSchema: { format: "uuid", pattern: uuidRegexp.source @@ -4638,7 +4637,6 @@ export class ULID extends String$.pipe( pattern(ulidRegexp, { schemaId: ULIDSchemaId, identifier: "ULID", - title: "ULID", description: "a Universally Unique Lexicographically Sortable Identifier", arbitrary: (): LazyArbitrary => (fc) => fc.ulid() }) @@ -4652,7 +4650,6 @@ export class ULID extends String$.pipe( */ export class URLFromSelf extends instanceOf(URL, { identifier: "URLFromSelf", - title: "URLFromSelf", arbitrary: (): LazyArbitrary => (fc) => fc.webUrl().map((s) => new URL(s)), pretty: () => (url) => url.toString() }) {} @@ -4672,7 +4669,6 @@ class URL$ extends transformOrFail( } ).annotations({ identifier: "URL", - title: "URL", pretty: () => (url) => url.toString() }) {} @@ -4712,7 +4708,7 @@ export const finite = self.pipe( filter(Number.isFinite, { schemaId: FiniteSchemaId, - description: "a finite number", + description: "a finite number (excluding NaN, +Infinity, and -Infinity)", jsonSchema: { "type": "number" }, ...annotations }) @@ -4827,7 +4823,6 @@ export const int = self.pipe( filter((a) => Number.isSafeInteger(a), { schemaId: IntSchemaId, - title: "integer", description: "an integer", jsonSchema: { type: "integer" }, ...annotations @@ -5043,26 +5038,26 @@ export class NumberFromString extends parseNumber(String$.annotations({ * @category number constructors * @since 3.10.0 */ -export class Finite extends Number$.pipe(finite({ identifier: "Finite", title: "Finite" })) {} +export class Finite extends Number$.pipe(finite({ identifier: "Finite" })) {} /** * @category number constructors * @since 3.10.0 */ -export class Int extends Number$.pipe(int({ identifier: "Int", title: "Int" })) {} +export class Int extends Number$.pipe(int({ identifier: "Int" })) {} /** * @category number constructors * @since 3.10.0 */ -export class NonNaN extends Number$.pipe(nonNaN({ identifier: "NonNaN", title: "NonNaN" })) {} +export class NonNaN extends Number$.pipe(nonNaN({ identifier: "NonNaN" })) {} /** * @category number constructors * @since 3.10.0 */ export class Positive extends Number$.pipe( - positive({ identifier: "Positive", title: "Positive" }) + positive({ identifier: "Positive" }) ) {} /** @@ -5070,7 +5065,7 @@ export class Positive extends Number$.pipe( * @since 3.10.0 */ export class Negative extends Number$.pipe( - negative({ identifier: "Negative", title: "Negative" }) + negative({ identifier: "Negative" }) ) {} /** @@ -5078,7 +5073,7 @@ export class Negative extends Number$.pipe( * @since 3.10.0 */ export class NonPositive extends Number$.pipe( - nonPositive({ identifier: "NonPositive", title: "NonPositive" }) + nonPositive({ identifier: "NonPositive" }) ) {} /** @@ -5086,7 +5081,7 @@ export class NonPositive extends Number$.pipe( * @since 3.10.0 */ export class NonNegative extends Number$.pipe( - nonNegative({ identifier: "NonNegative", title: "NonNegative" }) + nonNegative({ identifier: "NonNegative" }) ) {} /** @@ -5124,9 +5119,7 @@ export type JsonNumberSchemaId = typeof JsonNumberSchemaId export class JsonNumber extends Number$.pipe( finite({ schemaId: JsonNumberSchemaId, - identifier: "JsonNumber", - title: "JSON-compatible number", - description: "a JSON-compatible number, excluding NaN, +Infinity, and -Infinity" + identifier: "JsonNumber" }) ) {} @@ -5385,7 +5378,7 @@ export { * @since 3.10.0 */ export const PositiveBigIntFromSelf: filter> = BigIntFromSelf.pipe( - positiveBigInt({ identifier: "PositiveBigintFromSelf", title: "PositiveBigintFromSelf" }) + positiveBigInt({ identifier: "PositiveBigintFromSelf" }) ) /** @@ -5393,7 +5386,7 @@ export const PositiveBigIntFromSelf: filter> = BigIntFromSelf.pip * @since 3.10.0 */ export const PositiveBigInt: filter> = BigInt$.pipe( - positiveBigInt({ identifier: "PositiveBigint", title: "PositiveBigint" }) + positiveBigInt({ identifier: "PositiveBigint" }) ) /** @@ -5401,7 +5394,7 @@ export const PositiveBigInt: filter> = BigInt$.pipe( * @since 3.10.0 */ export const NegativeBigIntFromSelf: filter> = BigIntFromSelf.pipe( - negativeBigInt({ identifier: "NegativeBigintFromSelf", title: "NegativeBigintFromSelf" }) + negativeBigInt({ identifier: "NegativeBigintFromSelf" }) ) /** @@ -5409,7 +5402,7 @@ export const NegativeBigIntFromSelf: filter> = BigIntFromSelf.pip * @since 3.10.0 */ export const NegativeBigInt: filter> = BigInt$.pipe( - negativeBigInt({ identifier: "NegativeBigint", title: "NegativeBigint" }) + negativeBigInt({ identifier: "NegativeBigint" }) ) /** @@ -5417,7 +5410,7 @@ export const NegativeBigInt: filter> = BigInt$.pipe( * @since 3.10.0 */ export const NonPositiveBigIntFromSelf: filter> = BigIntFromSelf.pipe( - nonPositiveBigInt({ identifier: "NonPositiveBigintFromSelf", title: "NonPositiveBigintFromSelf" }) + nonPositiveBigInt({ identifier: "NonPositiveBigintFromSelf" }) ) /** @@ -5425,7 +5418,7 @@ export const NonPositiveBigIntFromSelf: filter> = BigIntFromSelf. * @since 3.10.0 */ export const NonPositiveBigInt: filter> = BigInt$.pipe( - nonPositiveBigInt({ identifier: "NonPositiveBigint", title: "NonPositiveBigint" }) + nonPositiveBigInt({ identifier: "NonPositiveBigint" }) ) /** @@ -5433,7 +5426,7 @@ export const NonPositiveBigInt: filter> = BigInt$.pipe( * @since 3.10.0 */ export const NonNegativeBigIntFromSelf: filter> = BigIntFromSelf.pipe( - nonNegativeBigInt({ identifier: "NonNegativeBigintFromSelf", title: "NonNegativeBigintFromSelf" }) + nonNegativeBigInt({ identifier: "NonNegativeBigintFromSelf" }) ) /** @@ -5441,7 +5434,7 @@ export const NonNegativeBigIntFromSelf: filter> = BigIntFromSelf. * @since 3.10.0 */ export const NonNegativeBigInt: filter> = BigInt$.pipe( - nonNegativeBigInt({ identifier: "NonNegativeBigint", title: "NonNegativeBigint" }) + nonNegativeBigInt({ identifier: "NonNegativeBigint" }) ) /** @@ -5799,13 +5792,21 @@ export const Uint8ArrayFromSelf: Schema = declare( } ) +/** + * @category Uint8 constructors + * @since 3.11.9 + */ +const Uint8FromSelf = Number$.pipe( + between(0, 255, { + identifier: "Uint8FromSelf", + description: "a 8-bit unsigned integer" + }) +) + const Uint8Array$: Schema> = transform( - Array$(Number$.pipe( - between(0, 255, { - title: "8-bit unsigned integer", - description: "a 8-bit unsigned integer" - }) - )).annotations({ description: "an array of 8-bit unsigned integers that will be parsed into a Uint8Array" }), + Array$(Uint8FromSelf).annotations({ + description: "an array of 8-bit unsigned integers that will be parsed into a Uint8Array" + }), Uint8ArrayFromSelf, { strict: true, decode: (numbers) => Uint8Array.from(numbers), encode: (uint8Array) => Array.from(uint8Array) } ).annotations({ identifier: "Uint8Array" }) @@ -7524,10 +7525,7 @@ export const positiveBigDecimal = ( * @since 3.10.0 */ export const PositiveBigDecimalFromSelf: filter> = BigDecimalFromSelf.pipe( - positiveBigDecimal({ - identifier: "PositiveBigDecimalFromSelf", - title: "PositiveBigDecimalFromSelf" - }) + positiveBigDecimal({ identifier: "PositiveBigDecimalFromSelf" }) ) /** @@ -7559,10 +7557,7 @@ export const nonNegativeBigDecimal = ( * @since 3.10.0 */ export const NonNegativeBigDecimalFromSelf: filter> = BigDecimalFromSelf.pipe( - nonNegativeBigDecimal({ - identifier: "NonNegativeBigDecimalFromSelf", - title: "NonNegativeBigDecimalFromSelf" - }) + nonNegativeBigDecimal({ identifier: "NonNegativeBigDecimalFromSelf" }) ) /** @@ -7594,10 +7589,7 @@ export const negativeBigDecimal = ( * @since 3.10.0 */ export const NegativeBigDecimalFromSelf: filter> = BigDecimalFromSelf.pipe( - negativeBigDecimal({ - identifier: "NegativeBigDecimalFromSelf", - title: "NegativeBigDecimalFromSelf" - }) + negativeBigDecimal({ identifier: "NegativeBigDecimalFromSelf" }) ) /** @@ -7629,10 +7621,7 @@ export const nonPositiveBigDecimal = ( * @since 3.10.0 */ export const NonPositiveBigDecimalFromSelf: filter> = BigDecimalFromSelf.pipe( - nonPositiveBigDecimal({ - identifier: "NonPositiveBigDecimalFromSelf", - title: "NonPositiveBigDecimalFromSelf" - }) + nonPositiveBigDecimal({ identifier: "NonPositiveBigDecimalFromSelf" }) ) /** @@ -8558,14 +8547,8 @@ const FiberIdNoneEncoded = Struct({ const FiberIdRuntimeEncoded = Struct({ _tag: Literal("Runtime"), - id: Int.annotations({ - title: "id", - description: "id" - }), - startTimeMillis: Int.annotations({ - title: "startTimeMillis", - description: "startTimeMillis" - }) + id: Int, + startTimeMillis: Int }).annotations({ identifier: "FiberIdRuntimeEncoded" }) const FiberIdCompositeEncoded = Struct({ diff --git a/packages/effect/test/Schema/JSONSchema.test.ts b/packages/effect/test/Schema/JSONSchema.test.ts index c4cd1cec36c..7cc5eabd5bf 100644 --- a/packages/effect/test/Schema/JSONSchema.test.ts +++ b/packages/effect/test/Schema/JSONSchema.test.ts @@ -444,7 +444,6 @@ describe("makeWithOptions", () => { }, { "Int": { "description": "an integer", - "title": "Int", "type": "integer" } }) @@ -850,8 +849,7 @@ details: Cannot encode Symbol(effect/Schema/test/a) key to JSON Schema` "$defs": { "JsonNumber": { "type": "number", - "description": "a JSON-compatible number, excluding NaN, +Infinity, and -Infinity", - "title": "JSON-compatible number" + "description": "a finite number (excluding NaN, +Infinity, and -Infinity)" } }, "$ref": "#/$defs/JsonNumber" @@ -1145,7 +1143,6 @@ details: Cannot encode Symbol(effect/Schema/test/a) key to JSON Schema` it("int", () => { expectJSONSchemaAnnotations(JsonNumber.pipe(Schema.int()), { "type": "integer", - "title": "integer", "description": "an integer" }) }) @@ -1157,7 +1154,6 @@ details: Cannot encode Symbol(effect/Schema/test/a) key to JSON Schema` "Trimmed": { "description": "a string with no leading or trailing whitespace", "pattern": "^\\S[\\s\\S]*\\S$|^\\S$|^$", - "title": "Trimmed", "type": "string" } }, @@ -1172,7 +1168,6 @@ details: Cannot encode Symbol(effect/Schema/test/a) key to JSON Schema` "Lowercased": { "description": "a lowercase string", "pattern": "^[^A-Z]*$", - "title": "Lowercased", "type": "string" } }, @@ -1187,7 +1182,6 @@ details: Cannot encode Symbol(effect/Schema/test/a) key to JSON Schema` "Uppercased": { "description": "an uppercase string", "pattern": "^[^a-z]*$", - "title": "Uppercased", "type": "string" } }, @@ -1202,7 +1196,6 @@ details: Cannot encode Symbol(effect/Schema/test/a) key to JSON Schema` "Capitalized": { "description": "a capitalized string", "pattern": "^[^a-z]?.*$", - "title": "Capitalized", "type": "string" } }, @@ -1217,7 +1210,6 @@ details: Cannot encode Symbol(effect/Schema/test/a) key to JSON Schema` "Uncapitalized": { "description": "a uncapitalized string", "pattern": "^[^A-Z]?.*$", - "title": "Uncapitalized", "type": "string" } }, @@ -2359,7 +2351,6 @@ details: Cannot encode Symbol(effect/Schema/test/a) key to JSON Schema` "NonEmptyString": { "type": "string", "description": "a non empty string", - "title": "NonEmptyString", "minLength": 1 } }, @@ -2545,7 +2536,6 @@ details: Cannot encode Symbol(effect/Schema/test/a) key to JSON Schema` "NonEmptyString": { "type": "string", "description": "a non empty string", - "title": "NonEmptyString", "minLength": 1 } }, @@ -2576,7 +2566,6 @@ details: Cannot encode Symbol(effect/Schema/test/a) key to JSON Schema` "NonEmptyString": { "type": "string", "description": "a non empty string", - "title": "NonEmptyString", "minLength": 1 }, "aa6f48cd-03e4-470a-beb7-5f7cc532c676": { @@ -2609,7 +2598,6 @@ details: Cannot encode Symbol(effect/Schema/test/a) key to JSON Schema` "NonEmptyString": { "type": "string", "description": "a non empty string", - "title": "NonEmptyString", "minLength": 1 } }, @@ -2642,7 +2630,6 @@ details: Cannot encode Symbol(effect/Schema/test/a) key to JSON Schema` "NonEmptyString": { "type": "string", "description": "a non empty string", - "title": "NonEmptyString", "minLength": 1 }, "d5ff7bc8-1bd5-42a7-8186-e29fd4c217ea": { @@ -2998,7 +2985,6 @@ details: Cannot encode Symbol(effect/Schema/test/a) key to JSON Schema` "NonEmptyString": { "type": "string", "description": "a non empty string", - "title": "NonEmptyString", "minLength": 1 } }, @@ -3585,7 +3571,6 @@ details: Cannot encode Symbol(effect/Schema/test/a) key to JSON Schema` "UUID": { "description": "a Universally Unique Identifier", "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$", - "title": "UUID", "type": "string", "format": "uuid" } @@ -3634,7 +3619,6 @@ details: Cannot encode Symbol(effect/Schema/test/a) key to JSON Schema` "$defs": { "Int": { "description": "an integer", - "title": "Int", "type": "custom" } }, @@ -4059,7 +4043,6 @@ details: Cannot encode Symbol(effect/Schema/test/a) key to JSON Schema` "Trimmed": { "description": "a string with no leading or trailing whitespace", "pattern": "^\\S[\\s\\S]*\\S$|^\\S$|^$", - "title": "Trimmed", "type": "string" } }, @@ -4242,9 +4225,8 @@ details: Cannot encode Symbol(effect/Schema/test/a) key to JSON Schema` expectJSONSchemaProperty(Schema.encodedBoundSchema(schema), { "$defs": { "JsonNumber": { - "description": "a JSON-compatible number, excluding NaN, +Infinity, and -Infinity", - "title": "JSON-compatible number", - "type": "number" + "type": "number", + "description": "a finite number (excluding NaN, +Infinity, and -Infinity)" }, "c0c853a6-9029-49d9-9a63-08aa542ec7da": { "anyOf": [ diff --git a/packages/effect/test/Schema/Schema/Class/Class.test.ts b/packages/effect/test/Schema/Schema/Class/Class.test.ts index 73d7a798693..b37e8b57761 100644 --- a/packages/effect/test/Schema/Schema/Class/Class.test.ts +++ b/packages/effect/test/Schema/Schema/Class/Class.test.ts @@ -564,7 +564,6 @@ details: Duplicate key "a"`) "NonEmptyString": { "description": "a non empty string", "minLength": 1, - "title": "NonEmptyString", "type": "string" }, "TypeID": { @@ -591,7 +590,6 @@ details: Duplicate key "a"`) "NonEmptyString": { "description": "a non empty string", "minLength": 1, - "title": "NonEmptyString", "type": "string" }, "TransformationID": { diff --git a/packages/effect/test/Schema/Schema/Class/extend.test.ts b/packages/effect/test/Schema/Schema/Class/extend.test.ts index 61361e2ea06..53a950b679b 100644 --- a/packages/effect/test/Schema/Schema/Class/extend.test.ts +++ b/packages/effect/test/Schema/Schema/Class/extend.test.ts @@ -267,7 +267,6 @@ describe("extend", () => { "NonEmptyString": { "description": "a non empty string", "minLength": 1, - "title": "NonEmptyString", "type": "string" }, "TypeID": { @@ -295,7 +294,6 @@ describe("extend", () => { "NonEmptyString": { "description": "a non empty string", "minLength": 1, - "title": "NonEmptyString", "type": "string" }, "TransformationID": { diff --git a/packages/effect/test/Schema/Schema/Uint8Array/Uint8Array.test.ts b/packages/effect/test/Schema/Schema/Uint8Array/Uint8Array.test.ts index da162d0d77c..3c48e45d55c 100644 --- a/packages/effect/test/Schema/Schema/Uint8Array/Uint8Array.test.ts +++ b/packages/effect/test/Schema/Schema/Uint8Array/Uint8Array.test.ts @@ -22,9 +22,9 @@ describe("Uint8Array > Uint8Array", () => { └─ Encoded side transformation failure └─ an array of 8-bit unsigned integers that will be parsed into a Uint8Array └─ [0] - └─ 8-bit unsigned integer + └─ Uint8FromSelf └─ Predicate refinement failure - └─ Expected 8-bit unsigned integer, actual 12354` + └─ Expected Uint8FromSelf, actual 12354` ) }) diff --git a/packages/effect/test/Schema/Schema/brand.test.ts b/packages/effect/test/Schema/Schema/brand.test.ts index 541fabeee81..8ea11fed93a 100644 --- a/packages/effect/test/Schema/Schema/brand.test.ts +++ b/packages/effect/test/Schema/Schema/brand.test.ts @@ -63,7 +63,7 @@ describe("brand", () => { expect(schema.ast.annotations).toEqual({ [AST.SchemaIdAnnotationId]: S.IntSchemaId, [AST.BrandAnnotationId]: ["A"], - [AST.TitleAnnotationId]: `integer & Brand<"A">`, + [AST.TitleAnnotationId]: `an integer & Brand<"A">`, [AST.DescriptionAnnotationId]: "an A brand", [AST.JSONSchemaAnnotationId]: { type: "integer" } }) @@ -81,7 +81,7 @@ describe("brand", () => { expect(schema.ast.annotations).toEqual({ [AST.SchemaIdAnnotationId]: S.IntSchemaId, [AST.BrandAnnotationId]: ["A", "B"], - [AST.TitleAnnotationId]: `integer & Brand<"A"> & Brand<"B">`, + [AST.TitleAnnotationId]: `an integer & Brand<"A"> & Brand<"B">`, [AST.DescriptionAnnotationId]: "a B brand", [AST.JSONSchemaAnnotationId]: { type: "integer" } }) @@ -100,7 +100,7 @@ describe("brand", () => { expect(schema.ast.annotations).toEqual({ [AST.SchemaIdAnnotationId]: S.IntSchemaId, [AST.BrandAnnotationId]: [A, B], - [AST.TitleAnnotationId]: "integer & Brand & Brand", + [AST.TitleAnnotationId]: "an integer & Brand & Brand", [AST.DescriptionAnnotationId]: "a B brand", [AST.JSONSchemaAnnotationId]: { type: "integer" } }) diff --git a/packages/platform-node/test/fixtures/openapi.json b/packages/platform-node/test/fixtures/openapi.json index bb8212cfe7a..f36562bb89c 100644 --- a/packages/platform-node/test/fixtures/openapi.json +++ b/packages/platform-node/test/fixtures/openapi.json @@ -516,12 +516,10 @@ "description": "a Universally Unique Identifier", "format": "uuid", "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$", - "title": "UUID", "type": "string" }, "Int": { "description": "an integer", - "title": "Int", "type": "integer" }, "HttpApiDecodeError": { diff --git a/packages/platform/test/OpenApiJsonSchema.test.ts b/packages/platform/test/OpenApiJsonSchema.test.ts index 032d87e3cf0..ddb8ae9baec 100644 --- a/packages/platform/test/OpenApiJsonSchema.test.ts +++ b/packages/platform/test/OpenApiJsonSchema.test.ts @@ -43,7 +43,6 @@ describe("OpenApiJsonSchema", () => { expect(defs).toStrictEqual({ "Int": { "description": "an integer", - "title": "Int", "type": "integer" }, "NumberFromString": {