Redocly / redocly-vs-code

Redocly VS Code extension
35 stars 6 forks source link

Previewing empty paths OAS v3.1.0 #32

Open pedrodovale opened 2 years ago

pedrodovale commented 2 years ago

When trying to preview the documentation for an OpenAPI Document complying to the version 3.1.0 of the spec with empty paths, an error is shown.

Can you please check this? Thanks in advance.

How to reproduce

The OpenAPI Document I'm trying to render:

openapi: 3.1.0
info:
  title: Book Shelf API
  description: An API to keep track of Books
  version: "0.1"
  contact:
    name: API Designer
  license:
    url: https://opensource.org/licenses/MIT
    name: MIT
servers:
  - url: http://api.bookshelf.com
paths: {}

Expected Behavior

The API metadata is rendered.

Actual Behavior

This error is show:

Something went wrong...
Cannot read properties of undefined (reading 'type')
Stack trace
(...)

More context

According to the spec, a document with an empty paths is a valid one:

The Paths MAY be empty, due to Access Control List (ACL) constraints.

(source: https://spec.openapis.org/oas/v3.1.0#paths-object)

Leaving the paths empty can be useful for API Designers that want to describe only the contact information or the API Security requirements.

The Redoc Interactive Demo seems to handle this correctly, rendering the API metadata.

tatomyr commented 2 years ago

Thank you @pedrodovale for notifying! Additional context: to reproduce the case I had to put a change to the definition (otherwise only blank screen is shown).