KaiZen-OpenAPI-Editor
                                
                                 KaiZen-OpenAPI-Editor copied to clipboard
                                
                                    KaiZen-OpenAPI-Editor copied to clipboard
                            
                            
                            
                        Swagger spec which uses special characters shows an error dialog
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
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.
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 https://github.com/RepreZen/SwagEdit/pull/160
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 https://github.com/RepreZen/SwagEdit/pull/160#issuecomment-235268673 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)
Removed the High Priority flag. The suggested improvements remaining to be completed are not high priority right now.