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

Protobuf not rendering #885

Closed
Syndlex opened this issue Dec 8, 2023 · 5 comments · Fixed by #888
Closed

Protobuf not rendering #885

Syndlex opened this issue Dec 8, 2023 · 5 comments · Fixed by #888
Labels
bug Something isn't working

Comments

@Syndlex
Copy link

Syndlex commented Dec 8, 2023

Describe the bug

I don't know if this is a bug or a Pitch.

We try using asyncapi with the following backing stack.
Kafka, CloudEvents, Protobuf.
The CLI tells us the file is valid and has no governance issues.

We would really like to have a rendert Version of the document but Studio is throwing errors.
Is the Protobuf parser missing?
I know this is a complex case but I thinks that this stack should be used more often.

How to Reproduce

Apply this file to Studio

asyncapi: 3.0.0

info:
  title: Service
  version: 1.0.0
  contact:
    name: Developers
    email: [email protected]

servers:
  development:
    host: localhost:9092
    protocol: kafka
    protocolVersion: 2.6.0
    description: Development Kafka broker.

channels:
  in:
    address: in
    title: Inbox channel
    description: This is the topic for all messages that the Account Service is
      meant to process.
    messages:
      createUser:
        $ref: "#/components/messages/CreateUser"
    servers:
      - $ref: "#/servers/development"

components:
  messages:
    CreateUser:
      name: CreateUser
      summary: A command for creating a user.
      tags:
        - name: Users
      contentType: application/vnd.google.protobuf;version=3
      traits:
        - $ref: "#/components/messageTraits/CloudEventHeaders"
      headers:
        type: object
        properties:
          correlationId:
            description: Correlation ID set by the application.
            type: string
            format: uuid
      correlationId:
        description: Default Correlation ID.
        location: $message.header#/correlationId
      payload:
        schemaFormat: application/vnd.google.protobuf;version=3
        schema:
          message Point {
                required int32 x = 1;
                required int32 y = 2;
                optional string label = 3;
            }

          message Line {
              required Point start = 1;
              required Point end = 2;
              optional string label = 3;
          }
  messageTraits:
    CloudEventHeaders:
      headers:
        type: object
        required:
          - ce-specversion
          - ce-id
          - ce-source
          - ce-type
        properties:
          ce-specversion:
            type: string
            description: The version of the CloudEvents specification which the
              event uses.
            enum:
              - "1.0"
          ce-id:
            type: string
            minLength: 1
            description: Identifies the event.
          ce-source:
            type: string
            format: uri-reference
            minLength: 1
            description: Identifies the context in which an event happened.
          ce-type:
            type: string
            minLength: 1
            description: Describes the type of event related to the originating
              occurrence.
          ce-datacontenttype:
            type: string
            description: Content type of the data value. Must adhere to
              RFC 2046 format.
          ce-dataschema:
            type: string
            description: Identifies the schema that data adheres to.
          ce-subject:
            type: string
            description: Describes the subject of the event in the context of
              the event producer (identified by source).
          ce-time:
            type: string
            format: date-time
            description: Timestamp of when the occurrence happened.
              Must adhere to RFC 3339.
          content-type:
            type: string
            enum:
              - application/json

Expected behavior

Show a rendert api doc

@Syndlex Syndlex added the bug Something isn't working label Dec 8, 2023
Copy link

github-actions bot commented Dec 8, 2023

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.

@derberg
Copy link
Member

derberg commented Dec 11, 2023

@Syndlex there are 2 issues related to this problem:

  • Studio do not use @asyncapi/protobuf-schema-parser so it basically needs to be added to dependencies and configured in https://github.com/asyncapi/studio/blob/master/apps/studio/src/services/parser.service.ts#L20-L24
  • Your example will still not work as protobuf is not json structure so you cannot inline it the way you did, it must be passed as string, so you need to modify it like below
        schema: |
          message Point {
                required int32 x = 1;
                required int32 y = 2;
                optional string label = 3;
            }
    
          message Line {
              required Point start = 1;
              required Point end = 2;
              optional string label = 3;
          }

@Syndlex
Copy link
Author

Syndlex commented Dec 11, 2023

Will the parser be supported?
When the answer is yes what has to be done and is it on the roadmap?

is it part of this?
grafik

Is there a possibility to help here?

@Amzani
Copy link
Collaborator

Amzani commented Dec 11, 2023

@Syndlex
Added support in this PR
Thanks @derberg

@derberg
Copy link
Member

derberg commented Dec 13, 2023

that was super quick, awesome

this will work like a charm now

      payload:
        schemaFormat: application/vnd.google.protobuf;version=3
        schema: |
          message Point {
                required int32 x = 1;
                required int32 y = 2;
                optional string label = 3;
            }

          message Line {
              required Point start = 1;
              required Point end = 2;
              optional string label = 3;
          }

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
None yet
Development

Successfully merging a pull request may close this issue.

3 participants