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

MessagingServiceSid and statusCallback should be nullable to be consistent with twilio npm module #94

Open
ZodsPlan opened this issue May 27, 2023 · 1 comment

Comments

@ZodsPlan
Copy link

ZodsPlan commented May 27, 2023

Issue Summary

The OAI specification for twilio API seems to be incorrect, or at least the nodejs implementation of twilio api may have an inconsistency. https://github.com/twilio/twilio-oai/blob/main/spec/yaml/twilio_api_v2010.yaml#L17395 - should be nullable to be consistent with the typings for twilio api. the OAI specification requires messagingServiceSid whereas the api does not. The same goes for statusCallback; it should be nullable to be consistent with twilio api.

Steps to Reproduce

  1. install latest version of twilio via npm
  2. npm install -g prism-cli
  3. run prism mock https://github.com/twilio/twilio-oai/blob/main/spec/yaml/twilio_api_v2010.yaml
  4. create a custom http client

Code Snippet

import twilio from 'twilio';

class PrismHttpClient extends RequestClient {
    request<TData>(opts: RequestClient.RequestOptions<TData>): Promise<Response<TData>> {
        opts.uri = opts.uri.replace(/^https:\/\/.*?\.twilio\.com/, 'http://127.0.0.1:4010'); // note: default prism port is 4010, so change if needed
        return super.request(opts);
    }
}

Then...

const opts ={httpClient: new PrismHttpClient()};
const client = smsClient(sid, token, opts);
const response = await client.messages
        .create({
            body: text,
            from,
            to,
            statusCallback: 'http://localhost:9000/status' // any url where twilio should post message status - this should be nullable also but it is not according to the twilio oai
        });

Then run that code.

Exception/Log

[5:49:29 PM] ›     [VALIDATOR] ⚠  warning   Request did not pass the validation rules
[5:49:29 PM] ›     [VALIDATOR] ✖  error     Request body property MessagingServiceSid must NOT have fewer than 34 characters
[5:49:29 PM] ›     [VALIDATOR] ✖  error     Request body property MessagingServiceSid must match pattern "^MG[0-9a-fA-F]{32}$"
[5:49:29 PM] › [HTTP SERVER] post /2010-04-01/Accounts/AC6d4932eed0ae3cf5d9af4f071965be8f/Messages.json ✖  error     Request terminated with error: https://stoplight.io/prism/errors#UNPROCESSABLE_ENTITY: Invalid request

Technical details:

  • twilio-oai version: latest
  • twilio version: 4.11.1
  • open version:
@twilio-dx
Copy link
Collaborator

Ahoy! Thank you for opening your first issue here! If this request is regarding troubleshooting your application, please reach out to the support team via https://support.twilio.com.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants