ErikWittern / openapi-snippet

Generates code snippets for given Swagger / Open API documents
MIT License
115 stars 66 forks source link

Unify library API #64

Open ErikWittern opened 3 years ago

ErikWittern commented 3 years ago

This library currently has two methods getSnippets and getEndpointSnippets, the latter of which depends on 4 arguments which must be provided in the right order. Adding additional arguments (e.g., as suggested in #62) would decrease usability, arguably.

I think that generally, the API of this library might be improved to become:

OpenAPISnippet.getSnippets(openApi, options) 

..., where options may contain things like targets and path + method to select which operation to generate snippets for (instead of having a separate method getEndpointSnippets). This refactor would make it more feasible to add further options. E.g., w.r.t. #62 it could also contain a new serverIndex option to denote which server to use.

Any thoughts?