x)- [X] bug report -> please search issues before submitting
- [ ] feature request
- [X] devkit
- [ ] schematics
node --version v8.11.1
npm --version 6.1.0
{
"$schema": "http://json-schema.org/draft-06/schema",
"title": "My builder schema",
"type": "object",
"allOf": [
{
"$ref": "file://../../node_modules/@angular-devkit/build-angular/src/browser/schema.json#"
}
],
"properties": {
"myProp": {
"type": "object"
}
},
"additionalProperties": false
}
or
{
"$schema": "http://json-schema.org/draft-06/schema",
"title": "My builder schema",
"type": "object",
"allOf": [
{
"$ref": "../../node_modules/@angular-devkit/build-angular/src/browser/schema.json#"
}
],
"properties": {
"myProp": {
"type": "object"
}
},
"additionalProperties": false
}
Protocol "file:" not supported. Expected "http:"
Error: Protocol "file:" not supported. Expected "http:"
at new ClientRequest (_http_client.js:131:11)
at request (http.js:38:10)
at Object.get (http.js:42:13)
at Promise (C:\Users\User\source\repos\AutoFluent-Cloud\autofluent-clients\node_modules\@angular-devkit\core\src\json\schema\registry.js:74:18)
at new Promise ()
at CoreSchemaRegistry._fetch (C:\Users\User\source\repos\AutoFluent-Cloud\autofluent-clients\node_modules\@angular-devkit\core\src\json\schema\registry.js:73:16)
at Object.loadSchema (C:\Users\User\source\repos\AutoFluent-Cloud\autofluent-clients\node_modules\@angular-devkit\core\src\json\schema\registry.js:61:39)
at loadMissingSchema (C:\Users\User\source\repos\AutoFluent-Cloud\autofluent-clients\node_modules\@angular-devkit\core\node_modules\ajv\lib\compile\async.js:67:64)
at _compileAsync (C:\Users\User\source\repos\AutoFluent-Cloud\autofluent-clients\node_modules\@angular-devkit\core\node_modules\ajv\lib\compile\async.js:56:48)
at C:\Users\User\source\repos\AutoFluent-Cloud\autofluent-clients\node_modules\@angular-devkit\core\node_modules\ajv\lib\compile\async.js:32:34
or
Unable to determine the domain name
Error: Unable to determine the domain name
at new ClientRequest (_http_client.js:85:13)
at request (http.js:38:10)
at Object.get (http.js:42:13)
at Promise (C:\Users\User\source\repos\AutoFluent-Cloud\autofluent-clients\node_modules\@angular-devkit\core\src\json\schema\registry.js:74:18)
at new Promise ()
at CoreSchemaRegistry._fetch (C:\Users\User\source\repos\AutoFluent-Cloud\autofluent-clients\node_modules\@angular-devkit\core\src\json\schema\registry.js:73:16)
at Object.loadSchema (C:\Users\User\source\repos\AutoFluent-Cloud\autofluent-clients\node_modules\@angular-devkit\core\src\json\schema\registry.js:61:39)
at loadMissingSchema (C:\Users\User\source\repos\AutoFluent-Cloud\autofluent-clients\node_modules\@angular-devkit\core\node_modules\ajv\lib\compile\async.js:67:64)
at _compileAsync (C:\Users\User\source\repos\AutoFluent-Cloud\autofluent-clients\node_modules\@angular-devkit\core\node_modules\ajv\lib\compile\async.js:56:48)
at C:\Users\User\source\repos\AutoFluent-Cloud\autofluent-clients\node_modules\@angular-devkit\core\node_modules\ajv\lib\compile\async.js:32:34
$ref relative schemas
take off the protocol. file:// is not support by ajv and not needed by the specification. For additional examples, please see here: https://spacetelescope.github.io/understanding-json-schema/structuring.html
With out file:// you get:
Unable to determine the domain name
Error: Unable to determine the domain name
at new ClientRequest (_http_client.js:85:13)
at request (http.js:38:10)
at Object.get (http.js:42:13)
at Promise (C:\Users\User\source\repos\AutoFluent-Cloud\autofluent-clients\node_modules\@angular-devkit\core\src\json\schemaregistry.js:74:18)
at new Promise ()
at CoreSchemaRegistry._fetch (C:\Users\User\source\repos\AutoFluent-Cloud\autofluent-clients\node_modules\@angular-devkit\core\src\json\schemaregistry.js:73:16)
at Object.loadSchema (C:\Users\User\source\repos\AutoFluent-Cloud\autofluent-clients\node_modules\@angular-devkit\core\src\json\schemaregistry.js:61:39)
at loadMissingSchema (C:\Users\User\source\repos\AutoFluent-Cloud\autofluent-clients\node_modules\@angular-devkit\core\node_modulesajv\lib\compile\async.js:67:64)
at _compileAsync (C:\Users\User\source\repos\AutoFluent-Cloud\autofluent-clients\node_modules\@angular-devkit\core\node_modulesajv\lib\compile\async.js:56:48)
at C:\Users\User\source\repos\AutoFluent-Cloud\autofluent-clients\node_modules\@angular-devkit\core\node_modulesajv\lib\compile\async.js:32:34
@clydin please reopen as it is still not possible to use relative schema references.
@clydin also following https://spacetelescope.github.io/understanding-json-schema/structuring.html I added an id but now get Request failed. Status Code: 404, I don't want to publicly host my schema
The current implementation only use http for asynchronous schema compilation using the loadSchema option of ajv, then we are only able to reference schemas using _http_ (for which there no really extended usefullness, most schema json on the web are available using https), neither https nor a local file are available,
this._ajv = ajv({
formats: formatsObj,
loadSchema: (uri) => this._fetch(uri),
schemaId: 'auto',
passContext: true,
});
The implementation of the _fetch in registry.js should allow to handle file://(possibly simply using the path module + a require()), http:// (with the http module, already implemented), https:// (with the https module). This way there will be freedom of choice when build schemas
Any news?
Most helpful comment
The current implementation only use http for asynchronous schema compilation using the
loadSchemaoption ofajv, then we are only able to reference schemas using _http_ (for which there no really extended usefullness, most schema json on the web are available using https), neither https nor a local file are available,The implementation of the
_fetchinregistry.jsshould allow to handlefile://(possibly simply using thepathmodule + arequire()),http://(with thehttpmodule, already implemented),https://(with thehttpsmodule). This way there will be freedom of choice when build schemas