Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
276 changes: 276 additions & 0 deletions examples/test_spec/twilio_allOf_v1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,276 @@
openapi: 3.1.0
info:
title: AllOf Test Service
description: Test specification for various allOf scenarios
version: 1.0.0
contact:
name: 'AllOf Test Service'
license:
name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0.html
x-twilio:
apiStandards: v1.0
servers:
- url: https://allof.test.com
paths:
/v1/basic-allof:
post:
operationId: CreateBasicAllOf
summary: Test basic allOf with multiple schemas
requestBody:
required: true
content:
application/json:
schema:
allOf:
- type: object
required: [ id ]
properties:
id:
type: string
example: "123"
- type: object
required: [ name ]
properties:
name:
type: string
example: "Test Entity"
- type: object
properties:
timestamp:
type: string
format: date-time
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/BasicAllOf'

/v1/nested-allof:
post:
operationId: CreateNestedAllOf
summary: Test nested allOf
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/NestedAllOf'
responses:
'200':
description: Success

/v1/allof-with-refs:
post:
operationId: CreateAllOfWithRefs
summary: Test allOf with schema references
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/AllOfWithRefs'
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/AllOfWithRefs'

/v1/allof-inline-and-ref:
post:
operationId: CreateMixedAllOf
summary: Test allOf mixing inline schemas and refs
requestBody:
required: true
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/BaseEntity'
- type: object
required: [ specificField ]
properties:
specificField:
type: string
extraData:
type: object
responses:
'200':
description: Success

/v1/allof-with-oneof:
post:
operationId: CreateAllOfWithOneOf
summary: Test allOf combined with oneOf
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/AllOfWithOneOf'
responses:
'200':
description: Success

components:
schemas:
# Basic allOf with refs
BasicAllOf:
allOf:
- $ref: '#/components/schemas/Identifiable'
- $ref: '#/components/schemas/Nameable'
- $ref: '#/components/schemas/Timestamped'

# Nested allOf
NestedAllOf:
allOf:
- type: object
properties:
outerField:
type: string
- allOf:
- $ref: '#/components/schemas/BaseEntity'
- type: object
properties:
nestedField:
type: string

# AllOf with multiple schema refs
AllOfWithRefs:
allOf:
- $ref: '#/components/schemas/BaseEntity'
- $ref: '#/components/schemas/Auditable'
- $ref: '#/components/schemas/Versioned'

# AllOf combined with oneOf
AllOfWithOneOf:
allOf:
- type: object
required: [ entityType ]
properties:
entityType:
type: string
commonField:
type: string
- oneOf:
- $ref: '#/components/schemas/TypeA'
- $ref: '#/components/schemas/TypeB'

# AllOf with additionalProperties
AllOfWithAdditionalProps:
allOf:
- $ref: '#/components/schemas/BaseEntity'
- type: object
properties:
knownField:
type: string
additionalProperties:
type: string

# AllOf with discriminator
AllOfWithDiscriminator:
allOf:
- type: object
required: [ objectType ]
properties:
objectType:
type: string
discriminator:
propertyName: objectType
mapping:
cat: '#/components/schemas/Cat'
dog: '#/components/schemas/Dog'
- oneOf:
- $ref: '#/components/schemas/Cat'
- $ref: '#/components/schemas/Dog'

# Base schemas
Identifiable:
type: object
required: [ id ]
properties:
id:
type: string

Nameable:
type: object
required: [ name ]
properties:
name:
type: string

Timestamped:
type: object
properties:
createdAt:
type: string
format: date-time
updatedAt:
type: string
format: date-time

BaseEntity:
type: object
required: [ id, createdAt ]
properties:
id:
type: string
createdAt:
type: string
format: date-time

Auditable:
type: object
properties:
createdBy:
type: string
modifiedBy:
type: string

Versioned:
type: object
properties:
version:
type: integer

TypeA:
type: object
required: [ fieldA ]
properties:
fieldA:
type: string
dataA:
type: integer

TypeB:
type: object
required: [ fieldB ]
properties:
fieldB:
type: boolean
dataB:
type: array
items:
type: string

Cat:
type: object
properties:
objectType:
type: string
enum: [cat]
meow:
type: boolean

Dog:
type: object
properties:
objectType:
type: string
enum: [dog]
bark:
type: boolean
3 changes: 2 additions & 1 deletion src/main/resources/twilio-php/context.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ class {{apiName}}Context extends InstanceContext
Version $version{{#requiredPathParams}},
${{#lambda.camelcase}}{{baseName}}{{/lambda.camelcase}}{{/requiredPathParams}}
) {
parent::__construct($version);
{{^isApiV1}}parent::__construct($version);{{/isApiV1}}{{#isApiV1}}$apiV1Version = new ApiV1Version($version->getDomain(), $version->version);
parent::__construct($apiV1Version);{{/isApiV1}}

// Path Solution
$this->solution = [{{#requiredPathParams}}
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/twilio-php/imports.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use Twilio\Options;
use Twilio\Stream;
use Twilio\Values;
use Twilio\Version;
use Twilio\ApiV1Version;
use Twilio\InstanceContext;
use Twilio\Deserialize;
use Twilio\Serialize;
Expand All @@ -14,4 +15,4 @@ use Twilio\Rest\{{domainName}}\{{apiVersionClass}}\{{parent}}List;
{{/metaProperties.listImportProperties}}
{{#metaProperties.contextImportProperties}}
use Twilio\Rest\{{domainName}}\{{apiVersionClass}}\{{parent}}List;
{{/metaProperties.contextImportProperties}}
{{/metaProperties.contextImportProperties}}
3 changes: 2 additions & 1 deletion src/main/resources/twilio-php/instance.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class {{apiName}}Instance extends InstanceResource
*/
public function __construct(Version $version, array $payload{{#requiredPathParams}}{{#vendorExtensions.x-is-parent-param}}, {{{dataType}}} ${{#lambda.camelcase}}{{baseName}}{{/lambda.camelcase}}{{/vendorExtensions.x-is-parent-param}}{{^vendorExtensions.x-is-parent-param}}, ?{{{dataType}}} ${{#lambda.camelcase}}{{baseName}}{{/lambda.camelcase}} = null{{/vendorExtensions.x-is-parent-param}}{{/requiredPathParams}})
{
parent::__construct($version);
{{^isApiV1}}parent::__construct($version);{{/isApiV1}}{{#isApiV1}}$apiV1Version = new ApiV1Version($version->getDomain(), $version->version);
parent::__construct($apiV1Version);{{/isApiV1}}

{{#responseModels.0}}
// Marshaled Properties
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/twilio-php/list.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class {{apiName}}List extends ListResource
Version $version{{#requiredPathParams}}{{#vendorExtensions.x-is-parent-param}},
{{{dataType}}} ${{#lambda.camelcase}}{{baseName}}{{/lambda.camelcase}}{{/vendorExtensions.x-is-parent-param}}{{/requiredPathParams}}
) {
parent::__construct($version);
{{^isApiV1}}parent::__construct($version);{{/isApiV1}}{{#isApiV1}}$apiV1Version = new ApiV1Version($version->getDomain(), $version->version);
parent::__construct($apiV1Version);{{/isApiV1}}

// Path Solution
$this->solution = [{{#requiredPathParams}}{{#vendorExtensions.x-is-parent-param}}
Expand Down
6 changes: 4 additions & 2 deletions src/main/resources/twilio-php/page.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ namespace Twilio\Rest\{{domainName}}\{{version}}{{namespaceSubPart}};

use Twilio\Http\Response;
use Twilio\Page;{{#isApiV1}}
use Twilio\TokenPaginationPage;{{/isApiV1}}
use Twilio\TokenPaginationPage;
use Twilio\ApiV1Version;{{/isApiV1}}
use Twilio\Version;

class {{apiName}}Page extends {{#isApiV1}}TokenPaginationPage{{/isApiV1}}{{^isApiV1}}Page{{/isApiV1}}
Expand All @@ -17,7 +18,8 @@ class {{apiName}}Page extends {{#isApiV1}}TokenPaginationPage{{/isApiV1}}{{^isAp
*/
public function __construct(Version $version, Response $response, array $solution)
{
parent::__construct($version, $response);
{{^isApiV1}}parent::__construct($version, $response);{{/isApiV1}}{{#isApiV1}}$apiV1Version = new ApiV1Version($version->getDomain(), $version->version);
parent::__construct($apiV1Version, $response);{{/isApiV1}}

// Path Solution
$this->solution = $solution;
Expand Down
Loading