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

Incorrect rendering of security schemas: by reference and inline #1066

Closed
RobinTail opened this issue Apr 6, 2024 · 4 comments · Fixed by #1086
Closed

Incorrect rendering of security schemas: by reference and inline #1066

RobinTail opened this issue Apr 6, 2024 · 4 comments · Fixed by #1086
Labels
bug Something isn't working

Comments

@RobinTail
Copy link
Contributor

RobinTail commented Apr 6, 2024

Describe the bug

Security schemas are not displayed correctly: wrong references, inline ones are not displayed at all.

For some reason the Studio does not follow the references to security schemas correctly — it seems to pick the first one inside components / securitySchemes regardless its id. That leads to wrong schema rendering.
Moreover, even when using no references and writing the security schemas inline — none of them are displayed.

How to Reproduce

Consider an application having server-level and operation-level security schemas.

Case 1
asyncapi: 3.0.0
info:
  title: Testing security
  version: 3.4.5
id: "urn:example:com:"
defaultContentType: text/plain
servers:
  test:
    host: example.com
    pathname: /
    protocol: https
    security:
      - $ref: "#/components/securitySchemes/serverSecurity0"
channels:
  Root:
    address: /
    title: Namespace /
    messages:
      rootIncomingTest:
        name: test
        title: test
        payload:
          type: array
          additionalItems: false
components:
  securitySchemes:
    serverSecurity0:
      type: httpApiKey
      description: Sample security schema
      in: header
      name: X-Api-Key
    rootSecurity0:
      type: userPassword
      description: Namespace level security sample
operations:
  RootRecvOperationTest:
    action: receive
    channel:
      $ref: "#/channels/Root"
    messages:
      - $ref: "#/channels/Root/messages/rootIncomingTest"
    title: test
    summary: Incoming event test
    description: The message consumed by the application within the / namespace
    security:
      - $ref: "#/components/securitySchemes/rootSecurity0"

Studio displays the server-level security schema twice and does not display the operation specific security schema despite the reference

image

Case 2: another order in components
asyncapi: 3.0.0
info:
  title: Testing security
  version: 3.4.5
id: "urn:example:com:"
defaultContentType: text/plain
servers:
  test:
    host: example.com
    pathname: /
    protocol: https
    security:
      - $ref: "#/components/securitySchemes/serverSecurity0"
channels:
  Root:
    address: /
    title: Namespace /
    messages:
      rootIncomingTest:
        name: test
        title: test
        payload:
          type: array
          additionalItems: false
components:
  securitySchemes:
    rootSecurity0:
      type: userPassword
      description: Namespace level security sample
    serverSecurity0:
      type: httpApiKey
      description: Sample security schema
      in: header
      name: X-Api-Key
operations:
  RootRecvOperationTest:
    action: receive
    channel:
      $ref: "#/channels/Root"
    messages:
      - $ref: "#/channels/Root/messages/rootIncomingTest"
    title: test
    summary: Incoming event test
    description: The message consumed by the application within the / namespace
    security:
      - $ref: "#/components/securitySchemes/rootSecurity0"

image

Case 3: inline schemas (no references)
asyncapi: 3.0.0
info:
  title: Testing security
  version: 3.4.5
id: "urn:example:com:"
defaultContentType: text/plain
servers:
  test:
    host: example.com
    pathname: /
    protocol: https
    security:
      - type: httpApiKey
        description: Sample security schema
        in: header
        name: X-Api-Key
channels:
  Root:
    address: /
    title: Namespace /
    messages:
      rootIncomingTest:
        name: test
        title: test
        payload:
          type: array
          additionalItems: false
operations:
  RootRecvOperationTest:
    action: receive
    channel:
      $ref: "#/channels/Root"
    messages:
      - $ref: "#/channels/Root/messages/rootIncomingTest"
    title: test
    summary: Incoming event test
    description: The message consumed by the application within the / namespace
    security:
      - type: userPassword
        description: Namespace level security sample  

image

Expected behavior

  • References should work precisely,
  • Inline security schemas (without references) should also work.
@RobinTail RobinTail added the bug Something isn't working label Apr 6, 2024
Copy link

github-actions bot commented Apr 6, 2024

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@Amzani
Copy link
Collaborator

Amzani commented Apr 22, 2024

Thanks @RobinTail for reporting this issue, this is related to our asyncapi-react dependency that we use to render documentation, I have reported the issue here: asyncapi/asyncapi-react#993

@RobinTail
Copy link
Contributor Author

Thank you for addressing this issue, @Amzani .
I hope you'll find a way to fix it soon.

@RobinTail
Copy link
Contributor Author

The issue can now be resolved by upgrading the dependency
asyncapi/asyncapi-react#993 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants