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

Reports unsupported specification when supplying it directly #2485

Open
elvanja opened this issue Jan 29, 2024 · 0 comments
Open

Reports unsupported specification when supplying it directly #2485

elvanja opened this issue Jan 29, 2024 · 0 comments

Comments

@elvanja
Copy link

elvanja commented Jan 29, 2024

The OpenAPI 3.0.3 API definition I am trying to integrate into a project is served from API server as yaml. That yml file is valid, e.g. it opens and renders without issues when I try it online via https://redocly.github.io/redoc/. I am using internal http tools to fetch it's raw content due to JWT authentication. So, I am trying to render the docs via React component, like this:

import { observer } from 'mobx-react'
import { useViewModelFactory } from 'mobx-react-viewmodel'

import { ApiDocPageViewModel } from './api_doc.page.vm.ts'
import { RedocStandalone } from 'redoc';

export const ApiDocPage = observer(function ApiDocPage() {
  const { spec } = useViewModelFactory(() => new ApiDocPageViewModel())

  return (
    <RedocStandalone spec={spec} />
  )
})

The important part is the <RedocStandalone spec={spec} /> section. I checked the spec value and indeed it is a string that contains the API specification, e.g. starts like this:

openapi: 3.0.3
info:
  title: API
  version: '1.0'
servers:
  - url: '{server}/api/v1'
....

However, this results in:

Error: Unsupported specification
    at detectSpec (http://localhost:4010/node_modules/.vite/deps/redoc.js?v=7192a3a7:21531:13)
    at http://localhost:4010/node_modules/.vite/deps/redoc.js?v=7192a3a7:36716:56
    at Generator.next (<anonymous>)
    at http://localhost:4010/node_modules/.vite/deps/redoc.js?v=7192a3a7:36632:71
    at new Promise (<anonymous>)
    at __awaiter (http://localhost:4010/node_modules/.vite/deps/redoc.js?v=7192a3a7:36614:14)
    at bundleDocument (http://localhost:4010/node_modules/.vite/deps/redoc.js?v=7192a3a7:36714:14)
    at http://localhost:4010/node_modules/.vite/deps/redoc.js?v=7192a3a7:36701:16
    at Generator.next (<anonymous>)
    at http://localhost:4010/node_modules/.vite/deps/redoc.js?v=7192a3a7:36632:71
image

I kind of traced this error to https://github.com/Redocly/redocly-cli/blob/main/packages/core/src/oas-types.ts#L103, but not sure if it applies here. Seems it indeed can not recognize the API doc/spec flavor. Which is odd given it works correctly on https://redocly.github.io/redoc. I am using "redoc": "^2.1.3" dependency.

Any idea on what may be wrong in my setup?

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

No branches or pull requests

1 participant