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

Fix warning in generated server when no operations are included in the OpenAPI doc #190

Closed
czechboy0 opened this issue Aug 11, 2023 · 2 comments · Fixed by #209
Closed
Assignees
Labels
area/generator Affects: plugin, CLI, config file. kind/bug Feature doesn't work as expected. size/S Small task. (A couple of hours of work.)

Comments

@czechboy0
Copy link
Contributor

It's legal to have no operations in the OpenAPI doc, e.g. just have schemas.

Today, when someone generates a serve with such a doc, they'll get a warning because the variable server isn't used in the generated registerHandlers method.

Let's fix it by only generating this initializer if there's at least one operation. Otherwise keep the method empty.

@czechboy0 czechboy0 added area/generator Affects: plugin, CLI, config file. kind/bug Feature doesn't work as expected. size/S Small task. (A couple of hours of work.) labels Aug 11, 2023
@arthurcro
Copy link
Contributor

Hey there!
I would be happy to take a look at fixing this! 😊

@czechboy0
Copy link
Contributor Author

Sounds good, @arthurcro, let us know if you need any help!

czechboy0 added a commit that referenced this issue Aug 17, 2023
### Motivation

Fixes #190.
 
### Modifications

We fix the issue buy only generating this initializer if there's at
least one operation. Otherwise keep the method empty.

### Result

The warning is fixed since the `server` variable declaration is not
added to the `registerHandlers` body when it's not used.

### Test Plan

We add a test in `SnippetBasedReferenceTests.swift` called
`testServerRegisterHandlers_noOperations` asserting the `server`
variable delcaration is not added to the `registerHandlers` body.

---------

Co-authored-by: Honza Dvorsky <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/generator Affects: plugin, CLI, config file. kind/bug Feature doesn't work as expected. size/S Small task. (A couple of hours of work.)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants