0.2.8 • Published 4 years ago

@direwolf2494/apidoc-swagger v0.2.8

Weekly downloads
6
License
MIT
Repository
github
Last release
4 years ago

apidoc-swagger

Build status: CircleCI

apidoc and swagger are two nice projects which are focusing on documentation of APIs. This project is a middle tier which tries to bring them together in a sense that:

It uses apidoc to convert inline documentation comments into json schema and later convert it to swagger json schema.

Uses the apidoc-core library.

How It Works

By putting in line comments in the source code like this in javascript, you will get swagger.json file which can be served to swagger-ui to generate html overview of documentation.

/api/foo.js:

/**
 * @api {get} /user/id Request User information
 * @apiName GetUser
 * @apiGroup User
 *
 * @apiParam {Number} id Users unique ID.
 *
 * @apiSuccess {String} firstname Firstname of the User.
 * @apiSuccess {String} lastname  Lastname of the User.
 */

Installation

npm install apidoc-swagger -g

Current version unlocks most of the basic capabilities of both projects and improvement is in progress.

Example

apidoc-swagger -i example/ -o doc/

Options

The following options can be used to customize the behavior of apidoc-swagger:

Long NameAbbreviationDefaultDescription
--input-iREQUIREDInput / source dirname.
--file-filters-f.*\\.(clj|coffee|cs|dart|erl|go|java|scala|js|php?|py|rb|ts|pm)$RegEx-Filter to select files that should be parsed.
--exclude-filters-eRegEx-Filter to select files / dirs that should not be parsed.
--output-o./doc/Output dirname.
--verbose-vfalseVebose debug output.
--help-hShows help information
--debugfalseShow debug message
--colortrueTurn off log color
--hosttarget host to use instead of url in package.json/apidoc.json
--default-responsefalseuses default success responses instead of api doc generated responses
--base-path/basepath for the api
--schemeshttpcomma separated list of url schemes
--parsefalseParse only the files and return the data, no file creation.
--parse-filtersOptional user defined filters. Format name=filename.
--parse-languagesOptional user defined languages. Format name=filename.
--parse-parsersOptional user defined parsers. Format name=filename
--parse-workersOptional user defined workers. Format name=filename
--silentfalseTurn all output off
--simulatefalseExecute but don't create output file
--markdownfalseTurn on markdown parser
--marked-configEnable custom markdown parser configs. It will overwite all other marked settings.
--marked-gfmfalseEnable GitHub flavored markdown.
--marked-tablesfalseEnable GFM tables. This option requires the gfm option to be true.
--marked-breaksfalseEnable GFM line breaks. This option requires the gfm option to be true.
--marked-pedanticfalseConform to obscure parts of markdown.pl as much as possible.
--marked-sanitizefalseSanitize the output. Ignore any HTML that has been input.
--marked-smartListsfalseUse smarter list behavior than the original markdown.
--marked-smartypantsfalseUse 'smart' typograhic punctuation for things like quotes and dashes.

Have a look at apidoc for full functionality overview and capabilities of apidoc.

To read more about how swagger works refer to swagger-ui and swagger-spec for details of swagger.json.

Gulp Module

gulp-apidoc-swagger npm install gulp-apidoc-swagger.