Skip to content
This repository has been archived by the owner on Nov 19, 2018. It is now read-only.

Commit

Permalink
Some fixes and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Wojciech Możejko committed Aug 30, 2016
1 parent 2cee3a2 commit 5e645d2
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 61 deletions.
4 changes: 4 additions & 0 deletions assets/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ h1.ui.dividing.header {
margin-top: 20px;
}

resource-method>.ui.row {
padding-top: 15px;
}

.menu-column {
background: #1B1C1D;
}
Expand Down
4 changes: 4 additions & 0 deletions bin/ramldoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ app.singleton('schema-resolver', () => {
return resolver(api)
})

riot.tag('raw', '<span></span>', function(opts) {
this.root.innerHTML = opts.html
})

let componentsPath = path.join(__dirname, '../components/**/*.tag')

glob.sync(componentsPath).forEach(function(tag) {
Expand Down
2 changes: 2 additions & 0 deletions components/menu/menu.tag
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{ api.title() }
</a>

<!--
<div class="item">
<div class="header">Objects</div>

Expand All @@ -13,6 +14,7 @@
</a>
</div>
</div>
-->

<div class="item" each={ resource in api.resources() }>
<div class="header">{ resource.displayName() }</div>
Expand Down
67 changes: 67 additions & 0 deletions components/method/query-parameters.tag
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<query-parameters>
<div if={ queryParameters.length > 0 }>
<div class="ui small header">Query Parameters</div>

<table class="ui table">
<thead>
<tr>
<th width="160px">Name</th>
<th width="100px">Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr each={ param in queryParameters }>
<td>{ param.name() }</td>
<td>{ param.type() }</td>
<td>{getQueryParameterDescription(param) }</td>
</tr>
</tbody>
</table>
</div>

<script>
var _ = require('lodash')

this.method = opts.method

this.traits = _.map(this.method.parent().is(), (is) => {
return is.trait()
})

this.queryParameters = this.method.queryParameters()

this.traits.forEach((trait) => {
trait.queryParameters().forEach((queryParameter) => {
this.queryParameters.push(queryParameter)
})
})

this.getQueryParameterDescription = (queryParameter) => {
var description = ''
var details = []

if (queryParameter.description()) {
description = queryParameter.description().value() + ' '
}

if (queryParameter.kind() == 'StringTypeDeclaration' && queryParameter.enum().length) {
details.push('enum [' + queryParameter.enum().join(', ') + ']')
}

if (queryParameter.default()) {
details.push('default: ' + queryParameter.default())
}

if (queryParameter.example()) {
details.push('example: ' + queryParameter.example())
}

if (details.length) {
description = description + '(' + details.join(', ') + ')'
}

return description
}
</script>
</query-parameters>
39 changes: 1 addition & 38 deletions components/method/request.tag
Original file line number Diff line number Diff line change
@@ -1,40 +1,3 @@
<method-request>
<div if={ queryParameters.length > 0 }>
<div class="ui small header">Query Parameters</div>

<table class="ui table">
<thead>
<tr>
<th width="160px">Name</th>
<th width="100px">Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr each={ param in queryParameters }>
<td>{ param.name() }</td>
<td>{ param.type() }</td>
<td>{ param.default() }</td>
</tr>
</tbody>
</table>
</div>

<script>
var _ = require('lodash')

this.method = opts.method

this.traits = _.map(this.method.parent().is(), (is) => {
return is.trait()
})

this.queryParameters = this.method.queryParameters()

this.traits.forEach((trait) => {
trait.queryParameters().forEach((queryParameter) => {
this.queryParameters.push(queryParameter)
})
})
</script>
<query-parameters method={ opts.method } />
</method-request>
3 changes: 1 addition & 2 deletions components/method/response.tag
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@
}

if (this.method) {
console.error(this.method.responses()[0].body()[0].schemaContent())

this.jsonSchema = this.method.responses()[0].body()[0].schemaContent()

try {
this.jsonSchema = JSON.parse(this.jsonSchema)
} catch(e) {}
Expand Down
16 changes: 0 additions & 16 deletions components/resource/resource-child.tag

This file was deleted.

4 changes: 2 additions & 2 deletions components/resource/resource.tag
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
<resource-method method={ method } resource={ resource }
each={ method in resource.methods() }></resource-method>

<div each={ resource in resource.resources() }>
<virtual each={ resource in resource.resources() }>
<resource-method method={ method } resource={ resource }
each={ method in resource.methods() }></resource-method>
</div>
</virtual>

<script>
this.app = this.parent.app
Expand Down
20 changes: 20 additions & 0 deletions components/resource/uri-parameters.tag
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<resource-uri-parameters>
<div class="ui small header">URI Parameters</div>

<table class="ui table">
<thead>
<tr>
<th width="160px">Name</th>
<th width="100px">Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr each={ param in opts.resource.uriParameters() }>
<td>{ param.name() }</td>
<td>{ param.type() }</td>
<td>{ '' }</td>
</tr>
</tbody>
</table>
</resource-uri-parameters>
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"change-case": "^3.0.0",
"commander": "^2.9.0",
"deasync": "^0.1.7",
"glob": "^7.0.5",
Expand Down
9 changes: 6 additions & 3 deletions src/schema-resolver.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
var _ = require('lodash')
var changeCase = require('change-case')

module.exports = function (api) { return {
order: 1,

canRead: /\.json$/i,
canRead: /.*/i,

read: function(file, callback) {
let fileName = file.url.split('/').pop()
let fileName = file.url.split('/').pop().replace(/\.json/g, '')

let schema = _.find(api.schemas(), (schema) => {
return schema.key() + '.json' == fileName
let schemaName = changeCase.paramCase(schema.key())

return schemaName == fileName
})

callback(null, schema.value().value())
Expand Down

0 comments on commit 5e645d2

Please sign in to comment.