diff --git a/openapi/main.tsp b/openapi/main.tsp index 3e051e0..3e40caf 100644 --- a/openapi/main.tsp +++ b/openapi/main.tsp @@ -15,7 +15,7 @@ namespace PartnerAPI { page?: Page; }, ): { - data: Partner[]; + data: PartnerResource[]; meta: { pagination: { current_page: int32; @@ -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 { @@ -64,7 +82,6 @@ namespace PartnerAPI { model Filter { flooring_materials?: int64[]; - location?: Location; } @@ -76,4 +93,9 @@ namespace PartnerAPI { @maxValue(100) size?: int32; } -} \ No newline at end of file + + model ResourceIdentifier { + type: string; + id: string; + } +} diff --git a/public/openapi.yaml b/public/openapi.yaml index 9dcb509..310dbeb 100644 --- a/public/openapi.yaml +++ b/public/openapi.yaml @@ -20,7 +20,7 @@ paths: data: type: array items: - $ref: '#/components/schemas/Partner' + $ref: '#/components/schemas/PartnerResource' meta: type: object properties: @@ -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: @@ -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: @@ -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: @@ -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