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

Allow for Schema instance as schema option #344

Merged
merged 3 commits into from
Dec 31, 2021
Merged

Allow for Schema instance as schema option #344

merged 3 commits into from
Dec 31, 2021

Conversation

eemeli
Copy link
Owner

@eemeli eemeli commented Dec 27, 2021

Previously, doc.setSchema always created a new Schema instance based on the given schema identifier. This change allows for an externally defined schema to be used instead, which makes using a different predefined set of default option values easier.

@eemeli
Copy link
Owner Author

eemeli commented Dec 29, 2021

Modified the PR a bit, such that the API now becomes:

type SchemaOptions = { ...
  /** The base schema to use. */
  schema?: string | Schema
}

class Document { ...
  directives?: Directives // previously required

  /**
   * Change the YAML version and schema used by the document.
   * A `null` version disables support for directives, explicit tags, anchors, and aliases.
   * It also requires the `schema` option to be given as a `Schema` instance value.
   *
   * Overrides all previously set schema options.
   */
  setSchema(version: '1.1' | '1.2' | null, options: SchemaOptions = {}): void
}

@eemeli eemeli merged commit 6943654 into master Dec 31, 2021
@eemeli eemeli deleted the custom-scheming branch December 31, 2021 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant