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

Consider not generating empty input/output structs (e.g. paths, query, etc) #229

Closed
czechboy0 opened this issue Aug 30, 2023 · 0 comments · Fixed by #235
Closed

Consider not generating empty input/output structs (e.g. paths, query, etc) #229

czechboy0 opened this issue Aug 30, 2023 · 0 comments · Fixed by #235
Labels
area/generator Affects: plugin, CLI, config file. kind/enhancement Improvements to existing feature.
Milestone

Comments

@czechboy0
Copy link
Contributor

czechboy0 commented Aug 30, 2023

Consider not generating empty input/output structs (e.g. paths, query, etc).

Today, we generate them all, even when they're empty.

To try to see impact of not doing so on real-world docs, I prototyped a version of the generator that skips those empty structs on my fork (diff).

The result: it removes about 10% of the code of GitHub's OpenAPI document, about 50k LOC.

Saving lines of code is a nice benefit, but I actually find that the code is more readable as well, and code completion guides you better (as you can see which containers have some parameters, whereas today you can't).

Opening this issue to start the discussion, happy to take this through a proposal if there are varying views.

@czechboy0 czechboy0 added area/generator Affects: plugin, CLI, config file. status/needs-design Needs further discussion and a concrete proposal. kind/enhancement Improvements to existing feature. labels Aug 30, 2023
@czechboy0 czechboy0 added this to the 0.2.0 milestone Aug 30, 2023
@czechboy0 czechboy0 removed the status/needs-design Needs further discussion and a concrete proposal. label Aug 30, 2023
czechboy0 added a commit that referenced this issue Aug 31, 2023
Stop generating empty input/output structs (query, headers, ...)

### Motivation

Fixes #229.

### Modifications

Stops generating the structs and properties when they're empty.

### Result

About 10% reduction in generated code, more clear generated code.

### Test Plan

Adapted tests, check those out first to see how the generated code is changing.


Reviewed by: glbrntt

Builds:
     ✔︎ pull request validation (5.8) - Build finished. 
     ✔︎ pull request validation (5.9) - Build finished. 
     ✔︎ pull request validation (docc test) - Build finished. 
     ✔︎ pull request validation (nightly) - Build finished. 
     ✔︎ pull request validation (soundness) - Build finished. 
     ✖︎ pull request validation (integration test) - Build finished. 

#235
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/enhancement Improvements to existing feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant