Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenAPI generator #42

Closed
System-Glitch opened this issue Mar 6, 2020 · 8 comments
Closed

OpenAPI generator #42

System-Glitch opened this issue Mar 6, 2020 · 8 comments
Assignees
Labels
feature request Request for new feature implementation

Comments

@System-Glitch
Copy link
Member

Proposal

Develop a module able to generate OpenAPI specification for Goyave applications by reading the main route registrer and validation rule sets.

This feature could be included in the CLI Utility ( #39 )

Possible drawbacks

None.

Additional information

This issue is a feature proposal and is meant to be discussed.
It is also a good candidate if you want to contribute to the project.
This should probably be developed as a side-project.

@System-Glitch System-Glitch added good first issue Good for newcomers feature request Request for new feature implementation labels Mar 6, 2020
@System-Glitch
Copy link
Member Author

System-Glitch commented Aug 25, 2020

I had a few ideas to make this feature:

  • Make it build-in (it would be implemented in a new openapi.go file at the root of the project, to be able to access unexported fields)
  • A lot of information can be retrieved simply by reading the route definition and its validation rules.
  • The route description can be retrieved using handler comments and godoc.
  • The hardest part is not mandatory: getting information about the responses.
  • Adding an optional (nullable) struct to the Route struct, containing OpenAPI information that can be added manually, such as potential responses, examples, etc.
  • OR adding this information in the handler's comments (using annotation-like syntax like Beego does for example)
    • The go/ast package could be used for comment extraction
  • For ease of use, it could be integrated into the CLI utility that is being developed.

@njr8392
Copy link

njr8392 commented Oct 22, 2020

I'd love to help you with this if you have't already started.

@System-Glitch
Copy link
Member Author

System-Glitch commented Oct 22, 2020

Hello @njr8392 ! Thank you very much for your help ! I haven't started this feature yet. Don't hesitate to contact me (via email, telegram or discord) if you have any question or if you need guidance.

@njr8392
Copy link

njr8392 commented Oct 22, 2020 via email

@System-Glitch
Copy link
Member Author

  • If possible, that would make more sense to me if this was a separate project. I don't want applications in production to waste memory usage holding information needed for the OpenAPI spec generation. Ideally, this is something that we could use in the future CLI app. If it is not possible to get the data you need from outside, we can add an accessor to the Router struct which will copy the route slice.
  • Routes should always be defined in a http/route/route.go file so use this as default, but make it so it is possible to optionally give a path to the file.
  • Prefer the go/ast package over godoc. Using godoc would be quite hacky.
  • I would like to get as much information as possible automatically, but I also want the developer to be able to override and/or complete it. I think Beego's approach with annotations is quite neat. You can take inspiration from it.
  • The goal is to turn a Router struct into an OpenAPI specification.

@njr8392
Copy link

njr8392 commented Oct 22, 2020 via email

@System-Glitch
Copy link
Member Author

After some reasearch, it looks like kin-openapi is the most fitting library we could use.

@System-Glitch System-Glitch self-assigned this Mar 18, 2021
@System-Glitch System-Glitch removed the good first issue Good for newcomers label Mar 29, 2021
@System-Glitch System-Glitch mentioned this issue Apr 28, 2021
@System-Glitch
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Request for new feature implementation
Projects
None yet
Development

No branches or pull requests

2 participants