Last active
September 26, 2018 08:10
-
-
Save Samsinite/d6c8aa56aed2b0c195413d92a8c40ce7 to your computer and use it in GitHub Desktop.
Javascript API Annotation DSL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/instance-initializers/schema.js | |
import fetch from 'fetch' | |
import { loadSchema } from 'wildland-schema/ember-data'; | |
import ENV from '../config/environment'; | |
// load schema and store to report usage violations | |
export function initialize(applicationInstance) { | |
if (ENV.environment === 'development') { | |
const store = applicationInstance.lookup('service:store'); | |
fetch('/api/v1/schema').then(response => response.json()) | |
.then(jsonSchema => loadSchema(store, jsonSchema)); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// models/baz.js | |
import DS from 'ember-data'; | |
import Schema from 'wildland-schema/ember-data'; | |
const Baz default DS.Model.extend({ | |
foo: DS.belongsTo('foo'), | |
oldThing: DS.attr(), | |
thing: DS.attr(), | |
bar: DS.attr(), | |
}); | |
export default Schema(Baz); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment