oas: [5/n] improve oas schemas (#9066)

Improve oas schemas [5/n]
This commit is contained in:
Shahed Nasser
2024-09-10 12:03:18 +00:00
committed by GitHub
parent a944226025
commit 5eafa5a184
15 changed files with 124 additions and 77 deletions
@@ -1,7 +1,7 @@
/** /**
* @schema AdminFulfillmentProvider * @schema AdminFulfillmentProvider
* type: object * type: object
* description: The fulfillment provider's fulfillment providers. * description: The shipping option's provider.
* x-schemaName: AdminFulfillmentProvider * x-schemaName: AdminFulfillmentProvider
* *
*/ */
@@ -1,7 +1,7 @@
/** /**
* @schema AdminFulfillmentProviderListResponse * @schema AdminFulfillmentProviderListResponse
* type: object * type: object
* description: SUMMARY * description: The paginated list of fulfillment providers.
* x-schemaName: AdminFulfillmentProviderListResponse * x-schemaName: AdminFulfillmentProviderListResponse
* required: * required:
* - limit * - limit
@@ -12,18 +12,18 @@
* limit: * limit:
* type: number * type: number
* title: limit * title: limit
* description: The fulfillment provider's limit. * description: The maximum number of items returned.
* offset: * offset:
* type: number * type: number
* title: offset * title: offset
* description: The fulfillment provider's offset. * description: The number of items skipped before retrieving the returned items.
* count: * count:
* type: number * type: number
* title: count * title: count
* description: The fulfillment provider's count. * description: The total count of items.
* fulfillment_providers: * fulfillment_providers:
* type: array * type: array
* description: The fulfillment provider's fulfillment providers. * description: The list of fulfillment providers.
* items: * items:
* $ref: "#/components/schemas/AdminFulfillmentProvider" * $ref: "#/components/schemas/AdminFulfillmentProvider"
* *
@@ -1,7 +1,7 @@
/** /**
* @schema AdminFulfillmentResponse * @schema AdminFulfillmentResponse
* type: object * type: object
* description: SUMMARY * description: A fulfillment's details.
* x-schemaName: AdminFulfillmentResponse * x-schemaName: AdminFulfillmentResponse
* required: * required:
* - fulfillment * - fulfillment
@@ -1,7 +1,7 @@
/** /**
* @schema AdminFulfillmentSetDeleteResponse * @schema AdminFulfillmentSetDeleteResponse
* type: object * type: object
* description: SUMMARY * description: The deletion details.
* x-schemaName: AdminFulfillmentSetDeleteResponse * x-schemaName: AdminFulfillmentSetDeleteResponse
* required: * required:
* - id * - id
@@ -20,7 +20,7 @@
* deleted: * deleted:
* type: boolean * type: boolean
* title: deleted * title: deleted
* description: Whether the Fulfillment Set was deleted. * description: Whether the fulfillment set was deleted.
* *
*/ */
@@ -1,8 +1,61 @@
/** /**
* @schema AdminGeoZone * @schema AdminGeoZone
* type: object * type: object
* description: The geo zone's geo zones. * description: The geo zone's details.
* x-schemaName: AdminGeoZone * x-schemaName: AdminGeoZone
* required:
* - id
* - type
* - country_code
* - province_code
* - city
* - postal_expression
* - created_at
* - updated_at
* - deleted_at
* properties:
* id:
* type: string
* title: id
* description: The geo zone's ID.
* type:
* type: string
* description: The geo zone's type.
* enum:
* - country
* - province
* - city
* - zip
* country_code:
* type: string
* title: country_code
* description: The geo zone's country code.
* province_code:
* type: string
* title: province_code
* description: The geo zone's province code.
* city:
* type: string
* title: city
* description: The geo zone's city.
* postal_expression:
* type: object
* description: The geo zone's postal expression.
* created_at:
* type: string
* format: date-time
* title: created_at
* description: The date the geo zone was created.
* updated_at:
* type: string
* format: date-time
* title: updated_at
* description: The date the geo zone was update.
* deleted_at:
* type: string
* format: date-time
* title: deleted_at
* description: The date the geo zone was deleted.
* *
*/ */
@@ -1,7 +1,7 @@
/** /**
* @schema AdminImportProductRequest * @schema AdminImportProductRequest
* type: object * type: object
* description: SUMMARY * description: The import's details.
* x-schemaName: AdminImportProductRequest * x-schemaName: AdminImportProductRequest
* required: * required:
* - file * - file
@@ -1,7 +1,7 @@
/** /**
* @schema AdminImportProductResponse * @schema AdminImportProductResponse
* type: object * type: object
* description: SUMMARY * description: The import process's details.
* x-schemaName: AdminImportProductResponse * x-schemaName: AdminImportProductResponse
* required: * required:
* - transaction_id * - transaction_id
@@ -10,10 +10,10 @@
* transaction_id: * transaction_id:
* type: string * type: string
* title: transaction_id * title: transaction_id
* description: The product's transaction id. * description: The ID of the workflow execution's transaction. This is useful to confirm the import using the `/admin/products/:transaction-id/import` API route.
* summary: * summary:
* type: object * type: object
* description: The product's summary. * description: The import's summary.
* required: * required:
* - toCreate * - toCreate
* - toUpdate * - toUpdate
@@ -21,11 +21,11 @@
* toCreate: * toCreate:
* type: number * type: number
* title: toCreate * title: toCreate
* description: The summary's tocreate. * description: The number of products that will be created by this import.
* toUpdate: * toUpdate:
* type: number * type: number
* title: toUpdate * title: toUpdate
* description: The summary's toupdate. * description: The number of products that will be updated by this import.
* *
*/ */
@@ -14,7 +14,7 @@
* sku: * sku:
* type: string * type: string
* title: sku * title: sku
* description: The inventory item's sku. * description: The inventory item's SKU.
* origin_country: * origin_country:
* type: string * type: string
* title: origin_country * title: origin_country
@@ -22,15 +22,15 @@
* hs_code: * hs_code:
* type: string * type: string
* title: hs_code * title: hs_code
* description: The inventory item's hs code. * description: The inventory item's HS code.
* requires_shipping: * requires_shipping:
* type: boolean * type: boolean
* title: requires_shipping * title: requires_shipping
* description: The inventory item's requires shipping. * description: Whether the inventory item requires shipping.
* mid_code: * mid_code:
* type: string * type: string
* title: mid_code * title: mid_code
* description: The inventory item's mid code. * description: The inventory item's MID code.
* material: * material:
* type: string * type: string
* title: material * title: material
@@ -62,13 +62,13 @@
* thumbnail: * thumbnail:
* type: string * type: string
* title: thumbnail * title: thumbnail
* description: The inventory item's thumbnail. * description: The URL of the inventory item's thumbnail.
* metadata: * metadata:
* type: object * type: object
* description: The inventory item's metadata. * description: The inventory item's metadata, can hold custom key-value pairs.
* location_levels: * location_levels:
* type: array * type: array
* description: The inventory item's location levels. * description: The inventory item's associated inventory levels.
* items: * items:
* $ref: "#/components/schemas/AdminInventoryLevel" * $ref: "#/components/schemas/AdminInventoryLevel"
* *
@@ -1,7 +1,7 @@
/** /**
* @schema AdminInventoryItemResponse * @schema AdminInventoryItemResponse
* type: object * type: object
* description: SUMMARY * description: The inventory item's details.
* x-schemaName: AdminInventoryItemResponse * x-schemaName: AdminInventoryItemResponse
* required: * required:
* - inventory_item * - inventory_item
@@ -1,7 +1,7 @@
/** /**
* @schema AdminInventoryLevel * @schema AdminInventoryLevel
* type: object * type: object
* description: The location level's location levels. * description: The inventory level's details.
* x-schemaName: AdminInventoryLevel * x-schemaName: AdminInventoryLevel
* required: * required:
* - id * - id
@@ -22,60 +22,51 @@
* id: * id:
* type: string * type: string
* title: id * title: id
* description: The location level's ID. * description: The inventory level's ID.
* created_at:
* type: string
* format: date-time
* title: created_at
* description: The location level's created at.
* updated_at:
* type: string
* format: date-time
* title: updated_at
* description: The location level's updated at.
* deleted_at:
* type: string
* format: date-time
* title: deleted_at
* description: The location level's deleted at.
* inventory_item_id: * inventory_item_id:
* type: string * type: string
* title: inventory_item_id * title: inventory_item_id
* description: The location level's inventory item id. * description: The ID of the inventory item this level belongs to.
* location_id: * location_id:
* type: string * type: string
* title: location_id * title: location_id
* description: The location level's location id. * description: The ID of the stock location this level belongs to.
* stocked_quantity: * stocked_quantity:
* type: number * type: number
* title: stocked_quantity * title: stocked_quantity
* description: The location level's stocked quantity. * description: The quantity of the associated inventory item stocked in the associated stock location.
* raw_stocked_quantity:
* type: object
* description: The location level's raw stocked quantity.
* reserved_quantity: * reserved_quantity:
* type: number * type: number
* title: reserved_quantity * title: reserved_quantity
* description: The location level's reserved quantity. * description: The reserved quantity of the associated inventory item stocked in the associated stock location.
* raw_reserved_quantity:
* type: object
* description: The location level's raw reserved quantity.
* incoming_quantity: * incoming_quantity:
* type: number * type: number
* title: incoming_quantity * title: incoming_quantity
* description: The location level's incoming quantity. * description: The incoming quantity of the associated inventory item stocked in the associated stock location.
* raw_incoming_quantity:
* type: object
* description: The location level's raw incoming quantity.
* metadata: * metadata:
* type: object * type: object
* description: The location level's metadata. * description: The location level's metadata, can hold custom key-value pairs.
* inventory_item: * inventory_item:
* $ref: "#/components/schemas/AdminInventoryItem" * $ref: "#/components/schemas/AdminInventoryItem"
* available_quantity: * available_quantity:
* type: number * type: number
* title: available_quantity * title: available_quantity
* description: The location level's available quantity. * description: The quantity available for order of the associated inventory item in the associated stock location.
* created_at:
* type: string
* format: date-time
* title: created_at
* description: The date the inventory level was created.
* updated_at:
* type: string
* format: date-time
* title: updated_at
* description: The date the inventory level was updated.
* deleted_at:
* type: string
* format: date-time
* title: deleted_at
* description: The date the inventory level was deleted.
* *
*/ */
@@ -21,7 +21,7 @@
* accepted: * accepted:
* type: boolean * type: boolean
* title: accepted * title: accepted
* description: The invite's accepted. * description: Whether the invite has been accepted.
* token: * token:
* type: string * type: string
* title: token * title: token
@@ -29,21 +29,21 @@
* expires_at: * expires_at:
* type: string * type: string
* title: expires_at * title: expires_at
* description: The invite's expires at. * description: The invite's expiry date.
* format: date-time * format: date-time
* metadata: * metadata:
* type: object * type: object
* description: The invite's metadata. * description: The invite's metadata, can hold custom key-value pairs.
* created_at: * created_at:
* type: string * type: string
* format: date-time * format: date-time
* title: created_at * title: created_at
* description: The invite's created at. * description: The date the invite was created.
* updated_at: * updated_at:
* type: string * type: string
* format: date-time * format: date-time
* title: updated_at * title: updated_at
* description: The invite's updated at. * description: The date the invite was updated.
* *
*/ */
@@ -1,7 +1,7 @@
/** /**
* @schema AdminInviteResponse * @schema AdminInviteResponse
* type: object * type: object
* description: SUMMARY * description: The invite's details.
* x-schemaName: AdminInviteResponse * x-schemaName: AdminInviteResponse
* required: * required:
* - invite * - invite
@@ -1,7 +1,7 @@
/** /**
* @schema AdminLinkPriceListProducts * @schema AdminLinkPriceListProducts
* type: object * type: object
* description: The removal details. * description: The products removal details.
* properties: * properties:
* remove: * remove:
* type: array * type: array
@@ -18,51 +18,54 @@
* to: * to:
* type: string * type: string
* title: to * title: to
* description: The notification's to. * description: Where to send the notification to. For example, if `channel` is `email`, this can be an email number.
* channel: * channel:
* type: string * type: string
* title: channel * title: channel
* description: The notification's channel. * description: Through which channel is the notification sent through.
* example: email
* template: * template:
* type: string * type: string
* title: template * title: template
* description: The notification's template. * description: The ID of the template in a third-party service used as the notification's shape.
* data: * data:
* type: object * type: object
* description: The notification's data. * description: Data payload to send with the notification.
* trigger_type: * trigger_type:
* type: string * type: string
* title: trigger_type * title: trigger_type
* description: The notification's trigger type. * description: What triggered this notification.
* example: order.created
* resource_id: * resource_id:
* type: string * type: string
* title: resource_id * title: resource_id
* description: The notification's resource id. * description: The ID of the associated resource. For example, if the notification was triggered because an order was created, this would be the ID of the order.
* resource_type: * resource_type:
* type: string * type: string
* title: resource_type * title: resource_type
* description: The notification's resource type. * description: The type of the resource that triggered the notification.
* example: order
* receiver_id: * receiver_id:
* type: string * type: string
* title: receiver_id * title: receiver_id
* description: The notification's receiver id. * description: The ID of the user or customer that's receiving this notification.
* original_notification_id: * original_notification_id:
* type: string * type: string
* title: original_notification_id * title: original_notification_id
* description: The notification's original notification id. * description: The ID of the original notification, if this notification is resent.
* external_id: * external_id:
* type: string * type: string
* title: external_id * title: external_id
* description: The notification's external id. * description: The ID of the notification in an external or third-party system.
* provider_id: * provider_id:
* type: string * type: string
* title: provider_id * title: provider_id
* description: The notification's provider id. * description: The ID of the provider used to send the notification.
* created_at: * created_at:
* type: string * type: string
* format: date-time * format: date-time
* title: created_at * title: created_at
* description: The notification's created at. * description: The date the notification was created.
* *
*/ */
@@ -55,7 +55,7 @@ type AuthRequests = {
class OasKindGenerator extends FunctionKindGenerator { class OasKindGenerator extends FunctionKindGenerator {
public name = "oas" public name = "oas"
protected allowedKinds: SyntaxKind[] = [ts.SyntaxKind.FunctionDeclaration] protected allowedKinds: SyntaxKind[] = [ts.SyntaxKind.FunctionDeclaration]
private MAX_LEVEL = 4 private MAX_LEVEL = 5
readonly REQUEST_TYPE_NAMES = [ readonly REQUEST_TYPE_NAMES = [
"MedusaRequest", "MedusaRequest",
"RequestWithContext", "RequestWithContext",