-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
SwaggerEditor@next: no specification loaded on page refresh #5075
Comments
It looks like the issue happens with Swagger UI v5.17.6, most probably due to swagger-api/swagger-ui#9918. With 5.17.5 the page refreshes as it should. |
I made a mistake when porting following conditions: if(this.props.spec && (this.props.spec !== prevStateSpec || this.props.spec !== prevProps.spec)) { if(this.props.url !== prevStateUrl || this.props.url !== prevProps.url) { They key is that we're missing |
The core issues was that after converting swagger-ui-react from class to function component, the default for the spec prop became the useEffect(() => {
if (system) {
const prevStateSpec = system.specSelectors.specStr();
if (
spec &&
spec !== SwaggerUIConstructor.config.defaults.spec &&
(spec !== prevStateSpec || spec !== prevSpec)
) {
const updatedSpec = typeof spec === 'object' ? JSON.stringify(spec) : spec;
system.specActions.updateSpec(updatedSpec);
}
}
}, [system, spec]); |
SwaggerUI regression remediation released as https://github.com/swagger-api/swagger-ui/releases/tag/v5.17.13 |
Addressed in #5080 |
Content & configuration
Running Swagger Editor locally with the default env definition (https://raw.githubusercontent.com/asyncapi/spec/v2.6.0/examples/streetlights-kafka.yml)
Describe the bug you're encountering
The specification loads fine but refreshing the page causes it to disappear from the editor. Any changes made will be lost. This also happens for the GitHub Pages deployment but not for https://editor-next.swagger.io/
To reproduce...
Steps to reproduce the behavior:
{}
specificationExpected behavior
The editor should retain the specification on refresh like in https://editor-next.swagger.io/
The text was updated successfully, but these errors were encountered: