Skip to content

refactor: add iterator for traversing an AsyncAPI doc - #604

Merged
asyncapi-bot merged 2 commits into
asyncapi:next-majorfrom
smoya:feat/traverse
Sep 13, 2022
Merged

asyncapi-bot merged 2 commits into
asyncapi:next-majorfrom
smoya:feat/traverse

Conversation

@smoya

@smoya smoya commented Sep 9, 2022 •

Copy link
Copy Markdown
Member

Description
This PR adds an iterator for traversing AsyncAPI documents. It is based in the current one. See https://github.com/asyncapi/parser-js/blob/master/lib/iterators.js

Related issue(s)
#481

Comment thread .eslintrc
no-empty-character-class: 2
no-self-compare: 2
valid-typeof: 2
no-unused-vars: [2, { "args": "none" }]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not compatible with Typescript, however we also use the compatible version so I'm just removing the support here.

@smoya
smoya force-pushed the feat/traverse branch 2 times, most recently from 2fdaf3b to f5ddec2 Compare September 9, 2022 17:19
@smoya
smoya marked this pull request as ready for review September 12, 2022 07:33
@smoya
smoya force-pushed the feat/traverse branch 2 times, most recently from 8b771c8 to 8abbfe5 Compare September 13, 2022 07:53

@magicmatatjahu magicmatatjahu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only two comments :)

Comment thread src/iterator.ts Outdated
seenSchemas: Set<any>
}

export type TraverseCallback = (schema: SchemaInterface, propOrIndex: String | Number | null, callbackType: SchemaIteratorCallbackType) => void

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export type TraverseCallback = (schema: SchemaInterface, propOrIndex: String | Number | null, callbackType: SchemaIteratorCallbackType) => void
export type TraverseCallback = (schema: SchemaInterface, propOrIndex: string | number | null, callbackType: SchemaIteratorCallbackType) => void

Comment thread src/iterator.ts Outdated
/**
* Traverse current schema and all nested schemas.
*/
function traverseSchema(schema: SchemaInterface, propOrIndex: String | Number | null, options: TraverseOptions) { // NOSONAR

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function traverseSchema(schema: SchemaInterface, propOrIndex: String | Number | null, options: TraverseOptions) { // NOSONAR
function traverseSchema(schema: SchemaInterface, propOrIndex: string | number | null, options: TraverseOptions) { // NOSONAR

@smoya

smoya commented Sep 13, 2022 •

Copy link
Copy Markdown
Member Author

@magicmatatjahu would you mind reviewing again? I fixed the linting issues but also improved the tests. Thanks!

@smoya
smoya requested review from magicmatatjahu and removed request for asyncapi-bot-eve, derberg, fmvilas and jonaslagoni September 13, 2022 08:37
@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@smoya

smoya commented Sep 13, 2022

Copy link
Copy Markdown
Member Author

/rtm

@asyncapi-bot
asyncapi-bot merged commit d69d6c5 into asyncapi:next-major Sep 13, 2022
@smoya
smoya deleted the feat/traverse branch September 13, 2022 09:15
@smoya smoya mentioned this pull request Sep 13, 2022
14 of 20 tasks
magicmatatjahu pushed a commit to magicmatatjahu/parser-js that referenced this pull request Oct 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants