Skip to content

salman-mustafa1230/apidoc-plugin-example

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

apidoc-plugin-example

Generates and inject apidoc example elements from api schemas or files.

@apiExample {SCHEMA_TYPE=PATH_TO_SCHEMA} ELEMENT_TYPE TITLE

Install

npm install apidoc-plugin-example --save-dev

Supported Schema Types

json

Prettifies JSON and injects in.

Uses json-schema-faker to generate a sample response.

Example Use

/**
 * @api {get} /api GetAPI
 * @apiExample {json=./ex/api.req.json} apiParamExample Request
 * @apiExample {jsonschema=./ex/api.res.json} apiSuccessExample Response JSON
 * @apiExample {xml=./ex/api.res.xml} apiSuccessExample Response XML
 */

Example Use with base path in apidoc.js

apidoc.json
{
  sampleJsonSchemaPath: "./schema/";
}
comment:
/**
 * @api {get} /api GetAPI
 * @apiExample {json=api.req.json} apiParamExample Request
 * @apiExample {jsonschema=api.res.json} apiSuccessExample Response JSON
 * @apiExample {xml=api.res.xml} apiSuccessExample Response XML
 */

Developer Note

This plugin uses parser-find-elements @ priority 201.

TODO

  • Add in wsdl schema / XSD

Packages

No packages published

Languages

  • JavaScript 100.0%