jovotech / jovo-framework

🔈 The React for Voice and Chat: Build Apps for Alexa, Messenger, Instagram, the Web, and more
https://www.jovo.tech
Apache License 2.0
1.68k stars 309 forks source link

:bug: Fix alexa HtmlRequest validation #1605

Closed sadlowskij closed 8 months ago

sadlowskij commented 10 months ago

Proposed Changes

Implementing a Alexa.Presentation.HTML.Start directive resulted in a validation error from jovo as is.

If using a directive like this:

return await this.$send({
      message: 'some text',
      listen: undefined,

      platforms: {
        alexa: {
          nativeResponse: {
            response: {
              shouldEndSession: undefined,
              directives: [
                {
                  type: 'Alexa.Presentation.HTML.Start',
                  data: {
                    arbitraryDataKey1: 'Initial start up information',
                  },
                  request: {
                    uri: 'https://www.jovo.tech/',
                    method: 'GET',
                  },
                  configuration: {
                    timeoutInSeconds: 300,
                  },
                },
              ],
            },
          },
        },
      },
    });

leads to an error like this:

ValidationErrors:
 - platforms.alexa.nativeResponse.response.directives.0.request.uri: uri must be a data uri format
 - platforms.alexa.nativeResponse.response.directives.0.request.methods: methods must be equal to GET
 - platforms.alexa.nativeResponse.response.directives.0.request.uri: uri must be a data uri format
 - platforms.alexa.nativeResponse.response.directives.0.request.methods: methods must be equal to GET

According to the docs, it should be method instead of methods. Also it should be able to validate a standard Url, I assume the DataURI validator was put there by accident? Let me know if I'm missing something

Types of Changes

Checklist