bootprint / bootprint-openapi

Bootprint-module to render OpenAPI specifications, this repository has moved to https://github.com/bootprint/bootprint-monorepo/tree/master/packages/bootprint-openapi
MIT License
357 stars 48 forks source link

More Templates for HTML, PDF possible? #1

Closed aviadavi closed 9 years ago

aviadavi commented 9 years ago

Hi.

Do you have more handlebars templates for bootprint swagger (there is only 1 correct me if i'm wrong) ?

Is generating PDF possible ?

nknapp commented 9 years ago

At the moment, there is only this one template for swagger. Although I consider it usable at the moment (we used it to provide documentation to our customers) it can certainly be improved. So if you have any improvements, feel free to create an issue with more detailed ideas or a PR. I'm going to add a section about "contributing" to the documentation soon.

PDF generation is a bit tricky and it is a more general question of converting HTML to PDF. I've tried the following:

1) PhantomJS with the rasterize script - Works at the first glance, but it does not add PDF bookmarks and the links within the document are not working 2) WeasyPrint - Looks good and generates PDF-bookmarks. PDF-generation takes a bit longer. Links within the document are not working. 3) wkhtmltopdf - Takes really long to generate PDF. The resulting file is huge (2,3 MB for the petstore-example). Links and PDF-bookmarks are working fine. 4) PrinceXML - Runs very quickly, small PDF, links are working, layout looks good. It's a great tool, but I can't justify $3800 just for sending a nice Rest-API-Reference as PDF instead of HTML. I would use it for open source projects though (for which it is free).

Since every option had a large drawback (links not working, file size, price), we just sent a zip-file containing the HTML- and the StyleSheets. It's not what I had intended to do with Bootprint in the beginning, but at the moment I do not see another option.

So, PDF-generation is possible, but it's not built in (yet).

aviadavi commented 9 years ago

The idea is that the HTML will contain the following: 1) Default Values 2) Min/Max Value 3) Pattern 4) Examples

nknapp commented 9 years ago

Most of these values belong into the bootprint-json-schema module. I would like to encourage you to clone the repository, make your changes and submit a pull request. If you need a starting point. From what I can see, default values, min/max and pattern belong into the json-schema/datatype partial, which already renders the "format" and "enum"-values.

"Examples" in the json-schema parts of the swagger-spec would also go into bootprint-json-schema and there into the partial json-schema/body probably below the description. Pretty printed JSON can be rendered with the {{json value}}-helper.

"Examples" in the swagger-parts of the spec only seem to be possible within response definitions, which would go into the partials of this ("bootprint-swagger") module, namely swagger/responses.

Also, check out the development-setup when changing partials.

I may find some time to add these values myself, but a pull-request would probably be accepted faster than that.

I am currently working on documentation for the template-modules. Or better, I am trying to figure out a good way to write part of the document as inline comments within partials, less-files and js-files.

JamesPaden commented 9 years ago

@nknapp late to the party, but you might consider https://docraptor.com for HTML to PDF. It uses PrinceXML on the backend, but has a saas-based pricing model.

nknapp commented 9 years ago

@aviadavi can you provide a simple (possibly minimal) example containing the data you'd like to see in the output? That would be a great help.

nknapp commented 9 years ago

@JamesPaden I don't think a SaaS is the right alternative for my purposes, but it might be for others, thanks for the hint.

nknapp commented 9 years ago

I've included "default-values" and examples in the JSON-Schema into the current version.

nknapp commented 9 years ago

I've extracted the two remaining TODOs into separate issues. This issue will now be closed