Skip to content

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

Open
@ZodsPlan

Description

@ZodsPlan

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions