Repository navigation
fix(management-sdk): generate from a committed API spec - #849
Merged
Merged
Conversation
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.
Problem
The Management SDK's build wasn't reproducible.
openapi-generator.config.yamlread the spec fromhttps://app.reflag.com/openapi.json, and the committedopenapi.jsonwas an empty file. Everyyarn build, including the release build, regeneratedsrc/generatedfrom whatever production served at that moment.The live spec has changed since the client was last regenerated in #721, so the 2.0.0 release build produced uncommitted changes. That made the docs-sync step fail its clean-checkout check after publishing. Until this is fixed, every release will hit the same failure, and the next Management SDK release would ship code nobody reviewed.
Fix
openapi.json, and pointinputSpecat it. Builds now generate the same code every time.yarn update-spec, which downloads the latest spec. To update the client, runyarn update-spec && yarn generateand commit both, so spec changes go through review.openapi.jsonout ofoxfmtformatting, so the committed file matches whatupdate-specwrites.scripts/prepare-spec.mjs, which runs before generation. The generator flattensanyOfunions into one object with every field required, so a converter foreffectiveRulesfilters would mapfilterson every filter and throw for anything but a group. The script rewrites unions tagged by atypeconstant asoneOfwith atypediscriminator, so the generator emits a real union that switches ontype. It writes to an ignored.openapi.generated.jsonand leaves the committed spec untouched, so the fix survivesupdate-spec. Today, onlyeffectiveFlagFiltermatches.API changes in the regenerated client
flagType(booleanormultivariate), andcreateFlagaccepts it. It's optional and defaults toboolean, so existing calls are unchanged.FlagTargetingincludestargetingModeandeffectiveRules, the compiled rules that decide whether the flag is on. This adds 8 new models.The changeset is a minor bump for
@reflag/management-sdk. The README notes theflagTypedefault.Testing
tsc --project tsconfig.build.jsonpasses, and the Management SDK tests (9) pass.FlagTargetingJSON containing every filter variant, including a group with a nested negation, and serializes it back to the same JSON.