question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Data-only mode throws on init.

See original GitHub issue

Issue 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:open
  • Created 5 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
catullcommented, May 30, 2018

@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 as bootstrapping. That is the responsibility of angular2-json-schema-form.

0reactions
mringercommented, May 31, 2018

fair enough, thanks for the heads up.

Read more comments on GitHub >

github_iconTop Results From Across the Web

RTOS/TMDSLCDK6748: Uart callback mode reads the data only ...
Anyways, my goal is to read the data from a laser which throws a string at a specific frequency in the callback(non-blocking) mode....
Read more >
Can I throw from class init() in Swift with constant string loaded ...
I'd like my class init() in Swift to throw an error if something goes wrong with loading a file into a string within...
Read more >
Consent Settings In Google Tag Manager | Simo Ahava's blog
The Consent Mode initial config sets the default state of ad storage as denied and analytics storage as denied. That's all it does....
Read more >
How to: Perform Lazy Initialization of Objects - .NET Framework
Lazy initialization means objects aren't created if they're never needed. ... Initialize the data only if necessary if (someCondition) { if ...
Read more >
Initialization fails if localStorage is not available #1 - GitHub
store.js fails to initialize if localStorage is not available, ... for completeness // safely setup store.session (throws exception in FF ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found