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

Prop warning caused by spec react attribute #6399

Closed
k4m4 opened this issue Sep 14, 2020 · 0 comments · Fixed by #6400
Closed

Prop warning caused by spec react attribute #6399

k4m4 opened this issue Sep 14, 2020 · 0 comments · Fixed by #6400

Comments

@k4m4
Copy link
Contributor

k4m4 commented Sep 14, 2020

Q&A

  • OS: macOS
  • Browser: chrome (can reproduce on any)
  • Version: 85.0.4183.102 (can reproduce on any)
  • Method of installation: npm
  • Swagger-UI version: 3.33.0
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

Example Swagger/OpenAPI definition:

Swagger-UI configuration options (using Next.js):

import SwaggerUI from 'swagger-ui-react';
import openapi from '../openapi';

const Docs = () => {
	return <SwaggerUI spec={openapi} />;
};

export default Docs;

Describe the bug you're encountering

  • When using the spec attribute of the SwaggerUI react component, I get the following warning:
Warning: Failed prop type: Invalid prop `spec` of value `[object Object]` supplied to `SwaggerUI`, expected one of [null,null].

To reproduce...

  1. Install swagger-ui-react and import the SwaggerUI component.
  2. Import the OpenAPI spec as an object (or string).
  3. Pass the OpenAPI spec object to the spec attribute as such: <SwaggerUI spec={openapi} />

Expected behavior

  • No warnings.

Additional context or thoughts

spec: PropTypes.oneOf([
    PropTypes.string,
    PropTypes.object,
]),

should be PropTypes.oneOfType, instead (see github.com/facebook/react/issues/1919 for reference).

@k4m4 k4m4 changed the title Prop warning of spec react attribute Prop warning cause by spec react attribute Sep 14, 2020
@k4m4 k4m4 changed the title Prop warning cause by spec react attribute Prop warning caused by spec react attribute Sep 14, 2020
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 a pull request may close this issue.

1 participant