-
Notifications
You must be signed in to change notification settings - Fork 148
apiSchema - Build api doc blocks from schema #26
Conversation
… parsed (ie xml) add in $ref merging for jsonschema
Nice! I think i add a better plugin integration, so that your module (and others), can be used easy, without inflate the core. And the modules itself can be maintaned by the creators (due the lack of my time, it would be a better solution for all) and each module has its own dependencies. Can you provide your plugin via npm e.g. as Then a user can install
I will add then an automatic load of plugins, whose name start with "apidoc-plugin-". What did you think? |
I like the idea of using plugins. Since this plugin hook will be schema based maybe use |
I think we need a simple hook system (array). in
So all your schema specific variables and functions (to load the schema) can be in your plugin.
|
Yeah, autoloading into the index would work more cleanly than requiring on the fly. I'm not sure how we can do it that cleanly with the need for recursion and the ability to pre-parse the plugin-schema line. Or are you thinking about putting the schema parse inside the plugin as well? Maybe something like this. with @apiSchema in core // schema autoloaded in index.js
if (self.schema[element.name]) {
var elementParser = self.parsers[element.name];
var values = elementParser.parse(element.content, element.source);
if (self.schemas[values.schema]) {
var blockExtend = self.schemas[values.schema](values, filename);
elements = elements.concat(self._findElements(blockExtend, filename));
}
} else {
elements.push(element);
} with @apiSchema in plugin // schema autoloaded in index.js
if (self.plugin[element.name]) {
var blockExtend = self.plugin[element.name](element, filename);
elements = elements.concat(self._findElements(blockExtend, filename));
} else {
elements.push(element);
} with this approach the autoloader would need to be recursive to allow a plugin to load sub plugins. ie You're thinking the later approach I'm guessing. |
Refactor complete. The autoloading will likely need some love, little hacky right now. |
Close this for #27 I will change the hook load a little bit to make it more universal and not specific to a plugin name (WordPress Hook Style). |
Introducing a new concept for building out apidocs using schemas jsonschema (included), xml, etc. These schemas can have apiParams and apiSuccess auto generated. This will reduce errors and keep docs up to date.
Syntax:
@apiSchema {SCHEMA_TYPE=PATH_TO_SCHEMA_FILE} [LINE_ARGS_OPTIONAL]
Example
apidoc/apidoc#402