-
Notifications
You must be signed in to change notification settings - Fork 125
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
Emit YAML processing errors that Xcode can display #81
Emit YAML processing errors that Xcode can display #81
Conversation
### Motivation If there are any errors in the openapi.yaml file currently the errors show up in the build transcript but are not shown in the Xcode issue sidebar and are also not linked to the openapi.yaml file in the sidebar. This makes it hard to know what has failed, and what to do to fix the file. ### Modifications The YAML parser now catches decoding errors, and if they are common parsing or scanning errors it will emit a diagnostic message then throw a failure exit code. This required importing the swift-argument-parser module into the main _OpenAPIGeneratorCore. Added `absoluteFilePath` and `lineNumber` optional properties to the `Diagnostics` struct to capture more info. Modified the `Diagnostics.description` method to build a properly formatted message that Xcode can parse to point out the file and line causing issues. ### Result In consuming projects, invalid yaml in the openapi.yaml file is now highlighted in the Xcode Issue Navigator after a build with this plugin. ### Test Plan Added unit tests to verify emitted diagnostic and thrown error. Also tested manually with an example project. ### Resolves - Resolves apple#65. Signed-off-by: Kyle Hammond <[email protected]>
I'm not particularly happy with adding Without it, any thrown error is caught by The code now throws an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, thanks for working on it, @macblazer! I think we can do this without the swift-argument-parser dependency, so I added a few comments.
…oes not rely on how ArgumentParser handles the throw. Signed-off-by: Kyle Hammond <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Just added a few requests for missing documentation comments, otherwise it's almost ready to go.
…nit tests with a custom assertion function. Signed-off-by: Kyle Hammond <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks!
@swift-server-bot add to allowlist |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @macblazer. This is a great step forward, here ❤️
Motivation
If there are any errors in the openapi.yaml file currently the errors show up in the build transcript but are not shown in the Xcode issue sidebar and are also not linked to the openapi.yaml file in the sidebar. This makes it hard to know what has failed, and what to do to fix the file.
Modifications
The YAML parser now catches decoding errors, and if they are common parsing or scanning errors it will emit a diagnostic message then throw a failure exit code. This required importing the swift-argument-parser module into the main _OpenAPIGeneratorCore.
Added
absoluteFilePath
andlineNumber
optional properties to theDiagnostics
struct to capture more info. Modified theDiagnostics.description
method to build a properly formatted message that Xcode can parse to point out the file and line causing issues.Result
In consuming projects, invalid yaml in the openapi.yaml file is now highlighted in the Xcode Issue Navigator after a build with this plugin.
Test Plan
Added unit tests to verify emitted diagnostic and thrown error. Also tested manually with an example project.
Resolves