Skip to content

Commit

Permalink
Merge 6696973 into a28df38
Browse files Browse the repository at this point in the history
  • Loading branch information
romulo1984 committed Nov 26, 2018
2 parents a28df38 + 6696973 commit 74d0b57
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ For detail usage, please check the swagger specification in this [link][SwaggerS
Command | Description
:-----------------------------|:-----------
`adonis swagger:export` | Export config file & swagger-ui assets
`adonis swagger:export-docs` | Export swagger-ui assets only
`adonis swagger:remove` | Remove config file & swagger-ui assets
`adonis swagger:remove-docs` | Remove swagger-ui only

Expand All @@ -130,4 +131,4 @@ Special thanks to the creator(s) of [AdonisJS][AdonisJS] for creating such a gre

[Swagger]:https://swagger.io/
[SwaggerSpec]:https://swagger.io/specification/
[AdonisJS]: http://adonisjs.com/
[AdonisJS]: http://adonisjs.com/
26 changes: 26 additions & 0 deletions commands/SwaggerExportDocs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict'

const { Command } = require('@adonisjs/ace')
const path = require('path')

class SwaggerExportDocs extends Command {
static get signature () {
return `
swagger:export-docs
{ --silent : Hide the console log }
`
}

static get description () {
return 'Export swagger-ui assets only'
}

async handle (args, options) {
if (!options.silent) this.info('Exporting assets to public folder (public/docs)')
await this.copy(path.join(__dirname, '../templates/docs'), 'public/docs')

if (!options.silent) this.success(`${this.icon('success')} Completed`)
}
}

module.exports = SwaggerExportDocs
2 changes: 2 additions & 0 deletions providers/SwaggerProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ class SwaggerProvider extends ServiceProvider {

_registerCommands () {
this.app.bind('Adonis/Commands/SwaggerExport', () => require('../commands/SwaggerExport'))
this.app.bind('Adonis/Commands/SwaggerExportDocs', () => require('../commands/SwaggerExportDocs'))
this.app.bind('Adonis/Commands/SwaggerRemove', () => require('../commands/SwaggerRemove'))
this.app.bind('Adonis/Commands/SwaggerRemoveDocs', () => require('../commands/SwaggerRemoveDocs'))
}

_addCommands () {
const ace = require('@adonisjs/ace')
ace.addCommand('Adonis/Commands/SwaggerExport')
ace.addCommand('Adonis/Commands/SwaggerExportDocs')
ace.addCommand('Adonis/Commands/SwaggerRemove')
ace.addCommand('Adonis/Commands/SwaggerRemoveDocs')
}
Expand Down

0 comments on commit 74d0b57

Please sign in to comment.