$ in model description causes exception, html will not load
DavidBiesack opened this issue · 10 comments
Run the command
pretty-swag -i openapi.yaml -o /tmp/openapi.html
on the below openapi.yaml ; when viewing in the browser (Chrome on Mac OS X), the JavaScript gets an exception
Uncaught SyntaxError: Invalid or unexpected token
and the document is not rendered.
It looks like something is truncated:
"schema": "{\n \"value\": \"string\" /* Strings which follow the regular expression pattern: `-?\\d{1,15}\\.\\d{1,9}<!DOCTYPE html>
Here is the openapi.yaml:
swagger: '2.0'
info:
title: pretty-swag-bug
description: parse error in schema/javascript
version: '1'
termsOfService: Pending.
consumes:
- application/json
produces:
- application/json
paths:
/:
get:
responses:
'200' :
description: OK
schema:
$ref: '#/definitions/model'
definitions:
model:
properties:
value:
description: "Strings which follow the regular expression pattern:
`-?\\d{1,15}\\.\\d{1,9}$`
such as 325.50 or -200.75."
type: string
Thanks for reporting I'll make a patch this evening.
rolled out the patch. Check it out and let me know.
thanks - works for this test case.
The problem still shows up when I try this on my full openapi.yaml (which I can't post here) but that may be my npm environment.
The earlier problem was about templating that I use. Can you shrink your schema again and see if the problem is still around $ sign?
The schema I reported here was taken from my larger openapi.yaml file. Your patch works in the small case, but fails the same way on the larger file (same problem - the description string gets clipped at the dollar sign backtick combination.) If I can carve off time, I'll try to successively trim the file down to something that still exhibits the problem
I am able to reproduce the bug. Thanks for reporting!
I rolled out another patch. It should address this problem for good. Let me know!
Have you had a chance to try?
Yes, the latest update resolves the problem in my full test case. Thanks for the patches.
Thanks for reporting back 👍