Skip to content
Open
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
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,19 @@ will change the extension from `.dsl` to `.json`.

More generally, `-r` or `--rename` accepts a comma-delimited regular expression, string pair. The regular expression will be matched against the input filename, and the string will be used to generate the output filename (by replacing `$n` with the text matching *n*th group in the regular expression).

### Multiple output file
Using `-r`, you can generate multiple json file.

If you have `src/swagger` and `src/swagger2` named DSL,

```bash
swagger-dsl src/* -r /^src/,\'dest\'
```

this command output `dest/swagger` and `dest/swagger2`.





## Licensing
Expand Down
7 changes: 3 additions & 4 deletions lib/swagger-dsl.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
marked = require 'marked'
child_process = require 'child_process'
pathLib = require 'path'

# "private" (not-exported) methods
_clone = (a)->
Expand Down Expand Up @@ -228,10 +230,6 @@ init = (self,options)->
# **base(path)** sets the document's `basePath` property.
this.base = this.basepath = this.base_path = this.basePath = (path)=>
rest.basePath = path

# **resourcePath(path)** sets the document's `resourcePath` property.
this.resourcePath = this.resource_path = this.resourcepath = (path)=>
rest.resourcePath = path


# For "convenience", we add variables containing the string version of
Expand Down Expand Up @@ -427,6 +425,7 @@ _main = (argv,logfn,errfn,callback)=>
if argv.o is '-'
logfn json
else
child_process.execSync("mkdir -p #{pathLib.dirname(argv.o)}")
fs.writeFileSync(argv.o,json)
callback()
finally
Expand Down
47 changes: 27 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,39 @@
{
"name" : "swagger-dsl",
"version" : "0.2.2",
"description" : "CoffeeScript-based domain-specific language for generating JSON documents for Swagger.",
"repository" : { "type": "git", "url": "https://github.com/intellinote/swagger-dsl.git" },
"bugs" : { "url": "https://github.com/intellinote/swagger-dsl/issues" },
"license" : "MIT",
"author" : "Intellinote",
"name": "swagger-dsl",
"version": "0.2.2",
"description": "CoffeeScript-based domain-specific language for generating JSON documents for Swagger.",
"repository": {
"type": "git",
"url": "https://github.com/intellinote/swagger-dsl.git"
},
"bugs": {
"url": "https://github.com/intellinote/swagger-dsl/issues"
},
"license": "MIT",
"author": "Intellinote",
"dependencies": {
"coffee-script" : "latest",
"optimist" : "latest",
"marked" : "latest"
"coffee-script": "latest",
"marked": "latest",
"optimist": "latest"
},
"devDependencies": {
"browserify" : "latest",
"uglify-js" : "latest",
"coffee-coverage" : "latest",
"docco" : "latest",
"highlight.js" : "latest",
"marked-toc" : "latest",
"mocha" : "latest",
"should" : "latest"
"browserify": "latest",
"uglify-js": "latest",
"coffee-coverage": "latest",
"docco": "latest",
"highlight.js": "latest",
"marked-toc": "latest",
"mocha": "latest",
"should": "latest"
},
"main": "lib/swagger-dsl.js",
"scripts": {
"test":"./node_modules/.bin/mocha -t 2000 -R list --compilers coffee:coffee-script/register ./test/test-swagger-dsl.coffee"
"test": "./node_modules/.bin/mocha -t 2000 -R list --compilers coffee:coffee-script/register ./test/test-swagger-dsl.coffee"
},
"bin": {
"swagger-dsl": "./bin/swagger-dsl"
},
"engines": { "node": ">=0.10" }
"engines": {
"node": ">=0.10"
}
}