Skip to content

Commit

Permalink
Improve Response and Property types
Browse files Browse the repository at this point in the history
  • Loading branch information
kainpets committed Jul 2, 2024
1 parent 6c64813 commit 3d5a42e
Showing 1 changed file with 51 additions and 7 deletions.
58 changes: 51 additions & 7 deletions src/lib/blueprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,61 @@ interface Request {
parameters: Parameter[]
}

interface Response {
type Response = VoidResponse | ResourceResponse | ResourceListResponse

interface BaseResponse {
description: string
responseType: 'resource' | 'resource_list' | 'void'
responseKey: string | null
resourceType: string | null
}

interface Property {
interface VoidResponse extends BaseResponse {
responseType: 'void'
}

interface ResourceResponse extends BaseResponse {
responseType: 'resource'
responseKey: string
resourceType: string
}

interface ResourceListResponse extends BaseResponse {
responseType: 'resource_list'
responseKey: string
resourceType: string
}

type Property =
| StringProperty
| EnumProperty
| RecordProperty
| ListProperty
| ObjectProperty

interface BaseProperty {
name: string
type: 'string' | 'enum' | 'record' | 'list' | 'object'
properties: Property[] | null
}

interface StringProperty extends BaseProperty {
type: 'string'
}

interface EnumProperty extends BaseProperty {
type: 'enum'
values: string[]
}

interface RecordProperty extends BaseProperty {
type: 'record'
properties: Property[]
}

interface ListProperty extends BaseProperty {
type: 'list'
items: Property
}

interface ObjectProperty extends BaseProperty {
type: 'object'
properties: Property[]
}

type Method = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'
Expand Down

0 comments on commit 3d5a42e

Please sign in to comment.