The HTML output by the html2 generator gives this error when run in Chrome:
index.html:11 Uncaught TypeError: Cannot read property '$ref' of undefined
at HTMLDocument.<anonymous> (index.html:1288)
4.0.0-SNAPSHOT
The below yaml is valid as per:
[q@local] docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli validate -i /local/api.yaml
Validating spec (/local/api.yaml)
No validation issues detected.
openapi: 3.0.0
info:
title: Anchor-ResMan adaptor
description: A RESTful API for retrieval of property data cached by the Anchor-ResMan adapter background service.
version: "1.0.0"
servers:
- description: SwaggerHub API Auto Mocking
url: https://virtserver.swaggerhub.com/strangecode/AnchorNW/1.0.0
paths:
/properties:
get:
summary: get a list of properties
operationId: searchProperties
description: |
Get a list of all properties, filtered by search criteria.
parameters:
- in: query
name: searchString
description: pass an optional search string for looking up inventory
required: false
schema:
type: string
- in: query
name: skip
description: number of records to skip for pagination
schema:
type: integer
format: int32
minimum: 0
- in: query
name: limit
description: maximum number of records to return
schema:
type: integer
format: int32
minimum: 0
maximum: 50
responses:
'200':
description: properties results matching criteria
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Property'
'400':
description: bad input parameter
components:
schemas:
Property:
type: object
properties:
propertyID:
type: string
format: uuid
example: '31ed6cca-b03a-4fbd-a65f-0e8c5e578e34'
name:
type: string
example: 'x UDG Everett LLC'
streetAddress:
type: string
example: '316 NE 28th Avenue'
city:
type: string
example: 'Portland'
state:
type: string
example: 'OR'
zip:
type: string
example: '97232'
phone:
type: string
example: '(503) 726-7220'
email:
type: string
example: '[email protected]'
manager:
type: string
example: 'Mylisa Giroski'
currentPeriodStart:
type: string
format: date
example: '2019-01-01'
currentPeriodEnd:
type: string
format: date
example: '2019-01-31'
docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli generate -g html2 -i /local/api.yaml -o /local

馃憤 Thanks for opening this issue!
馃彿 I have applied any labels matching special text in your issue.
The team will review the labels and make any necessary changes.
Were you able to find a work-around for this issue? I am running into this as well and I don't see an easy fix for this.
I ran into the same issue. I didn't fix it generator-side, but changing every instance of the line:
var schema = schemaWrapper.schema to
var schema = schemaWrapper.content['application/json'].schema;
in my generated index.html worked for me.
In the generated document, the schemaWrapper variable was formatted like this:
var schemaWrapper = {
"description" : "An example object with schema",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/example"
}
}
}
};
So it makes sense schemaWrapper.schema is undefined
Edit: I forgot, I also had to change each instance of:
schemaWrapper.definitions = Object.assign({}, defs);
to:
schemaWrapper.definitions = Object.assign({}, defs);
schemaWrapper.components = {};
schemaWrapper.components.schemas = Object.assign({}, defs);
We have the same problem, making it unusable for us. Is there a previous version we could fall back to which doesn't have this issue?
I switched to a different generator tool chain: https://github.com/tobilg/api2html
I switched to a different generator tool chain: https://github.com/tobilg/api2html
Nice thanks! We've opted for https://sourcey.com/spectacle for the time being, will have a look at that one too.
Most helpful comment
Were you able to find a work-around for this issue? I am running into this as well and I don't see an easy fix for this.