Solve "Invalid Swagger 2.0 input" when import swagger to AWS API
1. Do not use single quotes ('
) when defining strings.
Wrong: { "key":'something' }
Use double ("
) instead:
{ "key":"something" }
For some reason, swagger web editor (http://editor.swagger.io/) validates single quotes and there are many examples on the network which use it for example for defining pattern
, but this will not be considered as valid on AWS:
{ "pattern": '^(\d{2})$' }
2. Do not use unescaped backslash inside of quotes.
Wrong:
{ "pattern": "^(\d)$" }
Right:
{ "pattern": "^(\\d)$" }
Use an external JSON validator (e.g. http://jsonlint.com/) which will give you an error on the specific position. AWS doesn't show an error reason it only says that it invalid.
Bug in the Amazon web console
If you load swagger from local file on PC to amazon web console there are some bug when you reselect file it not reloads - you need to update page (F5
) before reupload