Skip to content

Set $id after clone #193

@Eomm

Description

@Eomm

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the issue has not already been raised

Issue

Given an origin flunet-json-schema object filtered with only/without it is not possible to set the BaseSchema's $id:

const WhizBang = fluent
  .object()
  .additionalProperties(false)
  .id('whizbang')
  .title('WhizBang')
  .prop(
    'whiz'
  , fluent.string().required().minLength(1)
  )
  .prop(
    'bang'
  , fluent.string().required().minLength(1)
  )

const part = WhizBang.only(['whiz'])
console.log(JSON.stringify(part.id('asd').valueOf(), null, 2))

Shows:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "additionalProperties": false,
  "$id": "whizbang",
  "title": "WhizBang",
  "properties": {
    "whiz": {
+      "$id": "asd",
      "type": "string",
      "minLength": 1
    }
  },
  "required": [
    "whiz"
  ]
}

I can't find a way to set the "$id": "whizbang" field.

Ref fastify/fastify#4276

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions