Skip to content

fix(openapi): improve openapi generation#5823

Merged
kodiakhq[bot] merged 1 commit into
v2from
rd/v2/openapi
May 7, 2026
Merged

fix(openapi): improve openapi generation#5823
kodiakhq[bot] merged 1 commit into
v2from
rd/v2/openapi

Conversation

@erka

@erka erka commented May 5, 2026

Copy link
Copy Markdown
Contributor

This PR adds a custom OpenAPI generator (protoc-gen-flipt-openapi) that modifies the standard gnostic OpenAPI generator to support Flipt's Resource Payload pattern.

  • Added internal/cmd/protoc-gen-flipt-openapi/: A custom protoc plugin that wraps the gnostic protoc-gen-openapi generator
  • Added Schema RPC method to EnvironmentsService and SchemaAnchor message as a helper for OpenAPI generation (wraps flipt.core.Flag and flipt.core.Segment)

Why

The standard gnostic generator outputs google.protobuf.Any schemas, but Flipt's Resource API uses polymorphic payloads with a @type discriminator. This custom generator:

  1. Replaces the generic Any type with specific Flag and Segment payload variants
  2. Adds proper OpenAPI schema annotations for the @type discriminator field
  3. Ensures the generated OpenAPI spec correctly documents the Resource API's polymorphic behavior

@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

👋 Hi @erka! Thanks for your contribution to this project.

It looks like one or more of your commits are missing a DCO (Developer Certificate of Origin) sign-off. The DCO is a simple way for you to certify that you have the right to submit this code under the project's license.

How to fix this:

# For future commits, use the -s flag
git commit -s -m "Your commit message"

# To sign off on existing commits in this PR
git rebase HEAD~$(git rev-list --count origin/v2..HEAD) --signoff
git push --force-with-lease

The -s flag adds this line to your commit message:
Signed-off-by: Your Name <[email protected]>

📋 View the failing DCO check for more details

For more information about the DCO, visit: https://developercertificate.org/

@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

The latest Buf updates on your PR. Results from workflow Proto / proto-lint (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedMay 6, 2026, 11:32 AM

@codecov

codecov Bot commented May 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.19%. Comparing base (a0f9803) to head (d7bddf8).

Additional details and impacted files
@@           Coverage Diff           @@
##               v2    #5823   +/-   ##
=======================================
  Coverage   61.19%   61.19%           
=======================================
  Files         141      141           
  Lines       14195    14195           
=======================================
  Hits         8686     8686           
  Misses       4777     4777           
  Partials      732      732           
Flag Coverage Δ
integrationtests 34.49% <ø> (ø)
unittests 52.30% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@erka
erka force-pushed the rd/v2/openapi branch 4 times, most recently from c74a6bb to a987ab7 Compare May 6, 2026 11:07
@erka
erka force-pushed the rd/v2/openapi branch from a987ab7 to d7bddf8 Compare May 6, 2026 11:15
@erka erka added v2 Flipt v2 labels May 6, 2026
@erka
erka marked this pull request as ready for review May 6, 2026 11:24
@erka
erka requested a review from a team as a code owner May 6, 2026 11:24
@dosubot dosubot Bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label May 6, 2026
@erka erka added automerge Used by Kodiak bot to automerge PRs labels May 6, 2026
}

rpc Schema(google.protobuf.Empty) returns (SchemaAnchor) {
option (google.api.http) = {get: "/api/v2/_payloadschema"};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a standard in openapi or something?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, this is workaround for gnostic. By default it only generate openapi schema for objects which are in use in protobuf so I have to fake it in such ugly way to get them into the openapi schema. Saying that.. maybe there is a better way as I've ended up with custom buf plugin.

@markphelps markphelps left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you @erka ! just one question but non-blocking. lgtm

@kodiakhq
kodiakhq Bot merged commit 3790369 into v2 May 7, 2026
49 checks passed
@kodiakhq
kodiakhq Bot deleted the rd/v2/openapi branch May 7, 2026 22:02
@github-project-automation github-project-automation Bot moved this to Done in Flipt V2 May 7, 2026
erka added a commit that referenced this pull request May 8, 2026
A better workaround for #5823 without dirty things in Flipt GRPC.

Signed-off-by: Roman Dmytrenko <[email protected]>
erka added a commit that referenced this pull request May 9, 2026
A better workaround for #5823 without dirty things in Flipt GRPC.

Signed-off-by: Roman Dmytrenko <[email protected]>
kodiakhq Bot pushed a commit that referenced this pull request May 9, 2026
A better workaround for #5823 without dirty things in Flipt GRPC.

Signed-off-by: Roman Dmytrenko <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge Used by Kodiak bot to automerge PRs size:XL This PR changes 500-999 lines, ignoring generated files. v2 Flipt v2

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants