chore(codegen): stop on spec features it can't map - #74
Merged
Merged
Conversation
The script silently dropped or mistranslated spec features it had no mapping for: PATCH operations, header parameters, non-JSON or inline bodies and responses, unions, multi-member allOf, 3.1 type lists, and more. A future spec refresh could lose an endpoint or its data while the tests, which come from the same model, kept passing. Each case now stops with a message naming the operation or schema. Kalshi's current specs use none of them, so the committed output is byte-identical. test_codegen.py covers every check, and make lint runs it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The script in
tools/codegen/quietly dropped or mistranslated spec features it had no mapping for. Kalshi's current specs use none of them. But a future refresh could lose an endpoint or its data, and the route and message tests, which come from the same model, would keep passing. This PR makes each case stop with a message naming the operation or schema.What now stops
$refs.operationId(it was aKeyError).in: headerandin: cookie, which were dropped.contentparameters.style: form, explode: true.$refs outsidecomponents/parameters.$refrequest bodies, which sent{}.$refsuccess responses, which becameResult<void>.oneOf,anyOf,not, anddiscriminator.allOfwith more than one member, or with shape-changing keys beside it.allOfor a$ref.typelists on the REST side.propertiescombined withadditionalProperties, and top-level maps.components/schemas.readOnlyfields in request bodies.std::string.items.Update<T>would drop.msgbodies that aren't objects.update_subscriptionvariant not listed inUPDATE_PAYLOADS.Three mappings were wrong rather than unsupported, so they're fixed instead:
$refmessage body now resolves; it used to become an empty struct.Testing
generate.py --checkpasses on the committed files.tools/codegen/test_codegen.py: 72 tests, run bymake lint, which CI'sbuild-linuxruns. Each check has a test. Against the old generator, 63 of them fail. The other 9 cover specs both versions handle.operationId.make test(287 passed),./tools/test_consumers.sh,make docs, and markdownlint.There's no CHANGELOG entry, because nothing changes for users of the library.