Skip to content

Commit

Permalink
Merge pull request #47 from the-grid/deref-json-schemas
Browse files Browse the repository at this point in the history
Deref JSON schemas
  • Loading branch information
jonnor committed Apr 25, 2016
2 parents fc682a7 + ab0bb42 commit 4b94835
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules/
schema/
full-schema/
dist/
gh-pages/
/examples/*.json
16 changes: 16 additions & 0 deletions Gruntfile.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
path = require 'path'
deref = require 'json-schema-deref-sync'

module.exports = ->
# Project configuration
Expand Down Expand Up @@ -105,12 +106,27 @@ module.exports = ->
@file.write filename, JSON.stringify d._data, null, 2
@log.writeln "Created example file '#{filename}'"

# Custom task for generating full JSON schemas by dereferencing original schemas
@registerTask 'build_fullschemas', 'Create full schemas dereferencing them', =>
options =
baseFolder: 'schema'
@file.mkdir 'full-schema'
schemas = @file.expand ['schema/*.json']
schemas.forEach (e) =>
schema = @file.readJSON e
fullschema = deref schema, options
basename = path.basename e
filename = "full-schema/#{basename}"
@file.write filename, JSON.stringify fullschema, null, 2
@log.writeln "Created full schema #{filename}"

# Our local tasks
@registerTask 'build', 'Build', (target = 'all') =>
@task.run 'yaml'
@file.mkdir 'dist'
@task.run 'copy'
@task.run 'build_examples'
@task.run 'build_fullschemas'
@task.run 'aglio'

@registerTask 'test', 'Build and run tests', (target = 'all') =>
Expand Down
18 changes: 9 additions & 9 deletions blueprint/api.apib
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Performing such an action returns a Location header with a Job URL.
+ Schema

```
<!-- include(schema/site.json) -->
<!-- include(full-schema/site.json) -->
```

+ Response 201
Expand Down Expand Up @@ -97,7 +97,7 @@ Performing such an action returns a Location header with a Job URL.
+ Schema

```
<!-- include(schema/site.json) -->
<!-- include(full-schema/site.json) -->
```

### Update website details [PUT]
Expand All @@ -113,15 +113,15 @@ Performing such an action returns a Location header with a Job URL.
+ Schema

```
<!-- include(schema/site.json) -->
<!-- include(full-schema/site.json) -->
```

+ Response 200 (application/json)

+ Schema

```
<!-- include(schema/site.json) -->
<!-- include(full-schema/site.json) -->
```

### Delete website [DELETE]
Expand Down Expand Up @@ -187,7 +187,7 @@ Note that publishing an item to a website is a separate step. See /publish
+ Schema

```
<!-- include(schema/share.json) -->
<!-- include(full-schema/share.json) -->
```


Expand Down Expand Up @@ -269,7 +269,7 @@ When an item is being worked on by a user it is available via the API. Queries w
+ Schema

```
<!-- include(schema/item.json) -->
<!-- include(full-schema/item.json) -->
```

+ Response 404
Expand All @@ -281,7 +281,7 @@ When an item is being worked on by a user it is available via the API. Queries w
+ Schema

```
<!-- include(schema/item.json) -->
<!-- include(full-schema/item.json) -->
```

+ Response 422
Expand Down Expand Up @@ -321,7 +321,7 @@ TODO: make return a Job id in Location header
+ Schema

```
<!-- include(schema/publish.json) -->
<!-- include(full-schema/publish.json) -->
```

+ Response 202
Expand All @@ -343,7 +343,7 @@ TODO: make return a Job id in Location header
+ Schema

```
<!-- include(schema/publish.json) -->
<!-- include(full-schema/publish.json) -->
```

+ Response 202
Expand Down
4 changes: 2 additions & 2 deletions blueprint/passport.apib
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The Grid Passport is The Grid's account system that is responsible for access co
+ Schema

```
<!-- include(schema/user.json) -->
<!-- include(full-schema/user.json) -->
```

### Update user information [PUT]
Expand Down Expand Up @@ -61,7 +61,7 @@ Update the current user's profile information, for example to add missing detail
+ Schema

```
<!-- include(schema/user.json) -->
<!-- include(full-schema/user.json) -->
```

## User's public GitHub Token [/api/user/github]
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"grunt-mocha-test": "^0.12.7",
"grunt-yaml": "^0.4.1",
"grunt-yamllint": "^0.2.0",
"json-schema-deref-sync": "^0.3.0",
"mocha": "^2.1.0",
"tv4": "^1.1.9"
},
Expand Down

0 comments on commit 4b94835

Please sign in to comment.