diff --git a/components/index.js b/components/index.js index a7a2a6d61..b4a04b41e 100644 --- a/components/index.js +++ b/components/index.js @@ -26,6 +26,10 @@ export function Index({ asyncapi, params = {} }) { if(params.baseHref) { basehref = ``; } + let appJs = ``; + if(params?.singleFile) { + appJs = ``; + } return (` @@ -42,13 +46,20 @@ export function Index({ asyncapi, params = {} }) { ${asyncapiScript} - + ${appJs} ` ); } - \ No newline at end of file + +export function App({ asyncapi, params = {} }) { + return (` + const schema = ${stringifySpec(asyncapi)}; + const config = ${stringifyConfiguration(params)}; + const appRoot = document.getElementById('root'); + AsyncApiStandalone.render( + { schema, config, }, appRoot + ); + ` + ); +} diff --git a/template/js/app.js.js b/template/js/app.js.js new file mode 100644 index 000000000..036de9078 --- /dev/null +++ b/template/js/app.js.js @@ -0,0 +1,17 @@ +import { File } from '@asyncapi/generator-react-sdk'; +import { App } from '../../components/index'; +import { AsyncAPIDocumentInterface } from '@asyncapi/parser'; + +/** + * + * @param {object} param0 + * @param {AsyncAPIDocumentInterface} param0.asyncapi + * @returns + */ +export default function({ asyncapi, params = {} }) { + return ( + + + + ); +} diff --git a/test/components/__snapshots__/index.test.js.snap b/test/components/__snapshots__/index.test.js.snap index 2530cc26f..62d969e24 100644 --- a/test/components/__snapshots__/index.test.js.snap +++ b/test/components/__snapshots__/index.test.js.snap @@ -1,99 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Index component should render AsyncAPI v2 document 1`] = ` -" - - - - - Streetlights API 1.0.0 documentation - - - - - - - -
Streetlights API 1.0.0

The Smartylighting Streetlights API allows you to remotely manage the city lights.

-

Check out its awesome features:

-
    -
  • Turn a specific streetlight on/off 🌃
  • -
  • Dim a specific streetlight 😎
  • -
  • Receive real-time information about environmental lighting conditions 📈
  • -
-
  • #One
  • #Two

Servers

  • test.mosquitto.org:{port}mqttproduction

    Test broker

    -
    object
    port
    required
    string

    Secure connection (TLS) is available through port 8883.

    -
    Default value:"1883"
      Allowed values:
    • "1883"
    • "8883"
    Security:
    • API key
      • In: user

      Provide your API key as the user and leave the password empty.

      -
    • API key
      • In: user

      Provide your API key as the user and leave the password empty.

      -
    • API key
      • In: user

      Provide your API key as the user and leave the password empty.

      -

Operations

  • RECEIVE smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured

    The topic on which measured values may be produced and consumed.

    -

    Inform about environmental lighting conditions of a particular streetlight.

    Operation IDreceiveLightMeasurement

    Available only on servers:

    object
    streetlightId
    required
    string

    The ID of the streetlight.

    -
    object
    clientId
    my-app-id
    • #One

    Accepts the following message:

    Light measured

    Inform about environmental lighting conditions of a particular streetlight.

    object
    lumens
    integer
    >= 0

    Light intensity measured in lumens.

    -
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    -

    Additional properties are allowed.

    object
    my-app-header
    integer
    [ 0 .. 100 ]

    Additional properties are allowed.

    Examples

    {
    -  \\"lumens\\": 0,
    -  \\"sentAt\\": \\"2019-08-24T14:15:22Z\\"
    -}
    -
    -
    This example has been generated automatically.
    {
    -  \\"my-app-header\\": 100
    -}
    -
    -
    This example has been generated automatically.
  • SEND smartylighting/streetlights/1/0/action/{streetlightId}/turn/on

    Operation IDturnOn

    Available only on servers:

    object
    streetlightId
    required
    string

    The ID of the streetlight.

    -
    object
    clientId
    my-app-id
    • #Two

    Accepts the following message:

    Turn on/off

    Command a particular streetlight to turn the lights on or off.

    object
    command
    string

    Whether to turn on or off the light.

    -
      Allowed values:
    • "on"
    • "off"
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    -

    Additional properties are allowed.

    object
    my-app-header
    integer
    [ 0 .. 100 ]

    Additional properties are allowed.

    Examples

    {
    -  \\"command\\": \\"on\\",
    -  \\"sentAt\\": \\"2019-08-24T14:15:22Z\\"
    -}
    -
    -
    This example has been generated automatically.
    {
    -  \\"my-app-header\\": 100
    -}
    -
    -
    This example has been generated automatically.
  • SEND smartylighting/streetlights/1/0/action/{streetlightId}/turn/off

    Operation IDturnOff

    Available only on servers:

    object
    streetlightId
    required
    string

    The ID of the streetlight.

    -
    object
    clientId
    my-app-id
    • #One

    Accepts the following message:

    Turn on/off

    Command a particular streetlight to turn the lights on or off.

    object
    command
    string

    Whether to turn on or off the light.

    -
      Allowed values:
    • "on"
    • "off"
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    -

    Additional properties are allowed.

    object
    my-app-header
    integer
    [ 0 .. 100 ]

    Additional properties are allowed.

    Examples

    {
    -  \\"command\\": \\"on\\",
    -  \\"sentAt\\": \\"2019-08-24T14:15:22Z\\"
    -}
    -
    -
    This example has been generated automatically.
    {
    -  \\"my-app-header\\": 100
    -}
    -
    -
    This example has been generated automatically.
  • SEND smartylighting/streetlights/1/0/action/{streetlightId}/dim

    Operation IDdimLight

    Available only on servers:

    object
    streetlightId
    required
    string

    The ID of the streetlight.

    -
    object
    clientId
    my-app-id
    • #Two

    Accepts the following message:

    Dim light

    Command a particular streetlight to dim the lights.

    object
    percentage
    integer
    [ 0 .. 100 ]

    Percentage to which the light should be dimmed to.

    -
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    -

    Additional properties are allowed.

    object
    my-app-header
    integer
    [ 0 .. 100 ]

    Additional properties are allowed.

    Examples

    {
    -  \\"percentage\\": 100,
    -  \\"sentAt\\": \\"2019-08-24T14:15:22Z\\"
    -}
    -
    -
    This example has been generated automatically.
    {
    -  \\"my-app-header\\": 100
    -}
    -
    -
    This example has been generated automatically.

Messages

  • #1Light measuredlightMeasured

    Inform about environmental lighting conditions of a particular streetlight.

    Message IDlightMeasured
    object
    lumens
    integer
    >= 0

    Light intensity measured in lumens.

    -
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    -

    Additional properties are allowed.

    object
    my-app-header
    integer
    [ 0 .. 100 ]

    Additional properties are allowed.

  • #2Turn on/offturnOnOff

    Command a particular streetlight to turn the lights on or off.

    Message IDturnOnOff
    object
    command
    string

    Whether to turn on or off the light.

    -
      Allowed values:
    • "on"
    • "off"
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    -

    Additional properties are allowed.

    object
    my-app-header
    integer
    [ 0 .. 100 ]

    Additional properties are allowed.

  • #3Dim lightdimLight

    Command a particular streetlight to dim the lights.

    Message IDdimLight
    object
    percentage
    integer
    [ 0 .. 100 ]

    Percentage to which the light should be dimmed to.

    -
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    -

    Additional properties are allowed.

    object
    my-app-header
    integer
    [ 0 .. 100 ]

    Additional properties are allowed.

Schemas

  • object
    lumens
    integer
    >= 0

    Light intensity measured in lumens.

    -
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    -

    Additional properties are allowed.

  • object
    command
    string

    Whether to turn on or off the light.

    -
      Allowed values:
    • "on"
    • "off"
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    -

    Additional properties are allowed.

  • object
    percentage
    integer
    [ 0 .. 100 ]

    Percentage to which the light should be dimmed to.

    -
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    -

    Additional properties are allowed.

  • sentAt
    string
    format: date-time

    Date and time when the message was sent.

    -
- - - - - - " + const config = {\\"show\\":{\\"sidebar\\":true},\\"sidebar\\":{\\"showOperations\\":\\"byDefault\\"}}; + const appRoot = document.getElementById('root'); + AsyncApiStandalone.render( + { schema, config, }, appRoot + );" `; -exports[`Index component should render AsyncAPI v3 document 1`] = ` -" - - - - - Streetlights API 1.0.0 documentation - - - - - - - -
Streetlights API 1.0.0

The Smartylighting Streetlights API allows you to remotely manage the city lights.

-

Check out its awesome features:

-
    -
  • Turn a specific streetlight on/off 🌃
  • -
  • Dim a specific streetlight 😎
  • -
  • Receive real-time information about environmental lighting conditions 📈
  • -
-

Servers

  • mqtt://test.mosquitto.org:{port}/mqttproduction

    Test broker

    -
    object
    port
    required
    string

    Secure connection (TLS) is available through port 8883.

    -
    Default value:"1883"
      Allowed values:
    • "1883"
    • "8883"

Operations

  • RECEIVE smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured

    The topic on which measured values may be produced and consumed.

    -

    Inform about environmental lighting conditions of a particular streetlight.

    This is the description with bold text.

    -

    On multiple lines.

    -
    Operation IDreceiveLightMeasurement

    Available only on servers:

    object
    streetlightId
    required
    string

    The ID of the streetlight.

    -
    object
    object
    const
    my-app-id

    Accepts the following message:

    Light measuredreceiveLightMeasurement.message

    Inform about environmental lighting conditions of a particular streetlight.

    Message IDreceiveLightMeasurement.message
    object
    integer
    >= 0

    Light intensity measured in lumens.

    -
    object
    x-pi
    false
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    -

    Additional properties are allowed.

    object
    my-app-header
    integer
    [ 0 .. 100 ]

    Additional properties are allowed.

    Examples

    {
    -  \\"lumens\\": 0,
    -  \\"sentAt\\": \\"2019-08-24T14:15:22Z\\"
    -}
    -
    -
    This example has been generated automatically.
    {
    -  \\"my-app-header\\": 100
    -}
    -
    -
    This example has been generated automatically.
  • SEND smartylighting/streetlights/1/0/action/{streetlightId}/turn/on

    Operation IDturnOn

    Available only on servers:

    object
    streetlightId
    required
    string

    The ID of the streetlight.

    -
    object
    object
    const
    my-app-id

    Accepts the following message:

    Turn on/offturnOn.message

    Command a particular streetlight to turn the lights on or off.

    Message IDturnOn.message
    object
    string

    Whether to turn on or off the light.

    -
      Allowed values:
    • "on"
    • "off"
    object
    x-pi
    false
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    -

    Additional properties are allowed.

    object
    my-app-header
    integer
    [ 0 .. 100 ]

    Additional properties are allowed.

    Examples

    {
    -  \\"command\\": \\"on\\",
    -  \\"sentAt\\": \\"2019-08-24T14:15:22Z\\"
    -}
    -
    -
    This example has been generated automatically.
    {
    -  \\"my-app-header\\": 100
    -}
    -
    -
    This example has been generated automatically.
  • SEND smartylighting/streetlights/1/0/action/{streetlightId}/turn/off

    Operation IDturnOff

    Available only on servers:

    object
    streetlightId
    required
    string

    The ID of the streetlight.

    -
    object
    object
    const
    my-app-id

    Accepts the following message:

    Turn on/offturnOn.message

    Command a particular streetlight to turn the lights on or off.

    Message IDturnOn.message
    object
    string

    Whether to turn on or off the light.

    -
      Allowed values:
    • "on"
    • "off"
    object
    x-pi
    false
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    -

    Additional properties are allowed.

    object
    my-app-header
    integer
    [ 0 .. 100 ]

    Additional properties are allowed.

    Examples

    {
    -  \\"command\\": \\"on\\",
    -  \\"sentAt\\": \\"2019-08-24T14:15:22Z\\"
    -}
    -
    -
    This example has been generated automatically.
    {
    -  \\"my-app-header\\": 100
    -}
    -
    -
    This example has been generated automatically.
  • SEND smartylighting/streetlights/1/0/action/{streetlightId}/dim

    Operation IDdimLight

    Available only on servers:

    object
    streetlightId
    required
    string

    The ID of the streetlight.

    -
    object
    object
    const
    my-app-id

    Accepts the following message:

    Dim lightdimLight.message

    Command a particular streetlight to dim the lights.

    Message IDdimLight.message
    object
    percentage
    integer
    [ 0 .. 100 ]

    Percentage to which the light should be dimmed to.

    -
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    -

    Additional properties are allowed.

    object
    my-app-header
    integer
    [ 0 .. 100 ]

    Additional properties are allowed.

    Examples

    {
    -  \\"percentage\\": 100,
    -  \\"sentAt\\": \\"2019-08-24T14:15:22Z\\"
    -}
    -
    -
    This example has been generated automatically.
    {
    -  \\"my-app-header\\": 100
    -}
    -
    -
    This example has been generated automatically.
  • SEND some.channel

    this description shows in markdown

    -
    Operation IDsome.channel.subscribe

    Available only on servers:

    Accepts one of the following messages:

    • #0subscribe.message.0
      Message IDsubscribe.message.0
      object
      result
      string
        Examples values:
      • "success"

      Additional properties are allowed.

      Examples

      {
      -  \\"result\\": \\"success\\"
      -}
      -
      -
      This example has been generated automatically.
    • #1subscribe.message.1
      Message IDsubscribe.message.1
      object
        Examples values:
      • {"error":{"errorCode":404,"errorMessage":"Something messed up"}}
      object
      errorCode
      integer
      errorMessage
      string

      Additional properties are allowed.

      Additional properties are allowed.

      Examples

      • #1 Example
        {
        -  \\"error\\": {
        -    \\"errorCode\\": 404,
        -    \\"errorMessage\\": \\"Something messed up\\"
        -  }
        -}
        -
        -

