twskj / pretty-swag

Pretty UI for Swagger spec
MIT License
122 stars 20 forks source link

Supporting to embeding pretty-swag within html #42

Closed sundriver closed 7 years ago

sundriver commented 7 years ago

Hi @twskj

The produced html includes css, html header, html body tag, js, etc.

Would be nice if one could turn off these outputs essentially producing plain static html.

Then one can simple include the output into a div locally and style it as required.

I appreciate your advice,

Ali

twskj commented 7 years ago

Thanks for pointing this out. Currently, pretty-swag does not generated div format yet. Its content get "hydrated" at run time by javascript.

This sounds like the same issue as #26. I am still looking for a solution. Solutions I am looking at are:

  1. Chrome headless rendering.
  2. Simple server-side template on node like ejs

Each has pros/cons but I am leaning toward the second choice because it has less restrictions but a big chunk of work has to put on developing a new template.

If you have other ideas, feel free to discuss here. Also pull request is always welcome if you have time to solve this before me 👍

Cheers

sundriver commented 7 years ago

to make sure I understand the process correctly. pretty-swag converts swagger doc into an intermediate format livedoc is what generates the html, so to get output I am after I need to:

  1. introduce new option in pretty-swag
  2. intercept the option in livedoc and generate the output.

Any advice ?

Ali

twskj commented 7 years ago

yup you got it right. You can also intercept raw parsing data and not use livedoc at all. The parsing result is in json format. Take that json and loop over data to generate html however you like.

sundriver commented 7 years ago

Thanks @twskj