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
42 changes: 32 additions & 10 deletions openapi/main.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace PartnerAPI {
page?: Page;
},
): {
data: Partner[];
data: PartnerResource[];
meta: {
pagination: {
current_page: int32;
Expand All @@ -30,26 +30,44 @@ namespace PartnerAPI {
@route("/partners/{id}")
@summary("Retrieve partner details by ID")
op getPartner(@path id: string): {
data: Partner;
included: (Address | FlooringMaterial)[];
data: PartnerResource;
included: (AddressResource | FlooringMaterialResource)[];
};

model Partner {
model PartnerResource {
type: string;
id: string;
attributes: PartnerAttributes;
relationships?: {
address: { data: ResourceIdentifier };
flooring_materials: { data: ResourceIdentifier[] };
};
links: {
self: string;
};
}

model PartnerAttributes {
full_name: string;
operating_radius: float;
rating: string;
distance?: float;
}

model Address {
model AddressResource {
type: string;
id: string;
location: Location;
attributes: {
location: Location;
};
}

model FlooringMaterial {
model FlooringMaterialResource {
type: string;
id: string;
name: string;
attributes: {
name: string;
};
}

model Location {
Expand All @@ -64,7 +82,6 @@ namespace PartnerAPI {

model Filter {
flooring_materials?: int64[];

location?: Location;
}

Expand All @@ -76,4 +93,9 @@ namespace PartnerAPI {
@maxValue(100)
size?: int32;
}
}

model ResourceIdentifier {
type: string;
id: string;
}
}
98 changes: 82 additions & 16 deletions public/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ paths:
data:
type: array
items:
$ref: '#/components/schemas/Partner'
$ref: '#/components/schemas/PartnerResource'
meta:
type: object
properties:
Expand Down Expand Up @@ -79,28 +79,36 @@ paths:
type: object
properties:
data:
$ref: '#/components/schemas/Partner'
$ref: '#/components/schemas/PartnerResource'
included:
type: array
items:
anyOf:
- $ref: '#/components/schemas/Address'
- $ref: '#/components/schemas/FlooringMaterial'
- $ref: '#/components/schemas/AddressResource'
- $ref: '#/components/schemas/FlooringMaterialResource'
required:
- data
- included
components:
schemas:
Address:
AddressResource:
type: object
required:
- type
- id
- location
- attributes
properties:
type:
type: string
id:
type: string
location:
$ref: '#/components/schemas/Location'
attributes:
type: object
properties:
location:
$ref: '#/components/schemas/Location'
required:
- location
Filter:
type: object
properties:
Expand All @@ -111,16 +119,24 @@ components:
format: int64
location:
$ref: '#/components/schemas/Location'
FlooringMaterial:
FlooringMaterialResource:
type: object
required:
- type
- id
- name
- attributes
properties:
id:
type:
type: string
name:
id:
type: string
attributes:
type: object
properties:
name:
type: string
required:
- name
Location:
type: object
required:
Expand All @@ -147,16 +163,13 @@ components:
format: int32
minimum: 1
maximum: 100
Partner:
PartnerAttributes:
type: object
required:
- id
- full_name
- operating_radius
- rating
properties:
id:
type: string
full_name:
type: string
operating_radius:
Expand All @@ -165,3 +178,56 @@ components:
type: string
distance:
type: number
PartnerResource:
type: object
required:
- type
- id
- attributes
- links
properties:
type:
type: string
id:
type: string
attributes:
$ref: '#/components/schemas/PartnerAttributes'
relationships:
type: object
properties:
address:
type: object
properties:
data:
$ref: '#/components/schemas/ResourceIdentifier'
required:
- data
flooring_materials:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/ResourceIdentifier'
required:
- data
required:
- address
- flooring_materials
links:
type: object
properties:
self:
type: string
required:
- self
ResourceIdentifier:
type: object
required:
- type
- id
properties:
type:
type: string
id:
type: string