Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
mokkabonna committed Mar 16, 2018
1 parent 2a12f02 commit 216df13
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 7 deletions.
2 changes: 1 addition & 1 deletion demo/server/index.js
Expand Up @@ -46,7 +46,7 @@ app.get('/api/things/:id', function(req, res) {
}
res.set('link', formatter(links))

if (req.params.id === 12345) {
if (req.params.id === '12345') {
res.send({id: 12345, data: {}})
} else {
res.send({id: 67890, data: {}})
Expand Down
4 changes: 2 additions & 2 deletions demo/src/components/Browser.vue
Expand Up @@ -14,12 +14,12 @@
<nav>
<h1>Links</h1>
<ul class="links">
<li v-for="link in resource.links" :key="link.rel">
<li v-for="link in resource.links" :key="link.rel + link.uri">
<router-link :to="{ name: 'Browser', query: {uri: link.uri} }">{{link.title || link.rel}}</router-link>
</li>
</ul>
<ul v-if="fetchSchemas.isResolved" class="links">
<li v-for="link in schemaLinks" :key="link.rel">
<li v-for="link in schemaLinks" :key="link.rel + link.targetUri">
<router-link :to="{ name: 'Browser', query: {uri: link.targetUri} }">{{link.title || link.rel}}</router-link>
</li>
</ul>
Expand Down
4 changes: 2 additions & 2 deletions demo/static/thing.json
@@ -1,7 +1,7 @@
{
"$id": "https://schema.example.com/thing",
"$schema": "http://json-schema.org/draft-07/hyper-schema#",
"base": "https://api.example.com/",
"base": "https://api.example.com/things/",
"type": "object",
"required": ["data"],
"properties": {
Expand All @@ -12,7 +12,7 @@
},
"links": [{
"rel": "self",
"href": "things/{id}",
"href": "{id}",
"templateRequired": ["id"],
"targetSchema": {
"$ref": "#"
Expand Down
27 changes: 26 additions & 1 deletion demo/static/things.json
Expand Up @@ -9,7 +9,32 @@
"type": "array",
"items": {
"allOf": [{
"$ref": "thing.json#"
"$id": "https://schema.example.com/thing",
"$schema": "http://json-schema.org/draft-07/hyper-schema#",
"base": "https://api.example.com/things",
"type": "object",
"required": ["data"],
"properties": {
"id": {
"$ref": "#/definitions/id"
},
"data": true
},
"links": [{
"rel": "self",
"href": "{id}",
"templateRequired": ["id"],
"targetSchema": {
"$ref": "#"
}
}],
"definitions": {
"id": {
"type": "integer",
"minimum": 1,
"readOnly": true
}
}
}],
"links": [{
"anchorPointer": "",
Expand Down
2 changes: 1 addition & 1 deletion src/resolver.js
Expand Up @@ -150,7 +150,7 @@ function getAllSchemaLinks(schema) {
traverse(schema, function(subSchema, pointer, root, parentPointer, parentKeyWord) {
links = links.concat((subSchema.links || []).map(l => createLink(l, pointer, parentPointer, parentKeyWord)))
})

console.log(links)
return links
}

Expand Down

0 comments on commit 216df13

Please sign in to comment.