wso2 / streaming-integrator-tooling

Apache License 2.0
45 stars 33 forks source link

Update source/sink list drop down in Async API view #182

Closed dilini-muthumala closed 3 years ago

dilini-muthumala commented 3 years ago

Description: The source/sink list drop down in Async API view includes sources/sinks that cannot be exported as Async APIs.

Screen Shot 2021-04-10 at 10 36 21 PM

If I choose a sink/source from the drop down that is not included in the list defined as sinkSorceTypes in [1], and click the button 'Generate Async API', it does not do anything. When I check the browser's JS console, the following error was there, as it is looking for the 'security' element of the source/sink in sinkSorceTypes in [1].

async-api-generator.js:602 Uncaught TypeError: Cannot read property 'security' of undefined
    at getServerHostPort (async-api-generator.js:602)
    at AsyncAPIView.generateAsyncAPI (async-api-generator.js:314)
    at HTMLButtonElement.<anonymous> (async-api-generator.js:184)
    at HTMLButtonElement.dispatch (jquery-1.9.1.min.js:3)
    at HTMLButtonElement.v.handle (jquery-1.9.1.min.js:3)
Screen Shot 2021-04-10 at 10 41 44 PM

[1] https://github.com/wso2/carbon-analytics/blob/master/components/org.wso2.carbon.siddhi.editor.core/src/main/resources/web/editor/js/async-api/async-api-generator.js#L125

Affected Product Version: wso2si-tooling-4.0.0-SNAPSHOT

Steps to reproduce: Create below app, go to Async API view, fill the fields (choose websocket as the source/sink) , and click on 'Generate Async API' button.

@App:name('Badapp')

@App:description('Description of the plan')

@source(type='kafka',topic.list = "productions",threading.option = "single.thread",group.id = "group1",bootstrap.servers = "localhost:9092",
    @map(type='json'))
define stream SweetProductionStream (name string,amount double);

@sink(type='websocket', 
      url='ws://localhost:8025/abc',
@map(type='xml'))
define stream LowProductionAlertStream (name string, amount double);

@info(name='query1')
from SweetProductionStream 
select * 
insert  into LowProductionAlertStream;
dilini-muthumala commented 3 years ago

On a related note - it was noted that it is allowed to Generate an Async API from the following app although it does not make sense to create an Async API from an SSE source.

@App:name('SSEApp')
@App:description('Description of the plan')

@App:asyncAPI("""asyncapi: 2.0.0
info:
  title: ssetest
  version: 1.0.0
  description: test sse
servers:
  production:
    url: 'localhost:8080'
    protocol: http
    security: []
channels:
  /:
    publish:
      message:
        $ref: '#/components/messages/RecieveProductionStreamPayload'
components:
  messages:
    RecieveProductionStreamPayload:
      payload:
        type: object
        properties:
          date:
            $ref: '#/components/schemas/date'
  schemas:
    date:
      type: string
  securitySchemes: {}
""")

@source(type='sse',event.source.url = "http://localhost:8080",
    @map(type='json'))
define stream RecieveProductionStream (date string);

@sink(type='log')
define stream LogProductionStream (date string);

@info(name='query1')
from RecieveProductionStream 
select * 
insert  into LogProductionStream;
dnwick commented 3 years ago

This is fixed now