outmoded / lout Goto Github PK
View Code? Open in Web Editor NEWAPI documentation generator
License: Other
API documentation generator
License: Other
this might be an issue relative path at:
https://github.com/hapijs/lout/blob/master/templates/index.html#L7
Just wondering if one could provide a link or write an example way to hook this up with hapi.
Something changed in one of the Hapi dependencies (Vision I think) that is breaking the build now.
Also Joi 4.x.x as captured in #57
Lout's package still requires an old version of Hapi and a conflicting (with new Hapi) version of node.
Error at Line 144 function internals.getParamsData
param.children is null if data type is object and have no children.
var childrenKeys = Object.keys(param.children);
so it's should be
if(param.children) {
....
}
If the hapi server object is configured passing a value of true or 'required' to server.auth.strategy, then it is not possible to configure lout to not require authentication - the documentation pages do not display correctly.
This is because when lout registers it's 2 routes, it does not pass the auth setting to the css route.
This plugin fails to load do to a missing handlebars dependency when installing from npm. Handlebars is listed only as a dev dependency.
I'm noticing that the allowedValues
that are available to the template in the different route params seem to just contain an array of 1 item that appears to be a stringified Array of the allowed values.
My question is, is this intended behavior?
For example, if I have config for a route that looks like this:
{
path: '/foo/{id}',
method: 'POST',
config: {
handler: function(request, reply) { reply({some:'data'}); },
validate: {
payload: {
id: Hapi.types.String().allow(['one','two','three']).required()
}
}
}
}
Then the allowedValues
property of payloadParams
on the route object in the template returns this value:
["[ \"one\", \"two\", \"three\" ]"]
instead of:
['one','two','three']
So ultimately, I can't easily loop through each value.
If this was not intentional, I can submit a fix. Thanks!
We'd be interested in using lout to generate our docs, but don't want an additional dynamic route enabled.
By using request.server.table()
you get each connection, but if you use server.table()
, you only get the connections that have been specified in select
(specifically when using glue
).
@Marsup, you haven't updated version
in package.json
since seven commits ago, since which you made breaking changes on master
. npm depends on semantic versioning. Please npm version major
with all due haste.
Just wondering why joi is a peerDep currently. It seems to better fit the dependency pattern.
Our implementation use a custom authentication plugin. Our server.pack method looks something like this currently:
server.pack.require
"hapi-auth-custom": hapiAuthCustomOpts
"lout": loutOps,
(err) ->
server.auth.strategy "custom", "custom", validateUser
# ... routes, etc...
If I set the auth option for lout {auth: "custom"}, it complains:
Error: Unknown authentication strategy: custom
What am I doing wrong :)
version
"lout" : "^6.0.1"
config
server.route({
method: 'POST', path: '/test',
config: {
validate : {
payload: {
page : Joi.number().min(1).max(99999).required()
}
},
handler: function(req, resp) {
resp('test');
}
}
});
result in /docs
page
Type
number
Forbidden Values
Infinity
-Infinity
No mentioning of .min(1).max(99999)
and Lout completely dies. Need a way to identify errors and continue showing documentation
Alternatives are now described as objects.
Date.min/max can now take references.
I know that I can disable a specific route but I'd would be nice if I could tell lout to ignore a certain method entirely.
The reason for me is that we use "*" to handle all the 400 properly but obviously I don't want them to show up in the docs.
What do you guys think?
Lout by default shows "Type any" for Path, Query and Payload parameters by default, but Hapi doesn't accept a payload for a GET request. Is it possible to remove this? I tried:
validate: {
payload: false
}
On a route, but Hapi will return a "Cannot Validate" error since it's a GET. If there's nothing I can do config wise to fix this, should I submit a PR to disable the section from being generated for GETs by default?
I think it would be handy if we had a way disable this from being generated for POST, and other methods as well...
-a code
to makefileWe are looking for someone to take over the project and maintain it moving forward. Our team isn't currently using this which makes it hard to support.
Not yet in hapi (coming in 5.0) but should start looking at the changes in how describe work and all the new features.
Handlebars is now stable in its 2.x version.
Follow-up of the #40 digressions.
Is there any way to style the output of the route description, for instance using a custom markup language? Displaying inline JSON is ugly and will be unreadable for big objects:
My use case is pretty simple: I want to display the route description (using text) and a sample return value, which I'd like to embed in a <pre>
tag. At the moment all HTML tags are escaped, am I missing something?
I am loving using lout with Hapi 6.x but I need to exclude some routes from the index.
How do I do that?
I tried this route to exclude for example with a plugins: lout:false
{
method: 'GET',
path: '/{path*}',
handler: {
directory: { path: './public', listing: false, index: true }
},
plugins: {
lout: false
}
}
but it complains with
Error: Invalid route options (/{path*}) {
"method": "GET",
"path": "/{path*}",
"handler": {
"directory": {
"path": "./public",
"listing": false,
"index": true
}
},
"plugins" [1]: {
"lout": false
}
}
What do I need to do to exclude a route?
It would be useful to show what the API docs look like with a live demo or even just screenshots.
Hi guys,
I am new to hapi and lout. So it can well be that I did something wrong.
Having these packages:
"hapi": "^4.1.4",
"hoek": "^2.1.0",
"joi": "^4.2.0",
"lout": "^3.1.2"
and the following server code:
var Hapi = require('hapi');
var server = Hapi.createServer('0.0.0.0', parseInt(process.env.PORT, 10) || 3000);
server.route({
method: 'GET',
path: '/hello',
handler: function(req, reply) {
reply('i am a beautiful butterfly');
}
});
server.pack.require('lout', function() {
server.start(function () {
console.log('Server started at: ' + server.info.uri);
});
});
I get:
Server started at: http://0.0.0.0:3000
Debug: hapi, internal, implementation, error
TypeError: Cannot read property 'key' of undefined
at Object.exports.process (/Users/aboehrnsen/Developer/code-wemo/songbox/node_modules/hapi/node_modules/joi/lib/errors.js:54:81)
at internals.Any.validate (/Users/aboehrnsen/Developer/code-wemo/songbox/node_modules/hapi/node_modules/joi/lib/any.js:527:19)
at internals.Any.validateCallback (/Users/aboehrnsen/Developer/code-wemo/songbox/node_modules/hapi/node_modules/joi/lib/any.js:533:20)
at Object.internals.input (/Users/aboehrnsen/Developer/code-wemo/songbox/node_modules/hapi/lib/validation.js:101:19)
at exports.query (/Users/aboehrnsen/Developer/code-wemo/songbox/node_modules/hapi/lib/validation.js:17:22)
at /Users/aboehrnsen/Developer/code-wemo/songbox/node_modules/hapi/lib/request.js:314:13
at iterate (/Users/aboehrnsen/Developer/code-wemo/songbox/node_modules/hapi/node_modules/async/lib/async.js:149:13)
at /Users/aboehrnsen/Developer/code-wemo/songbox/node_modules/hapi/node_modules/async/lib/async.js:160:25
at /Users/aboehrnsen/Developer/code-wemo/songbox/node_modules/hapi/node_modules/hoek/lib/index.js:467:22
at process._tickDomainCallback (node.js:459:13)
Any ideas?
Instead of setting own basePath to custom templates it would be great to just point to own CSS files, as this is probably the most common reason for customisation.
Quick review shows that moving plugin.loader()
, requiring handlebars directly, and moving to absolute path to the templates directory will allow it to be backwards compatible change.
Configuring lout with an endpoint of /
causes the following exception:
/code/node_modules/hapi/node_modules/hoek/lib/index.js:394
throw new Error(msgs.join(' ') || 'Unknown error');
^
Error: Invalid path: //css/{path*}
at Object.exports.assert (/code/node_modules/hapi/node_modules/hoek/lib/index.js:394:11)
at new module.exports.internals.Route (/code/node_modules/hapi/lib/route.js:27:11)
at /code/node_modules/hapi/lib/router.js:110:25
at Array.forEach (native)
at /code/node_modules/hapi/lib/router.js:107:17
at Array.forEach (native)
at internals.Router.add (/code/node_modules/hapi/lib/router.js:104:13)
at internals.Server._route (/code/node_modules/hapi/lib/server.js:425:18)
at internals.Pack._applySync (/code/node_modules/hapi/lib/pack.js:593:14)
at Object.methods.route (/code/node_modules/hapi/lib/pack.js:198:22)
Lout will crash when it encounters a param which is of type array
and has a rule which describes the max number of items.
Below is an example param which would cause lout to crash.
{ type: 'array',
flags: { insensitive: false, allowOnly: false },
description: 'Some Attribute',
valids: [ undefined ],
invalids: [ null ],
rules: [ { name: 'max', arg: 5 } ] }
The crash is caused by the following lines starting at 196 of lib/index.js
param.rules.forEach(function (rule) {
data.rules[rule.name] = rule.arg.map(function (type) {
return internals.getParamsData(type.describe());
});
});
Does this exist?
Currently generated documentation for routes includes auth strategy, but not scope. For our use cause being able to document scope for other developers would be extremely helpful. With the way we implement scope, this would essentially would tell them which methods they have permissions to use (we plan on having quite a few different scopes with varying access to routes).
I can do a fork, but I thought I would ask first before sending you a pull request - maybe there is a reason you don't want scope exposed?
I just tried lout quickly with my current server under the latest hapi with a defaultMode for authentication. Unsurprisingly, I got a "missing authentication" error. Maybe an option can be added to specify the authentication mode on the documentation route?
Solution is to provide an own helpers folder in custom basePath. This should be documented.
Hi...
README.md indicates 'basePath' is available (to change the template directory)....but couldn't see this implemented. (Perhaps I've missed something.)
I needed to add:
var internals = {
defaults: {
basePath: './templates'
}
}
and reference this in register:
plugin.views({ engines: { html: 'handlebars' }, path: settings.basePath });
Instead of this:
plugin.views({ engines: { html: 'handlebars' }, path: './templates' });
thanks
#57 is still missing hapijs/joi#383, support it when released.
If an endpoint has a payload validation schema then we can generate a sample request payload to display (Instead of adding mock data, it could be { "item": "string", "item2": 100 }
If the endpoint also has response validation then we can also provide a sample response body.
Currently, in the outputted documentation, the parameter type is blank.
Adapt to hapijs/hapi#2262.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.