-
Notifications
You must be signed in to change notification settings - Fork 5
[SW-502] Fixed SDK, added a working schema.json from vim-sw PHP SDK #8
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,15 +10,15 @@ export default class Api { | |
this.url = url; | ||
this.client = createClient(url, token, version) | ||
this.version = version; | ||
this.schema = require('./data/schema.json') | ||
} | ||
|
||
async _initialize() { | ||
let schema = await this.client.get('_info/entity-schema.json'); | ||
|
||
this.EntityDefinition = EntityDefinition; | ||
|
||
Object.keys(schema.data).forEach((entityName) => { | ||
this.EntityDefinition.add(entityName, schema.data[entityName]); | ||
Object.keys(this.schema).forEach((entityName) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Small refactor. data subkey is not exist in the new schema file. |
||
this.EntityDefinition.add(entityName, this.schema[entityName]); | ||
}); | ||
|
||
const hydrator = new EntityHydrator(this.EntityDefinition); | ||
|
@@ -39,7 +39,7 @@ export default class Api { | |
|
||
return new Repository( | ||
route, | ||
definition.entity, | ||
entityName, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously definition.entity returned null. Changed to another variable. |
||
this.client, | ||
hydrator, | ||
changesetGenerator, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ import axios from 'axios'; | |
|
||
export function createClient(url, token, version) { | ||
const client = axios.create({ | ||
baseURL: `${url}/api/v${version}` | ||
baseURL: `${url}/api` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed version from URL |
||
}) | ||
|
||
client.defaultUrl = url; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ export default class EntityDefinition { | |
*/ | ||
getPrimaryKeyFields() { | ||
return this.filterProperties((property) => { | ||
return property.flags.primary_key === true; | ||
return property.flags.primary === true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now primary field called 'primary' in the new schema.json |
||
}); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -462,8 +462,7 @@ export default class Repository { | |
let headers = { | ||
Accept: 'application/vnd.api+json', | ||
Authorization: `Bearer ${context.authToken.access}`, | ||
'Content-Type': 'application/json', | ||
'sw-api-compatibility': compatibility | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed, otherwise there was a cors error |
||
'Content-Type': 'application/json' | ||
}; | ||
|
||
if (context.languageId) { | ||
|
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we load the schematic from the local file