redocly-vs-code icon indicating copy to clipboard operation
redocly-vs-code copied to clipboard

Previewing empty paths OAS v3.1.0

Open pedrodovale opened this issue 3 years ago • 3 comments

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.

pedrodovale avatar Jun 06 '22 09:06 pedrodovale

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).

tatomyr avatar Jun 07 '22 09:06 tatomyr