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

Improve OpenAPI generator #90

Merged
merged 15 commits into from
Dec 18, 2022
Merged

Improve OpenAPI generator #90

merged 15 commits into from
Dec 18, 2022

Conversation

sdboyer
Copy link
Contributor

@sdboyer sdboyer commented Dec 15, 2022

Refactor codegen to no longer rely on eval and printing, taking
advantage of the ability to pass a cue.Value to the CUE standard library
package.

Also introduce support for a group flag, which allows translating only the
children of the root schema to OpenAPI.

And introduce a long-overdue test txtar-based test framework.

cc @IfSentient

sam boyer added 2 commits December 15, 2022 16:33
Refactor codegen to no longer rely on eval and printing, taking
advantage of the ability to pass a cue.Value to the CUE standard library
package.

Also introduce support for a group flag, which allows translating only the
children of the root schema to OpenAPI.

And introduce a long-overdue test txtar-based test framework.
@sdboyer
Copy link
Contributor Author

sdboyer commented Dec 16, 2022

cc @undef1nd - fyi, this testing system should be equally useful for what you've been looking at with JSON Schema generation

@sdboyer sdboyer self-assigned this Dec 16, 2022
@sdboyer sdboyer added enhancement New feature or request breaking change Breaks existing code labels Dec 16, 2022
@sdboyer
Copy link
Contributor Author

sdboyer commented Dec 17, 2022

This testing system is 🔥 . It can treat the exemplar set as a corpus for tests using only a single flag. Add a new exemplar to the corpus, and it instantly flows to all tests using the framework.

@sdboyer
Copy link
Contributor Author

sdboyer commented Dec 17, 2022

I've also added a cfg.Subpath, which allows forcing the generator to gen just one subpath within the provided schema, rather than the whole thing.

This is mostly ready to go. The nasty bug with extra files being appended to txtar when golden updates are on remains, and i also have to figure out why some Go types aren't rendering in grok.

Once those are licked, though, this is ready to merge.

@sdboyer sdboyer merged commit 392072f into main Dec 18, 2022
@sdboyer
Copy link
Contributor Author

sdboyer commented Dec 18, 2022

This is in good shape. But there are some follow-ups.

I had to fork CUE for some fixes - there were a couple key cases that weren't covered (conjuncts in numeric value types, selectors on object types). This substantially impacted Go codegen elsewhere, being the difference between obviously incorrect and probably correct.

The test framework itself is also in a messy, halfway state. In retrospect, i realize what i was really trying to do was graft a subtest layer on top of the txtar-specific test runner. The framework itself already creates a subtest per txtar, but i was effectively trying to make each provided subtest executed from there be able to construct its own subtests in a way that's basically similar to stdlib *testing.T.Run.

Given that the central object in the framework is the lineage, this is crucial to allow for more standard helpers that, for example, allow a particular test case to be executed across all schemas in a lineage, and keeping each subtest's output therein tidily namespaced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Breaks existing code enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant