Code Monkey home page Code Monkey logo

Comments (4)

derberg avatar derberg commented on June 25, 2024

Hey there, please provide a full example, or at least a formatted message that can be copy/pasted

please use markdown code formatting

from generator.

lenartgolob avatar lenartgolob commented on June 25, 2024
asyncapi: '2.6.0'
info:
  title: Message Queues Documentation
  version: '1.0.0'
  description: This is a documentation for message queues
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
servers:
  test:
    url: test.mykafkacluster.org:8092
    protocol: kafka-secure
    description: Test broker
    security:
      - saslScram: []
defaultContentType: application/json
channels:

  #  Session

  "{operatorId}.*.session.started":
    description: desc
    parameters:
      operatorId:
        $ref: '#/components/parameters/operatorId'
    publish:
      operationId: sessionStarted
      traits:
        - $ref: '#/components/operationTraits/kafka'
      message:
        $ref: '#/components/messages/SessionStarted'
      tags:
        - name:  Session

components:
  messages:
    SessionStarted:
      name: SessionStarted
      title: Session Started
      contentType: application/json
      traits:
        - $ref: '#/components/messageTraits/commonHeaders'
      payload:
        $ref: "#/components/schemas/SessionPayload"   
        example:
          SessionId: 660427
          SessionNumber: "S-2023/2673"
          SessionSourceId: 1
          ParkingFrom: null
          ParkingTo: null
          ConnectedFrom: "2023-10-30T07: 53: 03.557Z"
          ConnectedTo: null
          From: "2023-10-30T07: 53: 03.557Z"
          To: null
          MeterStart: 6804.3 
          MeterEnd: null
          Consumption: null
          Power: null
          RoamingTypeId: 0
          RoamingSessionId: null
          InstanceRoamingPlatformId: null
          Object: 
            Id: 75691
            ObjectFriendlyCode: "1"                 
                                                                                                                              

  schemas:
    SessionPayload:
      type: object
      properties:
        SessionId:
          type: integer
          format: int64
          description: Unique ID of the  session
        SessionNumber:
          type: string
          description: Friendly ID of the  session
        SessionSourceId:
          type: integer
          format: int16
          description: 1 - Local charge point (CSO); 2 - Roaming CDR.
        ParkingFrom:
          type: string
          format: date-time
          description: Parking start time. Normally empty if charger is not able to detect parking time.
        ParkingTo:
          type: string
          format: date-time
          description: Parking end time. Normally empty if charger is not able to detect parking time.
        ConnectedFrom:
          type: string
          format: date-time
        ConnectedTo:
          type: string
          format: date-time
        From:
          type: string
          format: date-time
        To:
          type: string
          format: date-time
        MeterStart:
          type: string
          format: date-time
        MeterEnd:
          type: string
          format: date-time
        Consumption:
          type: number
          format: float
        Power:
          type: number
          format: float
        RoamingTypeId:
          type: integer
          format: int32
        RoamingSessionId:
          type: string
          description: Roaming session id, collected from roaming partner, used as reference when communicating with partner.
        InstanceRoamingPlatformId:
          type: integer
          format: int32
        Object:
          type: object
          properties:
            Id:
              type: integer
              format: int32
            ObjectFriendlyCode:
              type: string
  
  securitySchemes:
    saslScram:
      type: scramSha256
      description: Provide your username and password for SASL/SCRAM authentication
  parameters:
    operatorId:
      description: Instance ID. Every tenant has unique ID.
      schema:
        type: integer
        format: int32                
  messageTraits:
    commonHeaders:
      headers:
        type: object
        properties:
          my-app-header:
            type: integer
            minimum: 0
            maximum: 100
  operationTraits:
    kafka:
      bindings:
        kafka:
          clientId: my-app-id

@derberg This is the sample document (full document is too long). There are no error, the file gets generated, but the examples are generic instead of the examples I listed. I want the generated html file to have the example I listed. When I preview the async file with VS Code Extension the examples are the ones I defined and not generated ones, but once I generate html file the genric examples show up. Also defining example for each attribute is really not an option, because the file is so long and examples are also very long.

from generator.

derberg avatar derberg commented on June 25, 2024

@derberg sorry for such a late response but we were in the middle of asyncapi v3 release and then also christmas break

the problem is that you provide example in not a valid asyncapi way

your message should look like:

    SessionStarted:
      name: SessionStarted
      title: Session Started
      contentType: application/json
      traits:
        - $ref: '#/components/messageTraits/commonHeaders'
      payload:
        $ref: "#/components/schemas/SessionPayload"   
      examples:
        - payload:
            SessionId: 660427
            SessionNumber: "S-2023/2673"
            SessionSourceId: 1
            ParkingFrom: null
            ParkingTo: null
            ConnectedFrom: "2023-10-30T07: 53: 03.557Z"
            ConnectedTo: null
            From: "2023-10-30T07: 53: 03.557Z"
            To: null
            MeterStart: 6804.3 
            MeterEnd: null
            Consumption: null
            Power: null
            RoamingTypeId: 0
            RoamingSessionId: null
            InstanceRoamingPlatformId: null
            Object: 
              Id: 75691
              ObjectFriendlyCode: "1"      

since message can also have headers, then an example object has a structure that enable you to provide example of header and payload separately + you can have multiple examples -> https://v2.asyncapi.com/docs/reference/specification/v2.6.0#messageExampleObject

here you can see fixed document but still with errors as your example do not match provided AsyncAPI Schema

from generator.

derberg avatar derberg commented on June 25, 2024

7 days passed. I think we can assume provided solution will work. Closing. Feel free to drop a comment in case it is not really resolved

from generator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.