Data-only mode throws on init.
See original GitHub issueIssue type
I’m submitting a (check one): [x] Bug report [ ] Feature request [ ] Regression (something that used to work, but stopped working in a newer version) [ ] Support request [ ] Documentation issue or request
Prerequisites
Before posting, make sure you do the following (check all): [x] Confirm you are using the latest versions of all necessary packages (or if not, explain why not) [x] Search GitHub for a similar issue or PR [x] If submitting a Support request, also search Stack Overflow for similar issues Note: Please cross-post GitHub support requests to Stack Overflow, and include a link in your GitHub issue to your Stack Overflow question. We do currently respond to support requests on GitHub, but we eventually expect to stop, and will then refer all support questions exclusively to Stack Overflow.
Current behavior
Using the configuration provided in the documentation creating a “Data Only” with no schema or layout defined throws.
JsonSchemaFormComponent
Error: no schema with key or ref "http://json-schema.org/draft-06/schema#"
at Ajv.validate (webpack:////Users/.../dev/github/.../.../web-app/node_modules/angular2-json-schema-form/node_modules/ajv/lib/ajv.js?:92:19)
at Ajv.validateSchema (webpack:////Users/.../dev/github/.../.../web-app/node_modules/angular2-json-schema-form/node_modules/ajv/lib/ajv.js?:178:22)
at Ajv._addSchema (webpack:////Users/.../dev/github/.../.../web-app/node_modules/angular2-json-schema-form/node_modules/ajv/lib/ajv.js?:312:10)
at Ajv.compile (webpack:////Users/.../dev/github/.../.../web-app/node_modules/angular2-json-schema-form/node_modules/ajv/lib/ajv.js?:112:24)
Expected behavior
Expect a form to be created mirroring the JSON doc provided as input.
IMPORTANT: How can we reproduce your problem?
import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
import {
MaterialDesignFrameworkModule,
JsonSchemaFormModule,
JsonSchemaFormService,
FrameworkLibraryService,
WidgetLibraryService,
Framework,
MaterialDesignFramework } from 'angular2-json-schema-form';
import { Component } from '@angular/core';
import { By } from '@angular/platform-browser';
/* tslint:disable:component-class-suffix */
describe('JsonSchemaFormComponent', () => {
let fixture: ComponentFixture<JsonSchemaFormBasicUsage>;
let component: JsonSchemaFormBasicUsage;
beforeEach(fakeAsync(() => {
TestBed.configureTestingModule({
declarations: [
JsonSchemaFormBasicUsage
],
imports: [
MaterialDesignFrameworkModule,
{
ngModule: JsonSchemaFormModule,
providers: [
JsonSchemaFormService,
FrameworkLibraryService,
WidgetLibraryService,
{provide: Framework, useClass: MaterialDesignFramework, multi: true}
]
}
// New Widgets must import their dependencies.
],
providers: []
})
.compileComponents();
fixture = TestBed.createComponent(JsonSchemaFormBasicUsage);
component = fixture.componentInstance;
}));
fit('should build the json-schema-form basic usage', () => {
fixture.detectChanges();
expect(component).toBeTruthy();
});
});
@Component({
template: `
<json-schema-form
loadExternalAssets="true"
[(ngModel)]="exampleJsonObject">
</json-schema-form>
`
})
class JsonSchemaFormBasicUsage {
exampleJsonObject: any;
constructor() {
this.exampleJsonObject = {
'first_name': 'Jane', 'last_name': 'Doe', 'age': 25, 'is_company': false,
'address': {
'street_1': '123 Main St.', 'street_2': null,
'city': 'Las Vegas', 'state': 'NV', 'zip_code': '89123'
},
'phone_numbers': [
{ 'number': '702-123-4567', 'type': 'cell' },
{ 'number': '702-987-6543', 'type': 'work' }
], 'notes': ''
};
}
}
Environment
OS name & version: OS X 10.13.4 Browser name & version: Chrome 66.0.3359.181 Angular version: 5.1.0 Angular JSON Schema Form version(s): 0.7.0-alpha.1 Other relevant software or packages:
Any other relevant information
Issue Analytics
- State:
- Created 5 years ago
- Comments:8
Top GitHub Comments
@mringer I have around 20 schemata, most of them are independent. A few reference one of the other schemata.
All of them must be “spoon-fed” upfront to
ajv
, first all $ref-ed ones, then all the other ones. Without the trick above, I get a lot of runtime errors about schema A not being known when $ref-ed from Schema B etc.I do agree with you that all draft JSON schemata (v4, v5, v6, v7 and soon v8) MUST be registered with
ajv
- you refer to it asbootstrapping
. That is the responsibility ofangular2-json-schema-form
.fair enough, thanks for the heads up.