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

Improve Syntax Error reporting #282

Open
lamuertepeluda opened this issue Aug 26, 2021 · 2 comments
Open

Improve Syntax Error reporting #282

lamuertepeluda opened this issue Aug 26, 2021 · 2 comments
Labels
pinned Issues that will not be automatically closed WIP

Comments

@lamuertepeluda
Copy link

Hello and thank you very much for this tool!

I am using it but I found out that it is difficult to find the file that caused a syntax error.

Currently, a syntax error is reported like this:

YAMLSemanticError: Nested mappings are not allowed in compact mappings at line 23, column 25:

                  type: string
                        ^^^^^^…

No idea where this occurred, though! I was using a glob pattern like src/api/**/index.js where I have hundreds of folders with several API definitions per file... You can imagine my frustration!
I had to use the debugger to find it out. Of course this is not the best-comfort solution for an information that is already available to the parser!

Proposed solution

Why don't you include the filePath into the error? The information is already available here https://github.com/Surnet/swagger-jsdoc/blob/master/src/specification.js#L182

Just find a way to include it in the pushed errors https://github.com/Surnet/swagger-jsdoc/blob/master/src/specification.js#L198 and in the throwed errors https://github.com/Surnet/swagger-jsdoc/blob/master/src/specification.js#L264

Should I make a PR or do you prefer to handle this by yourself?

@daniloab
Copy link
Collaborator

Hi @lamuertepeluda thanks for the issue. Feel free to open a PR and implement this since you are fresh with the main idea of the issue.

I will just ask you to add tests and prints on the final pr.

@stale
Copy link

stale bot commented Oct 25, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Oct 25, 2021
@daniloab daniloab added the pinned Issues that will not be automatically closed label Oct 26, 2021
@stale stale bot removed the wontfix label Oct 26, 2021
@stale stale bot removed the wontfix label Oct 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pinned Issues that will not be automatically closed WIP
Projects
None yet
Development

No branches or pull requests

2 participants