Messages

  • #1Light measuredlightMeasured

    Inform about environmental lighting conditions of a particular streetlight.

    Message IDlightMeasured
    object
    integer
    >= 0

    Light intensity measured in lumens.

    -
    object
    x-pi
    false
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    -

    Additional properties are allowed.

    object
    my-app-header
    integer
    [ 0 .. 100 ]

    Additional properties are allowed.

  • #2Turn on/offturnOnOff

    Command a particular streetlight to turn the lights on or off.

    Message IDturnOnOff
    object
    string

    Whether to turn on or off the light.

    -
      Allowed values:
    • "on"
    • "off"
    object
    x-pi
    false
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    -

    Additional properties are allowed.

    object
    my-app-header
    integer
    [ 0 .. 100 ]

    Additional properties are allowed.

  • #3Dim lightdimLight

    Command a particular streetlight to dim the lights.

    Message IDdimLight
    object
    percentage
    integer
    [ 0 .. 100 ]

    Percentage to which the light should be dimmed to.

    -
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    -

    Additional properties are allowed.

    object
    my-app-header
    integer
    [ 0 .. 100 ]

    Additional properties are allowed.

  • #4successMessage
    Message IDsuccessMessage
    object
    result
    string
      Examples values:
    • "success"

    Additional properties are allowed.

  • #5failureMessage
    Message IDfailureMessage
    object
      Examples values:
    • {"error":{"errorCode":404,"errorMessage":"Something messed up"}}
    object
    errorCode
    integer
    errorMessage
    string

    Additional properties are allowed.

    Additional properties are allowed.

Schemas

  • object
    integer
    >= 0

    Light intensity measured in lumens.

    -
    object
    x-pi
    false
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    -

    Additional properties are allowed.

  • object
    string

    Whether to turn on or off the light.

    -
      Allowed values:
    • "on"
    • "off"
    object
    x-pi
    false
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    -

    Additional properties are allowed.

  • object
    percentage
    integer
    [ 0 .. 100 ]

    Percentage to which the light should be dimmed to.

    -
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    -

    Additional properties are allowed.

  • sentAt
    string
    format: date-time

    Date and time when the message was sent.

    -
- - - - + const config = {\\"show\\":{\\"sidebar\\":true},\\"sidebar\\":{\\"showOperations\\":\\"byDefault\\"}}; + const appRoot = document.getElementById('root'); + AsyncApiStandalone.render( + { schema, config, }, appRoot + );" +`; + +exports[`Index component should render AsyncAPI v2 document 1`] = ` +" + + + + + Streetlights API 1.0.0 documentation + + + + + + + +
Streetlights API 1.0.0

The Smartylighting Streetlights API allows you to remotely manage the city lights.

+

Check out its awesome features:

+
    +
  • Turn a specific streetlight on/off 🌃
  • +
  • Dim a specific streetlight 😎
  • +
  • Receive real-time information about environmental lighting conditions 📈
  • +
+
  • #One
  • #Two

Servers

  • test.mosquitto.org:{port}mqttproduction

    Test broker

    +
    object
    port
    required
    string

    Secure connection (TLS) is available through port 8883.

    +
    Default value:"1883"
      Allowed values:
    • "1883"
    • "8883"
    Security:
    • API key
      • In: user

      Provide your API key as the user and leave the password empty.

      +
    • API key
      • In: user

      Provide your API key as the user and leave the password empty.

      +
    • API key
      • In: user

      Provide your API key as the user and leave the password empty.

      +

Operations

  • RECEIVE smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured

    The topic on which measured values may be produced and consumed.

    +

    Inform about environmental lighting conditions of a particular streetlight.

    Operation IDreceiveLightMeasurement

    Available only on servers:

    object
    streetlightId
    required
    string

    The ID of the streetlight.

    +
    object
    clientId
    my-app-id
    • #One

    Accepts the following message:

    Light measured

    Inform about environmental lighting conditions of a particular streetlight.

    object
    lumens
    integer
    >= 0

    Light intensity measured in lumens.

    +
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    +

    Additional properties are allowed.

    object
    my-app-header
    integer
    [ 0 .. 100 ]

    Additional properties are allowed.

    Examples

    {
    +  \\"lumens\\": 0,
    +  \\"sentAt\\": \\"2019-08-24T14:15:22Z\\"
    +}
    +
    +
    This example has been generated automatically.
    {
    +  \\"my-app-header\\": 100
    +}
    +
    +
    This example has been generated automatically.
  • SEND smartylighting/streetlights/1/0/action/{streetlightId}/turn/on

    Operation IDturnOn

    Available only on servers:

    object
    streetlightId
    required
    string

    The ID of the streetlight.

    +
    object
    clientId
    my-app-id
    • #Two

    Accepts the following message:

    Turn on/off

    Command a particular streetlight to turn the lights on or off.

    object
    command
    string

    Whether to turn on or off the light.

    +
      Allowed values:
    • "on"
    • "off"
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    +

    Additional properties are allowed.

    object
    my-app-header
    integer
    [ 0 .. 100 ]

    Additional properties are allowed.

    Examples

    {
    +  \\"command\\": \\"on\\",
    +  \\"sentAt\\": \\"2019-08-24T14:15:22Z\\"
    +}
    +
    +
    This example has been generated automatically.
    {
    +  \\"my-app-header\\": 100
    +}
    +
    +
    This example has been generated automatically.
  • SEND smartylighting/streetlights/1/0/action/{streetlightId}/turn/off

    Operation IDturnOff

    Available only on servers:

    object
    streetlightId
    required
    string

    The ID of the streetlight.

    +
    object
    clientId
    my-app-id
    • #One

    Accepts the following message:

    Turn on/off

    Command a particular streetlight to turn the lights on or off.

    object
    command
    string

    Whether to turn on or off the light.

    +
      Allowed values:
    • "on"
    • "off"
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    +

    Additional properties are allowed.

    object
    my-app-header
    integer
    [ 0 .. 100 ]

    Additional properties are allowed.

    Examples

    {
    +  \\"command\\": \\"on\\",
    +  \\"sentAt\\": \\"2019-08-24T14:15:22Z\\"
    +}
    +
    +
    This example has been generated automatically.
    {
    +  \\"my-app-header\\": 100
    +}
    +
    +
    This example has been generated automatically.
  • SEND smartylighting/streetlights/1/0/action/{streetlightId}/dim

    Operation IDdimLight

    Available only on servers:

    object
    streetlightId
    required
    string

    The ID of the streetlight.

    +
    object
    clientId
    my-app-id
    • #Two

    Accepts the following message:

    Dim light

    Command a particular streetlight to dim the lights.

    object
    percentage
    integer
    [ 0 .. 100 ]

    Percentage to which the light should be dimmed to.

    +
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    +

    Additional properties are allowed.

    object
    my-app-header
    integer
    [ 0 .. 100 ]

    Additional properties are allowed.

    Examples

    {
    +  \\"percentage\\": 100,
    +  \\"sentAt\\": \\"2019-08-24T14:15:22Z\\"
    +}
    +
    +
    This example has been generated automatically.
    {
    +  \\"my-app-header\\": 100
    +}
    +
    +
    This example has been generated automatically.

Messages

  • #1Light measuredlightMeasured

    Inform about environmental lighting conditions of a particular streetlight.

    Message IDlightMeasured
    object
    lumens
    integer
    >= 0

    Light intensity measured in lumens.

    +
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    +

    Additional properties are allowed.

    object
    my-app-header
    integer
    [ 0 .. 100 ]

    Additional properties are allowed.

  • #2Turn on/offturnOnOff

    Command a particular streetlight to turn the lights on or off.

    Message IDturnOnOff
    object
    command
    string

    Whether to turn on or off the light.

    +
      Allowed values:
    • "on"
    • "off"
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    +

    Additional properties are allowed.

    object
    my-app-header
    integer
    [ 0 .. 100 ]

    Additional properties are allowed.

  • #3Dim lightdimLight

    Command a particular streetlight to dim the lights.

    Message IDdimLight
    object
    percentage
    integer
    [ 0 .. 100 ]

    Percentage to which the light should be dimmed to.

    +
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    +

    Additional properties are allowed.

    object
    my-app-header
    integer
    [ 0 .. 100 ]

    Additional properties are allowed.

Schemas

  • object
    lumens
    integer
    >= 0

    Light intensity measured in lumens.

    +
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    +

    Additional properties are allowed.

  • object
    command
    string

    Whether to turn on or off the light.

    +
      Allowed values:
    • "on"
    • "off"
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    +

    Additional properties are allowed.

  • object
    percentage
    integer
    [ 0 .. 100 ]

    Percentage to which the light should be dimmed to.

    +
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    +

    Additional properties are allowed.

  • sentAt
    string
    format: date-time

    Date and time when the message was sent.

    +
+ + + + + + " +`; + +exports[`Index component should render AsyncAPI v3 document 1`] = ` +" + + + + + Streetlights API 1.0.0 documentation + + + + + + + +
Streetlights API 1.0.0

The Smartylighting Streetlights API allows you to remotely manage the city lights.

+

Check out its awesome features:

+
    +
  • Turn a specific streetlight on/off 🌃
  • +
  • Dim a specific streetlight 😎
  • +
  • Receive real-time information about environmental lighting conditions 📈
  • +
+

Servers

  • mqtt://test.mosquitto.org:{port}/mqttproduction

    Test broker

    +
    object
    port
    required
    string

    Secure connection (TLS) is available through port 8883.

    +
    Default value:"1883"
      Allowed values:
    • "1883"
    • "8883"

Operations

  • RECEIVE smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured

    The topic on which measured values may be produced and consumed.

    +

    Inform about environmental lighting conditions of a particular streetlight.

    This is the description with bold text.

    +

    On multiple lines.

    +
    Operation IDreceiveLightMeasurement

    Available only on servers:

    object
    streetlightId
    required
    string

    The ID of the streetlight.

    +
    object
    object
    const
    my-app-id

    Accepts the following message:

    Light measuredreceiveLightMeasurement.message

    Inform about environmental lighting conditions of a particular streetlight.

    Message IDreceiveLightMeasurement.message
    object
    integer
    >= 0

    Light intensity measured in lumens.

    +
    object
    x-pi
    false
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    +

    Additional properties are allowed.

    object
    my-app-header
    integer
    [ 0 .. 100 ]

    Additional properties are allowed.

    Examples

    {
    +  \\"lumens\\": 0,
    +  \\"sentAt\\": \\"2019-08-24T14:15:22Z\\"
    +}
    +
    +
    This example has been generated automatically.
    {
    +  \\"my-app-header\\": 100
    +}
    +
    +
    This example has been generated automatically.
  • SEND smartylighting/streetlights/1/0/action/{streetlightId}/turn/on

    Operation IDturnOn

    Available only on servers:

    object
    streetlightId
    required
    string

    The ID of the streetlight.

    +
    object
    object
    const
    my-app-id

    Accepts the following message:

    Turn on/offturnOn.message

    Command a particular streetlight to turn the lights on or off.

    Message IDturnOn.message
    object
    string

    Whether to turn on or off the light.

    +
      Allowed values:
    • "on"
    • "off"
    object
    x-pi
    false
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    +

    Additional properties are allowed.

    object
    my-app-header
    integer
    [ 0 .. 100 ]

    Additional properties are allowed.

    Examples

    {
    +  \\"command\\": \\"on\\",
    +  \\"sentAt\\": \\"2019-08-24T14:15:22Z\\"
    +}
    +
    +
    This example has been generated automatically.
    {
    +  \\"my-app-header\\": 100
    +}
    +
    +
    This example has been generated automatically.
  • SEND smartylighting/streetlights/1/0/action/{streetlightId}/turn/off

    Operation IDturnOff

    Available only on servers:

    object
    streetlightId
    required
    string

    The ID of the streetlight.

    +
    object
    object
    const
    my-app-id

    Accepts the following message:

    Turn on/offturnOn.message

    Command a particular streetlight to turn the lights on or off.

    Message IDturnOn.message
    object
    string

    Whether to turn on or off the light.

    +
      Allowed values:
    • "on"
    • "off"
    object
    x-pi
    false
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    +

    Additional properties are allowed.

    object
    my-app-header
    integer
    [ 0 .. 100 ]

    Additional properties are allowed.

    Examples

    {
    +  \\"command\\": \\"on\\",
    +  \\"sentAt\\": \\"2019-08-24T14:15:22Z\\"
    +}
    +
    +
    This example has been generated automatically.
    {
    +  \\"my-app-header\\": 100
    +}
    +
    +
    This example has been generated automatically.
  • SEND smartylighting/streetlights/1/0/action/{streetlightId}/dim

    Operation IDdimLight

    Available only on servers:

    object
    streetlightId
    required
    string

    The ID of the streetlight.

    +
    object
    object
    const
    my-app-id

    Accepts the following message:

    Dim lightdimLight.message

    Command a particular streetlight to dim the lights.

    Message IDdimLight.message
    object
    percentage
    integer
    [ 0 .. 100 ]

    Percentage to which the light should be dimmed to.

    +
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    +

    Additional properties are allowed.

    object
    my-app-header
    integer
    [ 0 .. 100 ]

    Additional properties are allowed.

    Examples

    {
    +  \\"percentage\\": 100,
    +  \\"sentAt\\": \\"2019-08-24T14:15:22Z\\"
    +}
    +
    +
    This example has been generated automatically.
    {
    +  \\"my-app-header\\": 100
    +}
    +
    +
    This example has been generated automatically.
  • SEND some.channel

    this description shows in markdown

    +
    Operation IDsome.channel.subscribe

    Available only on servers:

    Accepts one of the following messages:

    • #0subscribe.message.0
      Message IDsubscribe.message.0
      object
      result
      string
        Examples values:
      • "success"

      Additional properties are allowed.

      Examples

      {
      +  \\"result\\": \\"success\\"
      +}
      +
      +
      This example has been generated automatically.
    • #1subscribe.message.1
      Message IDsubscribe.message.1
      object
        Examples values:
      • {"error":{"errorCode":404,"errorMessage":"Something messed up"}}
      object
      errorCode
      integer
      errorMessage
      string

      Additional properties are allowed.

      Additional properties are allowed.

      Examples

      • #1 Example
        {
        +  \\"error\\": {
        +    \\"errorCode\\": 404,
        +    \\"errorMessage\\": \\"Something messed up\\"
        +  }
        +}
        +
        +

Messages

  • #1Light measuredlightMeasured

    Inform about environmental lighting conditions of a particular streetlight.

    Message IDlightMeasured
    object
    integer
    >= 0

    Light intensity measured in lumens.

    +
    object
    x-pi
    false
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    +

    Additional properties are allowed.

    object
    my-app-header
    integer
    [ 0 .. 100 ]

    Additional properties are allowed.

  • #2Turn on/offturnOnOff

    Command a particular streetlight to turn the lights on or off.

    Message IDturnOnOff
    object
    string

    Whether to turn on or off the light.

    +
      Allowed values:
    • "on"
    • "off"
    object
    x-pi
    false
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    +

    Additional properties are allowed.

    object
    my-app-header
    integer
    [ 0 .. 100 ]

    Additional properties are allowed.

  • #3Dim lightdimLight

    Command a particular streetlight to dim the lights.

    Message IDdimLight
    object
    percentage
    integer
    [ 0 .. 100 ]

    Percentage to which the light should be dimmed to.

    +
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    +

    Additional properties are allowed.

    object
    my-app-header
    integer
    [ 0 .. 100 ]

    Additional properties are allowed.

  • #4successMessage
    Message IDsuccessMessage
    object
    result
    string
      Examples values:
    • "success"

    Additional properties are allowed.

  • #5failureMessage
    Message IDfailureMessage
    object
      Examples values:
    • {"error":{"errorCode":404,"errorMessage":"Something messed up"}}
    object
    errorCode
    integer
    errorMessage
    string

    Additional properties are allowed.

    Additional properties are allowed.

Schemas

  • object
    integer
    >= 0

    Light intensity measured in lumens.

    +
    object
    x-pi
    false
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    +

    Additional properties are allowed.

  • object
    string

    Whether to turn on or off the light.

    +
      Allowed values:
    • "on"
    • "off"
    object
    x-pi
    false
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    +

    Additional properties are allowed.

  • object
    percentage
    integer
    [ 0 .. 100 ]

    Percentage to which the light should be dimmed to.

    +
    sentAt
    string
    format: date-time

    Date and time when the message was sent.

    +

    Additional properties are allowed.

  • sentAt
    string
    format: date-time

    Date and time when the message was sent.

    +
+ + + + " `; diff --git a/test/components/index.test.js b/test/components/index.test.js index 4dce67d55..f183620e1 100644 --- a/test/components/index.test.js +++ b/test/components/index.test.js @@ -1,6 +1,6 @@ import { render } from '@asyncapi/generator-react-sdk'; import { Parser, fromFile } from '@asyncapi/parser'; -import { Index } from '../../components/index'; +import {App, Index} from '../../components/index'; import path from 'path'; const asyncapi_v3_path = path.resolve(__dirname, '../spec/asyncapi_v3.yml'); const asyncapi_v2_path = path.resolve(__dirname, '../spec/asyncapi_v2.yml'); @@ -23,3 +23,21 @@ describe('Index component', () => { expect(actual).toMatchSnapshot(); }); }); + +describe('App component', () => { + it('should render AsyncAPI v3 document', async () => { + const { document } = await fromFile(parser, asyncapi_v3_path).parse(); + expect(document).not.toBeUndefined(); + const result = render(); + const actual = result.trim(); + expect(actual).toMatchSnapshot(); + }); + + it('should render AsyncAPI v2 document', async () => { + const { document } = await fromFile(parser, asyncapi_v2_path).parse(); + expect(document).not.toBeUndefined(); + const result = render(); + const actual = result.trim(); + expect(actual).toMatchSnapshot(); + }); +}); \ No newline at end of file