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
0.2.5 & 0.2.6 Cannot parse Swagger definition #275
Comments
@Tanbouz, I landed here via google due to the same issue, using the example from https://github.com/awslabs/serverless-application-model/blob/master/examples/2016-10-31/api_swagger_cors/swagger.yaml, same errors on 0.2.6. A json template might be a workaround. https://github.com/awslabs/aws-sam-local/blob/develop/test/templates/open-api/pet-store-simple.json loaded successfully for me during sam local start-api. simple template.yaml excerpt:
|
It is external YAML that does not work. External JSON works fine. |
Using yaml2json as global, I was able to use prestart npm to convert it. Then use npm start to run sam local start-api using the json as the ref in template.yaml as a work around. Adding the json file to ignore git list so it not commited. |
@majway27 @pal-philbasford - I got the same issue after updating to 0.2.6. As you've suggested, using a json swagger file instead of the yaml solved it for me. |
Ran into this today as well, switching to json fixed it. |
The bug is here: Line 42 assumes that the file loaded is a JSON file. |
If the file location is a string, in my case it was 'api.yml', then the first case is met: The URI method only reads the file, regardless of contents: The YAML file text is being saved in the variable 'jsonDefinition', failing at line 42 when it tries to parse the YAML as JSON. |
how are you people dealing with variable in the JSON file? For example: I have this in my template.yml
when used in the JSON version of the swagger spec? I get this error: |
I wrote a node app that generates a template.yml and api.json from ejs templates. All of my lambda functions are in a subfolder. Running the app creates an api for all of them when preparing to do a deployment. |
Also broken upgrading from 0.2.4 to 0.2.6. Is this issue planned to be patched? I didn't realize JSON was the only supported Swagger format. Error I get is: |
I got this error as well, removing |
I also found that quoting works fine. So |
I've had the same experience. Simple workaround, but odd. |
this is fixed as of v0.3.0 |
0.2.4
sam local start-api
works fine0.2.5 & 0.2.6
Cannot parse Swagger definition: invalid character '-' in numeric literal
If I remove the
---
it willCannot parse Swagger definition: invalid character 's' looking for beginning of value
Using external swagger file since according to docs in-line is not yet supported.
Anyone else facing the same issue?
The text was updated successfully, but these errors were encountered: