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

RND-2311: enums for server url in openapi block #2452

Open
wants to merge 30 commits into
base: main
Choose a base branch
from

Conversation

BrettJephson
Copy link
Contributor

@BrettJephson BrettJephson commented Sep 5, 2024

With this PR, open api schemas with an array of servers and variables for server urls will allow selection of the variables and choice of server.

Updating code samples and scalar modal's server url when updated. Which fixes Issue #2432

CleanShot.2024-09-12.at.17.11.32.mp4

Copy link

linear bot commented Sep 5, 2024

@BrettJephson BrettJephson self-assigned this Sep 5, 2024
Copy link

changeset-bot bot commented Sep 5, 2024

🦋 Changeset detected

Latest commit: 8d1c349

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@gitbook/react-openapi Minor
gitbook Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

argos-ci bot commented Sep 5, 2024

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) 👍 Changes approved 15 changed Sep 25, 2024, 8:43 AM

Copy link
Member

@SamyPesse SamyPesse left a comment

Choose a reason for hiding this comment

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

Quick first pass, I think we should abstract the concept of enum you are introducing here (enum is also a confusing name btw), to also be used for other client states that the block needs.

@@ -6,7 +6,8 @@
"types": "./dist/index.d.ts",
"development": "./src/index.ts",
"default": "./dist/index.js"
}
},
"./client": "./src/client.ts"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exporting the client component separately here because I found that If I add a client component (OpenAPIContextProvider) to the /src/index file it has the unfortunate side effect of turning all the server components exported in that file into client components.

Copy link
Member

Choose a reason for hiding this comment

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

How does it work if you put 'use server' at the top of the other file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will that do anything? I thought use server was the default and use client is the only directive that really does anything, at the top of a file at least.

Copy link
Member

@SamyPesse SamyPesse left a comment

Choose a reason for hiding this comment

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

Can you add a LOT more comments to explain the relationship and the flow of things? Right now the PR is quite complex and and hard to diggest; it's hard to validate how it'll impact server/client components without understanding the flow of data you ate trying to put in place.

@@ -6,7 +6,8 @@
"types": "./dist/index.d.ts",
"development": "./src/index.ts",
"default": "./dist/index.js"
}
},
"./client": "./src/client.ts"
Copy link
Member

Choose a reason for hiding this comment

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

How does it work if you put 'use server' at the top of the other file?

Comment on lines +7 to +12
type OpenAPIContextProps = {
isPending?: boolean;
serverUrl?: string;
state?: Record<string, string> | null;
onUpdate: (params: Record<string, string> | null) => void;
};
Copy link
Member

Choose a reason for hiding this comment

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

We should document these props, I have no idea what they mean (isPending, etc).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do


export function OpenAPIContextProvider(props: {
children: React.ReactNode;
data: OpenAPIOperationData;
Copy link
Member

Choose a reason for hiding this comment

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

Passing the data here goes against the whole server component approach. This means we'll include the OpenAPI operation data for every element in HTML, resulting in very big HTML output.

}}
className="openapi-block"
/>
<OpenAPIContext block={block} data={data}>
Copy link
Member

Choose a reason for hiding this comment

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

Are we not supposed to have a onUpdate here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Test it" tool URL not prepopulated with gitbook API and must be manually edited
2 participants