-
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?
Conversation
@@ -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') |
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
|
||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Small refactor. data subkey is not exist in the new schema file.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Previously definition.entity returned null. Changed to another variable.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
removed version from URL
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Now primary field called 'primary' in the new schema.json
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Removed, otherwise there was a cors error
No description provided.