feat: implement ADR-0008 event stream support in OpenAPI spec#67
feat: implement ADR-0008 event stream support in OpenAPI spec#67jonathannorris wants to merge 5 commits intomainfrom
Conversation
- Bump OpenAPI version from 3.1.0 to 3.2.0 for text/event-stream support - Bump OFREP version from 0.2.0 to 0.3.0 - Add flagConfigEtag and flagConfigLastModified query parameters to both eval endpoints - Add eventStreams field to bulkEvaluationSuccess and serverEvaluationSuccess responses - Add eventStream schema with mutually exclusive url/endpoint fields - Add eventStreamEndpoint schema for structured origin + requestUri - Add sseEvent and sseEventData schemas for event stream payloads - Add webhook documenting text/event-stream content type (OAS 3.2.0) - Disable oas3-schema spectral rule until 3.2.0 support lands (stoplightio/spectral#2910) Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the OpenFeature Remote Evaluation Protocol (OFREP) by integrating event stream support, aligning with ADR-0008. It updates the OpenAPI specification to version 3.2.0 and the OFREP version to 0.3.0, enabling real-time change notifications for flag configurations. This allows providers to subscribe to event streams for immediate updates, moving beyond traditional polling mechanisms for detecting changes. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
There was a problem hiding this comment.
Code Review
This pull request successfully implements ADR-0008 by adding event stream support to the OpenAPI specification. The changes are well-structured, including the version bump to OpenAPI 3.2.0, the addition of new schemas for event streams, and new query parameters. My review includes a few suggestions to enhance maintainability and schema precision by reducing parameter duplication and adding more specific constraints to the new schemas.
I am having trouble creating individual review comments. Click here to see my feedback.
service/openapi.yaml (57-90)
To improve maintainability and reduce duplication, consider defining the flagConfigEtag and flagConfigLastModified parameters as reusable components under components.parameters. You can then reference them in both the /ofrep/v1/evaluate/flags/{key} and /ofrep/v1/evaluate/flags paths using $ref. This ensures consistency and simplifies future updates.
service/openapi.yaml (453-459)
The description states that currently only sse is a defined type. To make the schema more precise and self-documenting for the current version, consider constraining this field to the known value using enum.
type:
type: string
enum: ["sse"]
description: |
The connection type identifying the push mechanism to use.
Currently only `sse` is defined. Providers must ignore entries
with unknown types for forward compatibility.
example: "sse"service/openapi.yaml (474-485)
The description mentions that providers should default to 120 seconds for inactivityDelaySec if the value is not present. It's a good practice to explicitly define this default in the schema using the default keyword. This makes the API contract clearer for consumers.
inactivityDelaySec:
type: integer
minimum: 1
default: 120
description: |
Number of seconds of client inactivity (e.g., browser tab hidden,
mobile app backgrounded) after which the connection should be closed
to conserve resources. The client must reconnect and perform a full
unconditional re-fetch when activity resumes. When determining the
effective inactivity timeout, providers should use a client-side
override if configured; otherwise use this value when present;
otherwise default to 120 seconds.
example: 120service/openapi.yaml (524-529)
The description states that the SSE event type is always message. To enforce this and make the schema more strict, you can add an enum with the single allowed value.
event:
type: string
enum: ["message"]
description: |
The SSE event type. Always `message` for OFREP events. Providers
must inspect `data.type` rather than this field for event routing.
example: "message"service/openapi.yaml (550-555)
The description mentions that currently only refetchEvaluation is defined for the event type. To make the schema more precise for this version of the API, you can constrain this field to the known value using enum.
type:
type: string
enum: ["refetchEvaluation"]
description: |
The OFREP event type. Currently only `refetchEvaluation` is defined.
Providers must ignore unknown values for forward compatibility.
example: "refetchEvaluation"Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
| schema: | ||
| type: string | ||
| required: false | ||
| example: '"550e8400-e29b-41d4-a716-446655440000"' |
There was a problem hiding this comment.
Should the example use both single and double quotes?
Summary
text/event-stream/itemSchemasupporteventStreamsto both evaluation success responses,flagConfigEtag/flagConfigLastModifiedquery parameters to both eval endpoints, and new schemas for event stream connections and event payloadstext/event-streamcontent type using OAS 3.2.0 conventionsNotes
eventStreamschema enforces mutual exclusivity betweenurlandendpointusingoneOf+notclausesendpointprovides structuredorigin+requestUrifor proxied deployments that need to override the origin cleanly while preserving the request targeteventStreamsis designed to be extensible beyond SSERelated Issues