Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deref JSON schemas #47

Merged
merged 4 commits into from
Apr 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we use the existing dependency tv4 for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While reading tv4's API I didn't find a way to dereference schemas.


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