Skip to content

feat(reference): support per-parser options in all parser plugins #232

Description

@char0n

Summary

The overlay parser plugins (overlay-json-1, overlay-yaml-1) now support per-parser options via parserOpts[parserName] — allowing different sourceMap, style, strict values per parser plugin while sharing global defaults.

This pattern should be extended to all other parser plugins in apidom-reference for consistency.

Current pattern (overlay parsers)

const parserOptsNames = ['sourceMap', 'style', 'strict', 'refractorOpts'] as const;
const parserOptsGlobal = pick(parserOptsNames, this);
const parserOptsLocal = pick([...parserOptsNames, 'extends'], (this as any)[this.name] ?? {});
const parserOpts = { ...parserOptsGlobal, ...parserOptsLocal };

Usage:

parse(uri, {
  parse: {
    parserOpts: {
      strict: false,          // global default
      style: true,            // global default
      'overlay-json-1': {     // per-parser override
        sourceMap: true,
        style: false,
        extends: true,
      },
    },
  },
});

Parsers to update

  • arazzo-json-1
  • arazzo-yaml-1
  • asyncapi-json-2
  • asyncapi-yaml-2
  • openapi-json-2
  • openapi-json-3-0
  • openapi-json-3-1
  • openapi-yaml-2
  • openapi-yaml-3-0
  • openapi-yaml-3-1
  • json
  • yaml-1-2
  • apidom-json

Context

Implemented for overlay parsers in PR #231 to support different style/sourceMap settings for the overlay document vs its extends target.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions