mrin9 / RapiPdf

PDF generation from OpenAPI / Swagger Spec
https://mrin9.github.io/RapiPdf
MIT License
282 stars 102 forks source link

Enable examples flag #68

Closed DaManDOH closed 4 years ago

DaManDOH commented 4 years ago

Issue #6 β€” Added logic to include OpenAPI examples in generated PDF.

mrin9 commented 4 years ago

Thanks for the PR, and its nice that you update the API documentation and put up an example to show its working !!!

There are couple of issues with it

here is how it looks

Screen Shot 2020-07-26 at 10 34 31 AM

But having said that, I think we can start small and improve upon it later.

I will accept the PR now (will put a note in API docs that only json examples are supported). we will add indentation to it later

DaManDOH commented 4 years ago

Thanks for the PR, and its nice that you update the API documentation and put up an example to show its working !!!

Thanks! Lacking documentation is always a problem.

There are couple of issues with it

  • It assumes that examples will be always in JSON

The JSON stringifier should treat any other language as a basic JSON string, but I will admit I did not test anything beyond JSON and basic strings.

  • It wont auto-generate the examples

As the request and response example(s) properties are static fields in OpenAPI's specification, shouldn't the population of those fields be the responsibility of the OpenAPI documentation generator? In other words: shouldn't the subject API's JSON/YAML file already have the generated examples before it's passed to RapiPdf?

  • It wont indent the JSON

Yea, CSS is not my strong suit. πŸ˜…

gmmarc commented 3 years ago

@mrin9 this PR works great, but it's not included in the latest release v2.2.1. Thus, you need to build from source code to benefit from this PR (installing with yarn won't work).

It would be great if you could deploy a new release with the latest updates πŸ‘

Also sharing in case someone runs into the same issueβ€”It took me more time than I want to admit to figure it out πŸ˜