Authress-Engineering / openapi-explorer

OpenAPI Web component to generate a UI from the spec.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support string or boolean version of props

SeanLMcCullough opened this issue · comments

I came across an interesting issue when trying to hide the server selection in my implementation of openapi-explorer. The documentation could be more clear on how to use the props.

The Hide/Show Sections part of the docs lists show-server-selection etc.

These props should be noted that they are Strings and not Booleans as you'd think. This required a lot of debugging and shadow root manipulation to hide the server selection until I realised that there are two confusing problems;

  • show-server-selection is a string of a boolean (ex below)
  • show-server-selection is called allowServerSelection internally

This works

  <openapi-explorer
    spec-url="./openapi.yaml"
    :server-url="serverUrl"
    :show-server-selection="String(false)"
  >
  </openapi-explorer>

This does not work

  <openapi-explorer
    spec-url="./openapi.yaml"
    :server-url="serverUrl"
    :show-server-selection="false"
  >
  </openapi-explorer>

Rather than add complexity to the docs, the better solution here will be for us to accept either. It's unfortunate that parameter doesn't do that yet, but it will.

These properties have been migrated to the new hide- values for ones that have the functionality enabled by default. There is really no way to fix this because of the html specification itself. So rather than trying to make this complicated for people to understand, we are opting to avoid the issue altogether.

from now on the documentation points to these new properties in the new version 2.0,