-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Specs] More advanced API specification format #15
Comments
That's not a bad idea! Although the test suite should cover the API surface pretty well, more validation won't hurt. I do see a practical issue though: there are a fair number of API methods that allow more inputs than what is documented for backwards compatibility reasons. I'm not sure how many exactly but I imagine you could end up with a fuzzer that's a big pile of special cases. |
http://mongodb.github.io/node-mongodb-native/api-generated/collection.html#find
|
@Mickael-van-der-Beek - I like it. Another potential use case that a lot of people on the node group really wanted was an alphabetical API reference like Angular, et al, rather than just the man-page style. Last time I checked, the json docs didn't have quite enough consistency to build an API reference automatically. |
…specialisation if applied to node-forward/discussions#15.
@darrenderidder - Thanks! An alphabetical spec would definitely be a cool improvement! Currently the JSON and HTML API specs are generated with a non-NPM-published module called I feel that although it's very convenient, I'd prefer to do it the other way around. Here is an example of the schema syntax I have in mind:
The The I have already written and tested (86% coverage) a spec It supports type and format validation like above but also various options that can be configured at the module level or spec level:
If you want more details about the spec format for nested The Mickael-van-der-Beek/node-cerberus/src/fuzzer/payloads What do you guys think ? PS: One case I'm currently not handling in my validation spec format is linked parameters. e.g:
where One possible solution for this:
Which means that a The It's a bit of a hack so I'm definitely open other ideas ! |
A few months ago I discovered that Node.js had a JSON version of it's API documentation.
e.g:
http://nodejs.org/api/crypto.json
The format itself is decent but I think that it could go even further.
I feel like if the
params
field would be reworked, using the JSON API docs and their different versions as data source for various modules would be really easy.Some use cases I had in mind:
nodejs/node-v0.x-archive#8249
nodejs/node-v0.x-archive#8390
I imagine that a whole range of other possibilities would be opened by implementing this feature and improving the specs.
The following format could be one way of expressing a parameter spec:
Where
notEmpty
andisPath
are validator functions that could possibly be added to theutils
core module.I don't think the change itself would be huge nor time consuming after the initial coverage of the current API's.
Since this doesn't involve writing C/C++ code, I'd be willing to work actively on this feature !
Obviously, this could be done by an exterior NPM module but in my opinion a feature like a detailed spec / spec validation should be centralized in the core repository.
What do you guys think ?
The text was updated successfully, but these errors were encountered: