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

Frontend api openapi spec #4133

Merged
merged 3 commits into from
Jul 3, 2023
Merged

Frontend api openapi spec #4133

merged 3 commits into from
Jul 3, 2023

Conversation

kwasniew
Copy link
Contributor

@kwasniew kwasniew commented Jul 3, 2023

About the changes

Improving openapi spec for the frontend api - details inline

  • replaced conditional middleware with inline if statements. conditional middleware hides controller from the openapi listing
  • added 4xx errors to the spec
  • copied descriptions from the similar API
  • docs update: enabled status is always true for the frontend API

Important files

Discussion points

@vercel
Copy link

vercel bot commented Jul 3, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Jul 3, 2023 1:17pm
unleash-monorepo-frontend ⬜️ Ignored (Inspect) Jul 3, 2023 1:17pm

@@ -47,11 +46,7 @@ class IndexRouter extends Controller {

this.use(
'/api/frontend',
conditionalMiddleware(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

conditionalMiddleware is hiding openapi definitions so I moved the flag inside the 3 controller methods in the frontend API

@@ -146,6 +164,9 @@ export default class ProxyController extends Controller {
req: ApiUserRequest,
res: Response<ProxyFeaturesSchema>,
) {
if (!this.config.flagResolver.isEnabled('embedProxy')) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

replaces conditional middleware

@@ -9,12 +9,19 @@ export const proxyFeatureSchema = {
properties: {
name: {
type: 'string',
example: 'disable-comments',
description: 'Unique feature name.',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

syncing descriptions with the feature-schema

},
enabled: {
type: 'boolean',
example: true,
description: 'Always set to `true`.',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FRONTEND api returns only enabled toggles for a given context

@@ -68,7 +70,12 @@ export default class ProxyController extends Controller {
operationId: 'getFrontendFeatures',
responses: {
200: createResponseSchema('proxyFeaturesSchema'),
...getStandardResponses(401, 404),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

404 when the frontend api/embedProxy is disabled

Copy link
Contributor

@sjaanus sjaanus left a comment

Choose a reason for hiding this comment

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

LG

@kwasniew kwasniew merged commit b50b06c into main Jul 3, 2023
10 checks passed
@kwasniew kwasniew deleted the frontend-api-openapi-spec branch July 3, 2023 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants