docusaurus-openapi-docs icon indicating copy to clipboard operation
docusaurus-openapi-docs copied to clipboard

[FR] Ability to customize code snippets and responses.

Open sradu opened this issue 3 years ago • 4 comments

Is your feature request related to a problem?

Would be great to have the code snippets similar to stoplight. I'm also not seeing the 'Response' but perhaps that's a separate bug.

Describe the solution you'd like

I've attached some images.

Screen Shot 2022-07-21 at 10 05 44 PM Screen Shot 2022-07-21 at 10 05 49 PM

Describe alternatives you've considered

I'm trying to figure out how to theme it so it looks more similar to the screenshots. Haven't found a library that generates the client code yet.

sradu avatar Jul 21 '22 19:07 sradu

Hi @sradu, thanks for the FR! We use a forked postman-code-generators under the hood and do have the ability to support other languages. That said, we're being careful about how we introduce language support in order to control the overall webpack bundle size, i.e. keep it from inflating so much it impacts performance. Unfortunately, postman-code-generators doesn't really lend itself to tree shaking or optimization in this way - it's kind of "all or nothing" in that regard.

It's on our roadmap to look deeper into how to support other languages but, from experience, we also believe it's more important to provide coverage for the languages actually in use by the developer audience you're looking to reach/support. That said, our next move might be to allow users to define which languages they want to support in the plugin config.

As for response examples, we have an issue opened for that: #119

sserrata avatar Jul 21 '22 21:07 sserrata

Thanks Steven! I fully agree that having 4-5 snippets would be OK. For instance Curl, Ruby, Python, PHP, Javascript, Node, Go, .NET. Stripe has a similar way of doing it, a dropdown with a cookie to remember the choice.

Screen Shot 2022-07-22 at 1 56 40 PM

Dropdown seems a more common approach then tabs + logos. Not having those logos would also decrease the bundle size.

sradu avatar Jul 22 '22 10:07 sradu

I agree that, it we're to support >4 languages, a dropdown seems like a better UI/UX choice. I should mention that we are trying, whenever possible, to stick to the Infima CSS framework that Docusaurus is based on, in order to maintain UI/UX consistency while allowing the user to customize the styles in a consistent way with the rest of the Docusaurus site. That said, there's still room to introduce new, custom components not already included in Infima.

sserrata avatar Jul 22 '22 13:07 sserrata

Found an interesting project that could be a better/lighter-weight alternative: https://github.com/Kong/httpsnippet

It is based on the HAR format but it should be fairly easy to integrate with. One major pro is that we could potentially drop all the postman dependencies, including the step where we convert the OpenAPI object to a postman collection. This could potentially save both CPU cycles (time) and lighten the webpack bundle size.

sserrata avatar Jul 25 '22 17:07 sserrata