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

Swagger spec which uses special characters shows an error dialog #158

Open
tfesenko opened this issue Jul 15, 2016 · 4 comments
Open

Swagger spec which uses special characters shows an error dialog #158

tfesenko opened this issue Jul 15, 2016 · 4 comments

Comments

@tfesenko
Copy link
Member

We have a Windows user who uses special characters (from Icelandic alphabet).
The user reported the following error (see https://support.reprezen.com/helpdesk/tickets/133):

‘Update SwagEdit validation markers‘ has encountered a problem.
An internal error occurred during: “Update SwagEdit validation markers“

When I press details I get some extra info that seems to point to some encoding issue.
I can‘t seem to find anything on google regarding this issue so I really need your help.
I will send a screenshot as well as the .yaml code as it is right now.

I am running on windows.

I had been writing the project for a couple hours without any problems when this suddenly happened.
I am not entirely sure what I did but it felt like this happened when I hit CTRL + S to save the project.

I was able to reproduce it on Mac. Note that original encoding is "iso-8859-1":

file -I creditcards.yaml
creditcards.yaml: text/plain; charset=iso-8859-1

Also, the spec is invalid because the host is not specified:

info:
  description: yoyoyo
  version: 1.0.0
  title: CreditCards
host: 

This has high priority

@tedepstein
Copy link
Collaborator

Heard back from Egill:

Thanks for quick responses, great service. It worked for me to set the default to UTF-8 and writing Icelandic letters even seems to work after that.

I'm still not sure what this means for us though: should we change the default encoding for Windows installation and possibly other platforms, and/or just recommend this as a workaround if users encounter the problem? Or is there a better solution?

Also, I assume we need to do something with exception handling so that users don't see repeated modal error messages whenever they type in the editor.

I've attached the problem source file here.

creditcards.zip

@ghillairet
Copy link
Member

The problem looks like JSON only allows UTF encodings, the special character contain in the sample projects were encoded in iso-8859-1 which causes a parsing exception to be thrown.

I made the changes to force the parsing of swagger document using UTF-8 encoding.

I don't know what's the default file encoding in Eclipse for Windows, but we should encourage users to set it to UTF-8. This can be done in Eclipse > Preferences > General > Workspace > Text file encoding.

Link to PR #160

@tfesenko tfesenko self-assigned this Sep 14, 2016
@tfesenko
Copy link
Member Author

tfesenko commented Sep 14, 2016

I suggest to limit the scope of this issue to the following:
Do not show an error dialog, show a warning instead. When invalid sequences are encountered, create a warning to that effect. This might be difficult to address in SwagEdit, and may require changes to YEdit. Here I'm talking about invalid encodings, not invalid YAML or Swagger.
#198 may help with it.

See #160 (comment) for details

I will extract other parts, e.g. for contentTypes into other issues.

Modify API Studio to ensure that the workspace default encoding is always UTF-8 in our RCP product.
Modify SwagEdit to check the workspace default encoding and offer some sort of warning dialog explaining the situation and offering to change the preference (should also have a "don't bother me about this again" checkbox).

Covered by Use UTF-8 as default content type for JSON, Xtend and RAPID-ML Files

Create a FAQ item explaining the issue and our recommended practice.

See [https://modelsolv.atlassian.net/browse/ZEN-2894](Create a FAQ item about encodings)

@tedepstein
Copy link
Collaborator

Removed the High Priority flag. The suggested improvements remaining to be completed are not high priority right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants