@stoplight/yaml-ast-parser

WebJar for @stoplight/yaml-ast-parser

License

License

Apache-2.0
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

stoplight__yaml-ast-parser
Last Version

Last Version

0.0.48
Release Date

Release Date

Type

Type

jar
Description

Description

@stoplight/yaml-ast-parser
WebJar for @stoplight/yaml-ast-parser
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/stoplightio/yaml-ast-parser

Download stoplight__yaml-ast-parser

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/stoplight__yaml-ast-parser/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>stoplight__yaml-ast-parser</artifactId>
    <version>0.0.48</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/stoplight__yaml-ast-parser/
implementation 'org.webjars.npm:stoplight__yaml-ast-parser:0.0.48'
// https://jarcasting.com/artifacts/org.webjars.npm/stoplight__yaml-ast-parser/
implementation ("org.webjars.npm:stoplight__yaml-ast-parser:0.0.48")
'org.webjars.npm:stoplight__yaml-ast-parser:jar:0.0.48'
<dependency org="org.webjars.npm" name="stoplight__yaml-ast-parser" rev="0.0.48">
  <artifact name="stoplight__yaml-ast-parser" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='stoplight__yaml-ast-parser', version='0.0.48')
)
libraryDependencies += "org.webjars.npm" % "stoplight__yaml-ast-parser" % "0.0.48"
[org.webjars.npm/stoplight__yaml-ast-parser "0.0.48"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

yaml-ast-parser

Build Status

This is a fork of JS-YAML which supports parsing of YAML into AST.

In additional to parsing YAML to AST, it has following features:

  • restoration after the errors and reporting errors as a part of AST nodes.
  • built-in support for !include tag used in RAML

Usage

The type information below is relevant when using TypeScript, if using from JavaScript only the field/method information is relevant.

load method can be used to load the tree and returns a YAMLNode.

YAMLNode

YAMLNode class is an ancestor for all node kinds. It's kind field determine node kind, one of Kind enum:

  • SCALAR, MAPPING, MAP, SEQ, ANCHOR_REF or INCLUDE_REF.

After node kind is determined, it can be cast to one of the YAMLNode descendants types:

  • YAMLScalar, YAMLMapping, YamlMap, YAMLSequence or YAMLAnchorReference.
class important members
YAMLNode startPosition and endPosition provide node range.
YAMLScalar string value field
YAMLMapping YAMLScalar key and YAMLNode value fields
YAMLSequence YAMLNode[] items field
YamlMap YAMLMapping[] mappings field
YAMLAnchorReference string referencesAnchor and YAMLNode value

YAMLScalar

Scalars are one of the three main node types defined by YAML and are effectively leaf nodes.

There are many factors that can influence the type of datum represent in scalar node (context, schema, tag, etc.).

To help inspection of a YAMLScalar to determine its datatype when a document uses the Core Schema, you can pass the YAMLScalar to the determineScalarType function. It will return an enum value indicating null, bool, int, float, or string.

Once you know the type, there are also some helper functions to help read the value by passing them the string, value: parseYamlBoolean, parseYamlFloat, and parseYamlInteger.

org.webjars.npm

Stoplight

Stoplight leverages your OpenAPI documents to drive the entire API development process

Versions

Version
0.0.48