-
Notifications
You must be signed in to change notification settings - Fork 126
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 errors processing .yaml files that Xcode can display #65
Comments
That's a great idea. The CLI, which is used by the plugin, already emits warning and error diagnostics in a format that gets picked up by Xcode's Issue Navigator, but as you report here, that's not the case when the YAML parser throws an error. The way I understand it, the piece of work here would be to catch this exact error in YAML parsing, extract the location information, and emit a Diagnostic with the right file path and line number, so that it shows up in IDEs correctly. |
@czechboy0 I'd love to work on this little bit of functionality. Can you point me at some other diagnostic code that outputs things in the right format for Xcode? I've pretty much figured out how to catch the yaml decoding error, but I'm unsure what to do with all the parts of the info I have (file path, line number, column, and the parsing error message). |
@macblazer Great, thanks for considering to take it on! The printing of diagnostics happens in
The text formatting of diagnostics happens in
You might need to make some changes to the Diagnostic struct to add location to make it print in the format |
### 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]>
### 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 #65. --------- Signed-off-by: Kyle Hammond <[email protected]>
I got the following error in the build transcript:
It would be great if this were something Xcode could parse and show as an error in the error navigator.
The text was updated successfully, but these errors were encountered: