Skip to content
New issue

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

Generate JSON Schemas correctly for a schema created by extending two… #3101

Merged
merged 1 commit into from
Jun 27, 2024

Conversation

gcanti
Copy link
Contributor

@gcanti gcanti commented Jun 27, 2024

… refinements using the extend API, ensuring their JSON Schema annotations are preserved.

… refinements using the `extend` API, ensuring their JSON Schema annotations are preserved.
Copy link

changeset-bot bot commented Jun 27, 2024

🦋 Changeset detected

Latest commit: 8bd06e5

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

This PR includes changesets to release 23 packages
Name Type
@effect/schema Patch
@effect/cli Patch
@effect/cluster-browser Patch
@effect/cluster-node Patch
@effect/cluster-workflow Patch
@effect/cluster Patch
@effect/experimental Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/platform Patch
@effect/rpc-http Patch
@effect/rpc Patch
@effect/sql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-node Patch
@effect/sql-drizzle 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

@gcanti gcanti merged commit d990544 into main Jun 27, 2024
12 checks passed
@gcanti gcanti deleted the schema-preserve-filter-json-annotations branch June 27, 2024 06:50
@github-actions github-actions bot mentioned this pull request Jun 27, 2024
suddenlyGiovanni added a commit to suddenlyGiovanni/resume that referenced this pull request Sep 3, 2024
- [#3101](Effect-TS/effect#3101) [`d990544`](Effect-TS/effect@d990544) Thanks @gcanti! - Generate JSON Schemas correctly for a schema created by extending two refinements using the `extend` API, ensuring their JSON Schema annotations are preserved.

  Example

  ```ts
  import { JSONSchema, Schema } from "@effect/schema"

  const schema = Schema.Struct({
    a: Schema.String
  })
    .pipe(Schema.filter(() => true, { jsonSchema: { a: 1 } }))
    .pipe(
      Schema.extend(
        Schema.Struct({
          b: Schema.Number
        }).pipe(Schema.filter(() => true, { jsonSchema: { b: 2 } }))
      )
    )

  console.log(JSONSchema.make(schema))
  /*
  {
    '$schema': 'http://json-schema.org/draft-07/schema#',
    type: 'object',
    required: [ 'a', 'b' ],
    properties: {
      a: { type: 'string', description: 'a string', title: 'string' },
      b: { type: 'number', description: 'a number', title: 'number' }
    },
    additionalProperties: false,
    b: 2,
    a: 1
  }
  */
  ```

- Updated dependencies [[`a047af9`](Effect-TS/effect@a047af9)]:
  - [email protected]

Signed-off-by: Giovanni Ravalico <[email protected]>
suddenlyGiovanni added a commit to suddenlyGiovanni/resume that referenced this pull request Sep 3, 2024
- [#3101](Effect-TS/effect#3101) [`d990544`](Effect-TS/effect@d990544) Thanks @gcanti! - Generate JSON Schemas correctly for a schema created by extending two refinements using the `extend` API, ensuring their JSON Schema annotations are preserved.

  Example

  ```ts
  import { JSONSchema, Schema } from "@effect/schema"

  const schema = Schema.Struct({
    a: Schema.String
  })
    .pipe(Schema.filter(() => true, { jsonSchema: { a: 1 } }))
    .pipe(
      Schema.extend(
        Schema.Struct({
          b: Schema.Number
        }).pipe(Schema.filter(() => true, { jsonSchema: { b: 2 } }))
      )
    )

  console.log(JSONSchema.make(schema))
  /*
  {
    '$schema': 'http://json-schema.org/draft-07/schema#',
    type: 'object',
    required: [ 'a', 'b' ],
    properties: {
      a: { type: 'string', description: 'a string', title: 'string' },
      b: { type: 'number', description: 'a number', title: 'number' }
    },
    additionalProperties: false,
    b: 2,
    a: 1
  }
  */
  ```

- Updated dependencies [[`a047af9`](Effect-TS/effect@a047af9)]:
  - [email protected]

Signed-off-by: Giovanni Ravalico <[email protected]>
suddenlyGiovanni added a commit to suddenlyGiovanni/resume that referenced this pull request Sep 3, 2024
- [#3101](Effect-TS/effect#3101) [`d990544`]
(Effect-TS/effect@d990544) - Generate JSON Schemas correctly for a schema created by extending two refinements using the `extend` API, ensuring their JSON Schema annotations are preserved.

  Example

  ```ts
  import { JSONSchema, Schema } from "@effect/schema"

  const schema = Schema.Struct({
    a: Schema.String
  })
    .pipe(Schema.filter(() => true, { jsonSchema: { a: 1 } }))
    .pipe(
      Schema.extend(
        Schema.Struct({
          b: Schema.Number
        }).pipe(Schema.filter(() => true, { jsonSchema: { b: 2 } }))
      )
    )

  console.log(JSONSchema.make(schema))
  /*
  {
    '$schema': 'http://json-schema.org/draft-07/schema#',
    type: 'object',
    required: [ 'a', 'b' ],
    properties: {
      a: { type: 'string', description: 'a string', title: 'string' },
      b: { type: 'number', description: 'a number', title: 'number' }
    },
    additionalProperties: false,
    b: 2,
    a: 1
  }
  */
  ```

- Updated dependencies [[`a047af9`](Effect-TS/effect@a047af9)]:
  - [email protected]

Signed-off-by: Giovanni Ravalico <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

1 participant