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

YAML alias syntactic analysis #3703

Closed
char0n opened this issue Jan 19, 2024 · 2 comments
Closed

YAML alias syntactic analysis #3703

char0n opened this issue Jan 19, 2024 · 2 comments
Assignees
Labels
ApiDOM bug Something isn't working YAML

Comments

@char0n
Copy link
Member

char0n commented Jan 19, 2024

It seems that YamlAlias AST Node it not properly translated to ApiDOM. After the syntactic analysis the YamlAlias AST Node seems to be part of ApiDOM which is wrongs, as the ApiDOM shouldn't be aware of AST layer at all. This can cause various side effects in any higher level algorithms like serialization or transformation...

The goal of this issue is fix the bug and verify with simple unit test.

Refs #131

@char0n char0n added bug Something isn't working ApiDOM YAML labels Jan 19, 2024
@char0n
Copy link
Member Author

char0n commented Feb 2, 2024

Architectural design

We will create a new module in https://github.com/swagger-api/apidom/tree/main/packages/apidom-ast/src/yaml called anchors-aliases. This module will have a single class ReferenceManager.

yaml
  anchors-aliases/
    ReferenceManager.ts
  errrors/
  nodes/
  schemas/

ReferenceManage will look like this to abide to YAML 1.2 nomenclature:

class ReferenceManager { 
  void addAnchor(String anchor);
  Object resolveAlias(String alias);
}

The ReferenceManager needs to be exposed from apidom-ast package and will be used in apidom-parser-adapter-yaml-1-2.

Now it's important to understand that we don't want to support anchors and aliases fully - that is part of #131. What we need now is a basic framework of anchor and alias processing, with dummy implementation.

Now what does the dummy implementation mean? Inside the apidom-parser-adapter-yaml-1-2 package when YamlAnchor node is intercepted, we'll store it by using ReferenceManager.prototype.addAnchor. Then when YamlAlias node is intercepted, we'll run it through the ReferenceManager.prototype.resolveAlias. Now the resolveAlias will have very simple implementation which will basically return the string value of the alias node: node.content. We will not do any resolution for now.

@char0n
Copy link
Member Author

char0n commented Feb 2, 2024

Addressed in #3785

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ApiDOM bug Something isn't working YAML
Projects
None yet
Development

No branches or pull requests

2 participants