From bd32e90dab212eef1130882b82b9ac9b7523d4e2 Mon Sep 17 00:00:00 2001 From: James Kachel Date: Wed, 22 Jan 2025 14:59:26 -0600 Subject: [PATCH] Fixes OpenAPI generator check failures (#199) --- .github/workflows/ci.yml | 9 +- frontends/api/src/generated/v0/api.ts | 276 ++++ openapi/specs/v0.yaml | 1951 +++++++++++++------------ sandbox/__init__.py | 0 sandbox/apps.py | 8 + sandbox/urls.py | 21 + sandbox/views.py | 89 ++ scripts/test/openapi_spec_check.sh | 4 +- unified_ecommerce/settings.py | 1 + unified_ecommerce/urls.py | 1 + 10 files changed, 1414 insertions(+), 946 deletions(-) create mode 100644 sandbox/__init__.py create mode 100644 sandbox/apps.py create mode 100644 sandbox/urls.py create mode 100644 sandbox/views.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 368f9478..f74b83a9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,12 +48,19 @@ jobs: python-version: "3.12.1" cache: "poetry" + - uses: actions/setup-node@v4 + with: + node-version: "22" + - name: Validate lockfile run: poetry lock --check - - name: Install dependencies + - name: Install Python dependencies run: poetry install --no-interaction + - name: Install Node dependencies + run: npm install + - name: Lint run: poetry run ruff check --extend-ignore=D1 $(git ls-files '*.py') diff --git a/frontends/api/src/generated/v0/api.ts b/frontends/api/src/generated/v0/api.ts index e9fdeb1f..94ee5c98 100644 --- a/frontends/api/src/generated/v0/api.ts +++ b/frontends/api/src/generated/v0/api.ts @@ -2129,6 +2129,37 @@ export interface ProductRequest { */ image_metadata?: any | null } +/** + * + * @export + * @interface SandboxValues + */ +export interface SandboxValues { + /** + * + * @type {number} + * @memberof SandboxValues + */ + id: number + /** + * + * @type {string} + * @memberof SandboxValues + */ + name: string + /** + * + * @type {number} + * @memberof SandboxValues + */ + age: number + /** + * + * @type {string} + * @memberof SandboxValues + */ + email: string +} /** * Simpler serializer for discounts. * @export @@ -5760,6 +5791,251 @@ export class PaymentsApi extends BaseAPI { } } +/** + * SandboxApi - axios parameter creator + * @export + */ +export const SandboxApiAxiosParamCreator = function ( + configuration?: Configuration, +) { + return { + /** + * Retrieves the list of sandbox values. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + sandboxZenApiList: async ( + options: RawAxiosRequestConfig = {}, + ): Promise => { + const localVarPath = `/api/v0/sandbox/zen/` + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) + let baseOptions + if (configuration) { + baseOptions = configuration.baseOptions + } + + const localVarRequestOptions = { + method: "GET", + ...baseOptions, + ...options, + } + const localVarHeaderParameter = {} as any + const localVarQueryParameter = {} as any + + setSearchParams(localVarUrlObj, localVarQueryParameter) + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {} + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + } + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + } + }, + /** + * Retrieves a single sandbox value. + * @param {number} id + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + sandboxZenApiRetrieve: async ( + id: number, + options: RawAxiosRequestConfig = {}, + ): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists("sandboxZenApiRetrieve", "id", id) + const localVarPath = `/api/v0/sandbox/zen/{id}/`.replace( + `{${"id"}}`, + encodeURIComponent(String(id)), + ) + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) + let baseOptions + if (configuration) { + baseOptions = configuration.baseOptions + } + + const localVarRequestOptions = { + method: "GET", + ...baseOptions, + ...options, + } + const localVarHeaderParameter = {} as any + const localVarQueryParameter = {} as any + + setSearchParams(localVarUrlObj, localVarQueryParameter) + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {} + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + } + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + } + }, + } +} + +/** + * SandboxApi - functional programming interface + * @export + */ +export const SandboxApiFp = function (configuration?: Configuration) { + const localVarAxiosParamCreator = SandboxApiAxiosParamCreator(configuration) + return { + /** + * Retrieves the list of sandbox values. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async sandboxZenApiList( + options?: RawAxiosRequestConfig, + ): Promise< + ( + axios?: AxiosInstance, + basePath?: string, + ) => AxiosPromise> + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.sandboxZenApiList(options) + const index = configuration?.serverIndex ?? 0 + const operationBasePath = + operationServerMap["SandboxApi.sandboxZenApiList"]?.[index]?.url + return (axios, basePath) => + createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration, + )(axios, operationBasePath || basePath) + }, + /** + * Retrieves a single sandbox value. + * @param {number} id + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async sandboxZenApiRetrieve( + id: number, + options?: RawAxiosRequestConfig, + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.sandboxZenApiRetrieve(id, options) + const index = configuration?.serverIndex ?? 0 + const operationBasePath = + operationServerMap["SandboxApi.sandboxZenApiRetrieve"]?.[index]?.url + return (axios, basePath) => + createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration, + )(axios, operationBasePath || basePath) + }, + } +} + +/** + * SandboxApi - factory interface + * @export + */ +export const SandboxApiFactory = function ( + configuration?: Configuration, + basePath?: string, + axios?: AxiosInstance, +) { + const localVarFp = SandboxApiFp(configuration) + return { + /** + * Retrieves the list of sandbox values. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + sandboxZenApiList( + options?: RawAxiosRequestConfig, + ): AxiosPromise> { + return localVarFp + .sandboxZenApiList(options) + .then((request) => request(axios, basePath)) + }, + /** + * Retrieves a single sandbox value. + * @param {SandboxApiSandboxZenApiRetrieveRequest} requestParameters Request parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + sandboxZenApiRetrieve( + requestParameters: SandboxApiSandboxZenApiRetrieveRequest, + options?: RawAxiosRequestConfig, + ): AxiosPromise { + return localVarFp + .sandboxZenApiRetrieve(requestParameters.id, options) + .then((request) => request(axios, basePath)) + }, + } +} + +/** + * Request parameters for sandboxZenApiRetrieve operation in SandboxApi. + * @export + * @interface SandboxApiSandboxZenApiRetrieveRequest + */ +export interface SandboxApiSandboxZenApiRetrieveRequest { + /** + * + * @type {number} + * @memberof SandboxApiSandboxZenApiRetrieve + */ + readonly id: number +} + +/** + * SandboxApi - object-oriented interface + * @export + * @class SandboxApi + * @extends {BaseAPI} + */ +export class SandboxApi extends BaseAPI { + /** + * Retrieves the list of sandbox values. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof SandboxApi + */ + public sandboxZenApiList(options?: RawAxiosRequestConfig) { + return SandboxApiFp(this.configuration) + .sandboxZenApiList(options) + .then((request) => request(this.axios, this.basePath)) + } + + /** + * Retrieves a single sandbox value. + * @param {SandboxApiSandboxZenApiRetrieveRequest} requestParameters Request parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof SandboxApi + */ + public sandboxZenApiRetrieve( + requestParameters: SandboxApiSandboxZenApiRetrieveRequest, + options?: RawAxiosRequestConfig, + ) { + return SandboxApiFp(this.configuration) + .sandboxZenApiRetrieve(requestParameters.id, options) + .then((request) => request(this.axios, this.basePath)) + } +} + /** * UsersApi - axios parameter creator * @export diff --git a/openapi/specs/v0.yaml b/openapi/specs/v0.yaml index aec9176f..1cb57261 100644 --- a/openapi/specs/v0.yaml +++ b/openapi/specs/v0.yaml @@ -9,610 +9,650 @@ paths: operationId: meta_integrated_system_list description: Viewset for IntegratedSystem model. parameters: - - name: limit - required: false - in: query - description: Number of results to return per page. - schema: - type: integer - - name: offset - required: false - in: query - description: The initial index from which to return the results. - schema: - type: integer + - name: limit + required: false + in: query + description: Number of results to return per page. + schema: + type: integer + - name: offset + required: false + in: query + description: The initial index from which to return the results. + schema: + type: integer tags: - - meta + - meta responses: - '200': + "200": content: application/json: schema: - $ref: '#/components/schemas/PaginatedIntegratedSystemList' - description: '' + $ref: "#/components/schemas/PaginatedIntegratedSystemList" + description: "" post: operationId: meta_integrated_system_create description: Viewset for IntegratedSystem model. tags: - - meta + - meta requestBody: content: application/json: schema: - $ref: '#/components/schemas/IntegratedSystemRequest' + $ref: "#/components/schemas/IntegratedSystemRequest" application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/IntegratedSystemRequest' + $ref: "#/components/schemas/IntegratedSystemRequest" multipart/form-data: schema: - $ref: '#/components/schemas/IntegratedSystemRequest' + $ref: "#/components/schemas/IntegratedSystemRequest" required: true responses: - '201': + "201": content: application/json: schema: - $ref: '#/components/schemas/IntegratedSystem' - description: '' + $ref: "#/components/schemas/IntegratedSystem" + description: "" /api/v0/meta/integrated_system/{id}/: get: operationId: meta_integrated_system_retrieve description: Viewset for IntegratedSystem model. parameters: - - in: path - name: id - schema: - type: integer - description: A unique integer value identifying this integrated system. - required: true + - in: path + name: id + schema: + type: integer + description: A unique integer value identifying this integrated system. + required: true tags: - - meta + - meta responses: - '200': + "200": content: application/json: schema: - $ref: '#/components/schemas/IntegratedSystem' - description: '' + $ref: "#/components/schemas/IntegratedSystem" + description: "" put: operationId: meta_integrated_system_update description: Viewset for IntegratedSystem model. parameters: - - in: path - name: id - schema: - type: integer - description: A unique integer value identifying this integrated system. - required: true + - in: path + name: id + schema: + type: integer + description: A unique integer value identifying this integrated system. + required: true tags: - - meta + - meta requestBody: content: application/json: schema: - $ref: '#/components/schemas/IntegratedSystemRequest' + $ref: "#/components/schemas/IntegratedSystemRequest" application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/IntegratedSystemRequest' + $ref: "#/components/schemas/IntegratedSystemRequest" multipart/form-data: schema: - $ref: '#/components/schemas/IntegratedSystemRequest' + $ref: "#/components/schemas/IntegratedSystemRequest" required: true responses: - '200': + "200": content: application/json: schema: - $ref: '#/components/schemas/IntegratedSystem' - description: '' + $ref: "#/components/schemas/IntegratedSystem" + description: "" patch: operationId: meta_integrated_system_partial_update description: Viewset for IntegratedSystem model. parameters: - - in: path - name: id - schema: - type: integer - description: A unique integer value identifying this integrated system. - required: true + - in: path + name: id + schema: + type: integer + description: A unique integer value identifying this integrated system. + required: true tags: - - meta + - meta requestBody: content: application/json: schema: - $ref: '#/components/schemas/PatchedIntegratedSystemRequest' + $ref: "#/components/schemas/PatchedIntegratedSystemRequest" application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/PatchedIntegratedSystemRequest' + $ref: "#/components/schemas/PatchedIntegratedSystemRequest" multipart/form-data: schema: - $ref: '#/components/schemas/PatchedIntegratedSystemRequest' + $ref: "#/components/schemas/PatchedIntegratedSystemRequest" responses: - '200': + "200": content: application/json: schema: - $ref: '#/components/schemas/IntegratedSystem' - description: '' + $ref: "#/components/schemas/IntegratedSystem" + description: "" delete: operationId: meta_integrated_system_destroy description: Viewset for IntegratedSystem model. parameters: - - in: path - name: id - schema: - type: integer - description: A unique integer value identifying this integrated system. - required: true + - in: path + name: id + schema: + type: integer + description: A unique integer value identifying this integrated system. + required: true tags: - - meta + - meta responses: - '204': + "204": description: No response body /api/v0/meta/product/: get: operationId: meta_product_list description: Viewset for Product model. parameters: - - name: limit - required: false - in: query - description: Number of results to return per page. - schema: - type: integer - - in: query - name: name - schema: - type: string - - name: offset - required: false - in: query - description: The initial index from which to return the results. - schema: - type: integer - - in: query - name: system__slug - schema: - type: string + - name: limit + required: false + in: query + description: Number of results to return per page. + schema: + type: integer + - in: query + name: name + schema: + type: string + - name: offset + required: false + in: query + description: The initial index from which to return the results. + schema: + type: integer + - in: query + name: system__slug + schema: + type: string tags: - - meta + - meta responses: - '200': + "200": content: application/json: schema: - $ref: '#/components/schemas/PaginatedProductList' - description: '' + $ref: "#/components/schemas/PaginatedProductList" + description: "" post: operationId: meta_product_create description: Viewset for Product model. tags: - - meta + - meta requestBody: content: application/json: schema: - $ref: '#/components/schemas/ProductRequest' + $ref: "#/components/schemas/ProductRequest" application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/ProductRequest' + $ref: "#/components/schemas/ProductRequest" multipart/form-data: schema: - $ref: '#/components/schemas/ProductRequest' + $ref: "#/components/schemas/ProductRequest" required: true responses: - '201': + "201": content: application/json: schema: - $ref: '#/components/schemas/Product' - description: '' + $ref: "#/components/schemas/Product" + description: "" /api/v0/meta/product/{id}/: get: operationId: meta_product_retrieve description: Viewset for Product model. parameters: - - in: path - name: id - schema: - type: integer - description: A unique integer value identifying this product. - required: true + - in: path + name: id + schema: + type: integer + description: A unique integer value identifying this product. + required: true tags: - - meta + - meta responses: - '200': + "200": content: application/json: schema: - $ref: '#/components/schemas/Product' - description: '' + $ref: "#/components/schemas/Product" + description: "" put: operationId: meta_product_update description: Viewset for Product model. parameters: - - in: path - name: id - schema: - type: integer - description: A unique integer value identifying this product. - required: true + - in: path + name: id + schema: + type: integer + description: A unique integer value identifying this product. + required: true tags: - - meta + - meta requestBody: content: application/json: schema: - $ref: '#/components/schemas/ProductRequest' + $ref: "#/components/schemas/ProductRequest" application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/ProductRequest' + $ref: "#/components/schemas/ProductRequest" multipart/form-data: schema: - $ref: '#/components/schemas/ProductRequest' + $ref: "#/components/schemas/ProductRequest" required: true responses: - '200': + "200": content: application/json: schema: - $ref: '#/components/schemas/Product' - description: '' + $ref: "#/components/schemas/Product" + description: "" patch: operationId: meta_product_partial_update description: Viewset for Product model. parameters: - - in: path - name: id - schema: - type: integer - description: A unique integer value identifying this product. - required: true + - in: path + name: id + schema: + type: integer + description: A unique integer value identifying this product. + required: true tags: - - meta + - meta requestBody: content: application/json: schema: - $ref: '#/components/schemas/PatchedProductRequest' + $ref: "#/components/schemas/PatchedProductRequest" application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/PatchedProductRequest' + $ref: "#/components/schemas/PatchedProductRequest" multipart/form-data: schema: - $ref: '#/components/schemas/PatchedProductRequest' + $ref: "#/components/schemas/PatchedProductRequest" responses: - '200': + "200": content: application/json: schema: - $ref: '#/components/schemas/Product' - description: '' + $ref: "#/components/schemas/Product" + description: "" delete: operationId: meta_product_destroy description: Viewset for Product model. parameters: - - in: path - name: id - schema: - type: integer - description: A unique integer value identifying this product. - required: true + - in: path + name: id + schema: + type: integer + description: A unique integer value identifying this product. + required: true tags: - - meta + - meta responses: - '204': + "204": description: No response body /api/v0/meta/product/preload/{system_slug}/{sku}/: get: operationId: meta_product_preload_retrieve - description: Pre-loads the product metadata for a given SKU, even if the SKU + description: + Pre-loads the product metadata for a given SKU, even if the SKU doesn't exist yet. parameters: - - in: path - name: sku - schema: - type: string - pattern: ^[^/]+$ - required: true - - in: path - name: system_slug - schema: - type: string - pattern: ^[^/]+$ - required: true + - in: path + name: sku + schema: + type: string + pattern: ^[^/]+$ + required: true + - in: path + name: system_slug + schema: + type: string + pattern: ^[^/]+$ + required: true tags: - - meta + - meta responses: - '200': + "200": content: application/json: schema: - $ref: '#/components/schemas/Product' - description: '' + $ref: "#/components/schemas/Product" + description: "" /api/v0/payments/baskets/: get: operationId: payments_baskets_list description: Retrives the current user's baskets, one per system. parameters: - - in: query - name: integrated_system - schema: - type: integer - - name: limit - required: false - in: query - description: Number of results to return per page. - schema: - type: integer - - name: offset - required: false - in: query - description: The initial index from which to return the results. - schema: - type: integer + - in: query + name: integrated_system + schema: + type: integer + - name: limit + required: false + in: query + description: Number of results to return per page. + schema: + type: integer + - name: offset + required: false + in: query + description: The initial index from which to return the results. + schema: + type: integer tags: - - payments + - payments responses: - '200': + "200": content: application/json: schema: - $ref: '#/components/schemas/PaginatedBasketWithProductList' - description: '' + $ref: "#/components/schemas/PaginatedBasketWithProductList" + description: "" /api/v0/payments/baskets/{id}/: get: operationId: payments_baskets_retrieve description: Retrieve a basket for the current user. parameters: - - in: path - name: id - schema: - type: integer - required: true + - in: path + name: id + schema: + type: integer + required: true tags: - - payments + - payments responses: - '200': + "200": content: application/json: schema: - $ref: '#/components/schemas/BasketWithProduct' - description: '' + $ref: "#/components/schemas/BasketWithProduct" + description: "" /api/v0/payments/baskets/add_discount/{system_slug}/: post: operationId: payments_baskets_add_discount_create - description: Creates or updates a basket for the current user, adding the discount + description: + Creates or updates a basket for the current user, adding the discount if valid. parameters: - - in: query - name: discount_code - schema: - type: string - required: true - - in: path - name: system_slug - schema: - type: string - required: true + - in: query + name: discount_code + schema: + type: string + required: true + - in: path + name: system_slug + schema: + type: string + required: true tags: - - payments + - payments responses: - '200': + "200": content: application/json: schema: - $ref: '#/components/schemas/BasketWithProduct' - description: '' + $ref: "#/components/schemas/BasketWithProduct" + description: "" /api/v0/payments/baskets/clear/{system_slug}/: delete: operationId: payments_baskets_clear_destroy description: Clears the basket for the current user. parameters: - - in: path - name: system_slug - schema: - type: string - required: true + - in: path + name: system_slug + schema: + type: string + required: true tags: - - payments + - payments responses: - '204': + "204": description: No response body /api/v0/payments/baskets/create_from_product/{system_slug}/{sku}/: post: operationId: payments_baskets_create_from_product_create - description: Creates or updates a basket for the current user, adding the selected + description: + Creates or updates a basket for the current user, adding the selected product. parameters: - - in: path - name: sku - schema: - type: string - required: true - - in: path - name: system_slug - schema: - type: string - required: true + - in: path + name: sku + schema: + type: string + required: true + - in: path + name: system_slug + schema: + type: string + required: true tags: - - payments + - payments responses: - '200': + "200": content: application/json: schema: - $ref: '#/components/schemas/BasketWithProduct' - description: '' + $ref: "#/components/schemas/BasketWithProduct" + description: "" /api/v0/payments/baskets/create_from_product/{system_slug}/{sku}/{discount_code}/: post: operationId: create_basket_from_product_with_discount - description: Creates or updates a basket for the current user, adding the selected + description: + Creates or updates a basket for the current user, adding the selected product and discount. parameters: - - in: path - name: discount_code - schema: - type: string - required: true - - in: path - name: sku - schema: - type: string - required: true - - in: path - name: system_slug - schema: - type: string - required: true + - in: path + name: discount_code + schema: + type: string + required: true + - in: path + name: sku + schema: + type: string + required: true + - in: path + name: system_slug + schema: + type: string + required: true tags: - - payments + - payments responses: - '200': + "200": content: application/json: schema: - $ref: '#/components/schemas/BasketWithProduct' - description: '' + $ref: "#/components/schemas/BasketWithProduct" + description: "" /api/v0/payments/baskets/create_with_products/: post: operationId: payments_baskets_create_with_products_create - description: Creates or updates a basket for the current user, adding the selected + description: + Creates or updates a basket for the current user, adding the selected product. tags: - - payments + - payments requestBody: content: application/json: schema: - $ref: '#/components/schemas/CreateBasketWithProductsRequest' + $ref: "#/components/schemas/CreateBasketWithProductsRequest" application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/CreateBasketWithProductsRequest' + $ref: "#/components/schemas/CreateBasketWithProductsRequest" multipart/form-data: schema: - $ref: '#/components/schemas/CreateBasketWithProductsRequest' + $ref: "#/components/schemas/CreateBasketWithProductsRequest" required: true responses: - '200': + "200": content: application/json: schema: - $ref: '#/components/schemas/BasketWithProduct' - description: '' + $ref: "#/components/schemas/BasketWithProduct" + description: "" /api/v0/payments/baskets/for_system/{system_slug}/: get: operationId: payments_baskets_for_system_retrieve description: Returns or creates a basket for the current user and system. parameters: - - in: path - name: system_slug - schema: - type: string - required: true + - in: path + name: system_slug + schema: + type: string + required: true tags: - - payments + - payments responses: - '200': + "200": content: application/json: schema: - $ref: '#/components/schemas/BasketWithProduct' - description: '' + $ref: "#/components/schemas/BasketWithProduct" + description: "" /api/v0/payments/checkout/{system_slug}/: post: operationId: payments_checkout_create - description: Generates and returns the form payload for the current basket for + description: + Generates and returns the form payload for the current basket for the specified system, which can be used to start the checkout process. parameters: - - in: path - name: system_slug - schema: - type: string - required: true + - in: path + name: system_slug + schema: + type: string + required: true tags: - - payments + - payments responses: - '200': + "200": content: application/json: schema: - $ref: '#/components/schemas/CyberSourceCheckout' - description: '' + $ref: "#/components/schemas/CyberSourceCheckout" + description: "" /api/v0/payments/discounts/: post: operationId: payments_discounts_create description: Create a discount. tags: - - payments + - payments responses: - '200': + "200": content: application/json: schema: - $ref: '#/components/schemas/Discount' - description: '' + $ref: "#/components/schemas/Discount" + description: "" /api/v0/payments/orders/history/: get: operationId: payments_orders_history_list description: Retrives the current user's completed orders. parameters: - - name: limit - required: false - in: query - description: Number of results to return per page. - schema: - type: integer - - name: offset - required: false - in: query - description: The initial index from which to return the results. - schema: - type: integer + - name: limit + required: false + in: query + description: Number of results to return per page. + schema: + type: integer + - name: offset + required: false + in: query + description: The initial index from which to return the results. + schema: + type: integer tags: - - payments + - payments responses: - '200': + "200": content: application/json: schema: - $ref: '#/components/schemas/PaginatedOrderHistoryList' - description: '' + $ref: "#/components/schemas/PaginatedOrderHistoryList" + description: "" /api/v0/payments/orders/history/{id}/: get: operationId: payments_orders_history_retrieve description: Retrieve a completed order for the current user. parameters: - - in: path - name: id - schema: - type: integer - required: true + - in: path + name: id + schema: + type: integer + required: true tags: - - payments + - payments responses: - '200': + "200": content: application/json: schema: - $ref: '#/components/schemas/OrderHistory' - description: '' + $ref: "#/components/schemas/OrderHistory" + description: "" + /api/v0/sandbox/zen/: + get: + operationId: sandbox_zen_api_list + description: Retrieves the list of sandbox values. + tags: + - sandbox + responses: + "200": + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/sandbox_values" + description: "" + /api/v0/sandbox/zen/{id}/: + get: + operationId: sandbox_zen_api_retrieve + description: Retrieves a single sandbox value. + parameters: + - in: path + name: id + schema: + type: integer + required: true + tags: + - sandbox + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/sandbox_values" + description: "" /api/v0/users/me/: get: operationId: users_me_retrieve description: User retrieve and update viewsets for the current user tags: - - users + - users security: - - {} + - {} responses: - '200': + "200": content: application/json: schema: - $ref: '#/components/schemas/User' - description: '' + $ref: "#/components/schemas/User" + description: "" components: schemas: BasketItemWithProduct: @@ -620,7 +660,7 @@ components: description: Basket item model serializer with product information properties: product: - $ref: '#/components/schemas/Product' + $ref: "#/components/schemas/Product" id: type: integer readOnly: true @@ -644,14 +684,14 @@ components: minimum: 0 discount_applied: allOf: - - $ref: '#/components/schemas/SimpleDiscount' + - $ref: "#/components/schemas/SimpleDiscount" readOnly: true required: - - discount_applied - - discounted_price - - id - - price - - product + - discount_applied + - discounted_price + - id + - price + - product BasketWithProduct: type: object description: Basket model serializer with items and products @@ -662,11 +702,11 @@ components: user: type: integer integrated_system: - $ref: '#/components/schemas/IntegratedSystem' + $ref: "#/components/schemas/IntegratedSystem" basket_items: type: array items: - $ref: '#/components/schemas/BasketItemWithProduct' + $ref: "#/components/schemas/BasketItemWithProduct" subtotal: type: number format: double @@ -678,21 +718,21 @@ components: description: Get the tax for the basket readOnly: true tax_rate: - $ref: '#/components/schemas/TaxRate' + $ref: "#/components/schemas/TaxRate" total_price: type: number format: double description: Get the total price for the basket readOnly: true required: - - basket_items - - id - - integrated_system - - subtotal - - tax - - tax_rate - - total_price - - user + - basket_items + - id + - integrated_system + - subtotal + - tax + - tax_rate + - total_price + - user Company: type: object description: Serializer for companies. @@ -704,259 +744,259 @@ components: type: string maxLength: 255 required: - - id - - name + - id + - name CountryCodeEnum: enum: - - AF - - AX - - AL - - DZ - - AS - - AD - - AO - - AI - - AQ - - AG - - AR - - AM - - AW - - AU - - AT - - AZ - - BS - - BH - - BD - - BB - - BY - - BE - - BZ - - BJ - - BM - - BT - - BO - - BQ - - BA - - BW - - BV - - BR - - IO - - BN - - BG - - BF - - BI - - CV - - KH - - CM - - CA - - KY - - CF - - TD - - CL - - CN - - CX - - CC - - CO - - KM - - CG - - CD - - CK - - CR - - CI - - HR - - CU - - CW - - CY - - CZ - - DK - - DJ - - DM - - DO - - EC - - EG - - SV - - GQ - - ER - - EE - - SZ - - ET - - FK - - FO - - FJ - - FI - - FR - - GF - - PF - - TF - - GA - - GM - - GE - - DE - - GH - - GI - - GR - - GL - - GD - - GP - - GU - - GT - - GG - - GN - - GW - - GY - - HT - - HM - - VA - - HN - - HK - - HU - - IS - - IN - - ID - - IR - - IQ - - IE - - IM - - IL - - IT - - JM - - JP - - JE - - JO - - KZ - - KE - - KI - - KW - - KG - - LA - - LV - - LB - - LS - - LR - - LY - - LI - - LT - - LU - - MO - - MG - - MW - - MY - - MV - - ML - - MT - - MH - - MQ - - MR - - MU - - YT - - MX - - FM - - MD - - MC - - MN - - ME - - MS - - MA - - MZ - - MM - - NA - - NR - - NP - - NL - - NC - - NZ - - NI - - NE - - NG - - NU - - NF - - KP - - MK - - MP - - 'NO' - - OM - - PK - - PW - - PS - - PA - - PG - - PY - - PE - - PH - - PN - - PL - - PT - - PR - - QA - - RE - - RO - - RU - - RW - - BL - - SH - - KN - - LC - - MF - - PM - - VC - - WS - - SM - - ST - - SA - - SN - - RS - - SC - - SL - - SG - - SX - - SK - - SI - - SB - - SO - - ZA - - GS - - KR - - SS - - ES - - LK - - SD - - SR - - SJ - - SE - - CH - - SY - - TW - - TJ - - TZ - - TH - - TL - - TG - - TK - - TO - - TT - - TN - - TR - - TM - - TC - - TV - - UG - - UA - - AE - - GB - - UM - - US - - UY - - UZ - - VU - - VE - - VN - - VG - - VI - - WF - - EH - - YE - - ZM - - ZW + - AF + - AX + - AL + - DZ + - AS + - AD + - AO + - AI + - AQ + - AG + - AR + - AM + - AW + - AU + - AT + - AZ + - BS + - BH + - BD + - BB + - BY + - BE + - BZ + - BJ + - BM + - BT + - BO + - BQ + - BA + - BW + - BV + - BR + - IO + - BN + - BG + - BF + - BI + - CV + - KH + - CM + - CA + - KY + - CF + - TD + - CL + - CN + - CX + - CC + - CO + - KM + - CG + - CD + - CK + - CR + - CI + - HR + - CU + - CW + - CY + - CZ + - DK + - DJ + - DM + - DO + - EC + - EG + - SV + - GQ + - ER + - EE + - SZ + - ET + - FK + - FO + - FJ + - FI + - FR + - GF + - PF + - TF + - GA + - GM + - GE + - DE + - GH + - GI + - GR + - GL + - GD + - GP + - GU + - GT + - GG + - GN + - GW + - GY + - HT + - HM + - VA + - HN + - HK + - HU + - IS + - IN + - ID + - IR + - IQ + - IE + - IM + - IL + - IT + - JM + - JP + - JE + - JO + - KZ + - KE + - KI + - KW + - KG + - LA + - LV + - LB + - LS + - LR + - LY + - LI + - LT + - LU + - MO + - MG + - MW + - MY + - MV + - ML + - MT + - MH + - MQ + - MR + - MU + - YT + - MX + - FM + - MD + - MC + - MN + - ME + - MS + - MA + - MZ + - MM + - NA + - NR + - NP + - NL + - NC + - NZ + - NI + - NE + - NG + - NU + - NF + - KP + - MK + - MP + - "NO" + - OM + - PK + - PW + - PS + - PA + - PG + - PY + - PE + - PH + - PN + - PL + - PT + - PR + - QA + - RE + - RO + - RU + - RW + - BL + - SH + - KN + - LC + - MF + - PM + - VC + - WS + - SM + - ST + - SA + - SN + - RS + - SC + - SL + - SG + - SX + - SK + - SI + - SB + - SO + - ZA + - GS + - KR + - SS + - ES + - LK + - SD + - SR + - SJ + - SE + - CH + - SY + - TW + - TJ + - TZ + - TH + - TL + - TG + - TK + - TO + - TT + - TN + - TR + - TM + - TC + - TV + - UG + - UA + - AE + - GB + - UM + - US + - UY + - UZ + - VU + - VE + - VN + - VG + - VI + - WF + - EH + - YE + - ZM + - ZW type: string description: |- * `AF` - Afghanistan @@ -1209,255 +1249,255 @@ components: * `ZM` - Zambia * `ZW` - Zimbabwe x-enum-descriptions: - - Afghanistan - - Åland Islands - - Albania - - Algeria - - American Samoa - - Andorra - - Angola - - Anguilla - - Antarctica - - Antigua and Barbuda - - Argentina - - Armenia - - Aruba - - Australia - - Austria - - Azerbaijan - - Bahamas - - Bahrain - - Bangladesh - - Barbados - - Belarus - - Belgium - - Belize - - Benin - - Bermuda - - Bhutan - - Bolivia - - Bonaire, Sint Eustatius and Saba - - Bosnia and Herzegovina - - Botswana - - Bouvet Island - - Brazil - - British Indian Ocean Territory - - Brunei - - Bulgaria - - Burkina Faso - - Burundi - - Cabo Verde - - Cambodia - - Cameroon - - Canada - - Cayman Islands - - Central African Republic - - Chad - - Chile - - China - - Christmas Island - - Cocos (Keeling) Islands - - Colombia - - Comoros - - Congo - - Congo (the Democratic Republic of the) - - Cook Islands - - Costa Rica - - Côte d'Ivoire - - Croatia - - Cuba - - Curaçao - - Cyprus - - Czechia - - Denmark - - Djibouti - - Dominica - - Dominican Republic - - Ecuador - - Egypt - - El Salvador - - Equatorial Guinea - - Eritrea - - Estonia - - Eswatini - - Ethiopia - - Falkland Islands (Malvinas) - - Faroe Islands - - Fiji - - Finland - - France - - French Guiana - - French Polynesia - - French Southern Territories - - Gabon - - Gambia - - Georgia - - Germany - - Ghana - - Gibraltar - - Greece - - Greenland - - Grenada - - Guadeloupe - - Guam - - Guatemala - - Guernsey - - Guinea - - Guinea-Bissau - - Guyana - - Haiti - - Heard Island and McDonald Islands - - Holy See - - Honduras - - Hong Kong - - Hungary - - Iceland - - India - - Indonesia - - Iran - - Iraq - - Ireland - - Isle of Man - - Israel - - Italy - - Jamaica - - Japan - - Jersey - - Jordan - - Kazakhstan - - Kenya - - Kiribati - - Kuwait - - Kyrgyzstan - - Laos - - Latvia - - Lebanon - - Lesotho - - Liberia - - Libya - - Liechtenstein - - Lithuania - - Luxembourg - - Macao - - Madagascar - - Malawi - - Malaysia - - Maldives - - Mali - - Malta - - Marshall Islands - - Martinique - - Mauritania - - Mauritius - - Mayotte - - Mexico - - Micronesia - - Moldova - - Monaco - - Mongolia - - Montenegro - - Montserrat - - Morocco - - Mozambique - - Myanmar - - Namibia - - Nauru - - Nepal - - Netherlands - - New Caledonia - - New Zealand - - Nicaragua - - Niger - - Nigeria - - Niue - - Norfolk Island - - North Korea - - North Macedonia - - Northern Mariana Islands - - Norway - - Oman - - Pakistan - - Palau - - Palestine, State of - - Panama - - Papua New Guinea - - Paraguay - - Peru - - Philippines - - Pitcairn - - Poland - - Portugal - - Puerto Rico - - Qatar - - Réunion - - Romania - - Russia - - Rwanda - - Saint Barthélemy - - Saint Helena, Ascension and Tristan da Cunha - - Saint Kitts and Nevis - - Saint Lucia - - Saint Martin (French part) - - Saint Pierre and Miquelon - - Saint Vincent and the Grenadines - - Samoa - - San Marino - - Sao Tome and Principe - - Saudi Arabia - - Senegal - - Serbia - - Seychelles - - Sierra Leone - - Singapore - - Sint Maarten (Dutch part) - - Slovakia - - Slovenia - - Solomon Islands - - Somalia - - South Africa - - South Georgia and the South Sandwich Islands - - South Korea - - South Sudan - - Spain - - Sri Lanka - - Sudan - - Suriname - - Svalbard and Jan Mayen - - Sweden - - Switzerland - - Syria - - Taiwan - - Tajikistan - - Tanzania - - Thailand - - Timor-Leste - - Togo - - Tokelau - - Tonga - - Trinidad and Tobago - - Tunisia - - Türkiye - - Turkmenistan - - Turks and Caicos Islands - - Tuvalu - - Uganda - - Ukraine - - United Arab Emirates - - United Kingdom - - United States Minor Outlying Islands - - United States of America - - Uruguay - - Uzbekistan - - Vanuatu - - Venezuela - - Vietnam - - Virgin Islands (British) - - Virgin Islands (U.S.) - - Wallis and Futuna - - Western Sahara - - Yemen - - Zambia - - Zimbabwe + - Afghanistan + - Åland Islands + - Albania + - Algeria + - American Samoa + - Andorra + - Angola + - Anguilla + - Antarctica + - Antigua and Barbuda + - Argentina + - Armenia + - Aruba + - Australia + - Austria + - Azerbaijan + - Bahamas + - Bahrain + - Bangladesh + - Barbados + - Belarus + - Belgium + - Belize + - Benin + - Bermuda + - Bhutan + - Bolivia + - Bonaire, Sint Eustatius and Saba + - Bosnia and Herzegovina + - Botswana + - Bouvet Island + - Brazil + - British Indian Ocean Territory + - Brunei + - Bulgaria + - Burkina Faso + - Burundi + - Cabo Verde + - Cambodia + - Cameroon + - Canada + - Cayman Islands + - Central African Republic + - Chad + - Chile + - China + - Christmas Island + - Cocos (Keeling) Islands + - Colombia + - Comoros + - Congo + - Congo (the Democratic Republic of the) + - Cook Islands + - Costa Rica + - Côte d'Ivoire + - Croatia + - Cuba + - Curaçao + - Cyprus + - Czechia + - Denmark + - Djibouti + - Dominica + - Dominican Republic + - Ecuador + - Egypt + - El Salvador + - Equatorial Guinea + - Eritrea + - Estonia + - Eswatini + - Ethiopia + - Falkland Islands (Malvinas) + - Faroe Islands + - Fiji + - Finland + - France + - French Guiana + - French Polynesia + - French Southern Territories + - Gabon + - Gambia + - Georgia + - Germany + - Ghana + - Gibraltar + - Greece + - Greenland + - Grenada + - Guadeloupe + - Guam + - Guatemala + - Guernsey + - Guinea + - Guinea-Bissau + - Guyana + - Haiti + - Heard Island and McDonald Islands + - Holy See + - Honduras + - Hong Kong + - Hungary + - Iceland + - India + - Indonesia + - Iran + - Iraq + - Ireland + - Isle of Man + - Israel + - Italy + - Jamaica + - Japan + - Jersey + - Jordan + - Kazakhstan + - Kenya + - Kiribati + - Kuwait + - Kyrgyzstan + - Laos + - Latvia + - Lebanon + - Lesotho + - Liberia + - Libya + - Liechtenstein + - Lithuania + - Luxembourg + - Macao + - Madagascar + - Malawi + - Malaysia + - Maldives + - Mali + - Malta + - Marshall Islands + - Martinique + - Mauritania + - Mauritius + - Mayotte + - Mexico + - Micronesia + - Moldova + - Monaco + - Mongolia + - Montenegro + - Montserrat + - Morocco + - Mozambique + - Myanmar + - Namibia + - Nauru + - Nepal + - Netherlands + - New Caledonia + - New Zealand + - Nicaragua + - Niger + - Nigeria + - Niue + - Norfolk Island + - North Korea + - North Macedonia + - Northern Mariana Islands + - Norway + - Oman + - Pakistan + - Palau + - Palestine, State of + - Panama + - Papua New Guinea + - Paraguay + - Peru + - Philippines + - Pitcairn + - Poland + - Portugal + - Puerto Rico + - Qatar + - Réunion + - Romania + - Russia + - Rwanda + - Saint Barthélemy + - Saint Helena, Ascension and Tristan da Cunha + - Saint Kitts and Nevis + - Saint Lucia + - Saint Martin (French part) + - Saint Pierre and Miquelon + - Saint Vincent and the Grenadines + - Samoa + - San Marino + - Sao Tome and Principe + - Saudi Arabia + - Senegal + - Serbia + - Seychelles + - Sierra Leone + - Singapore + - Sint Maarten (Dutch part) + - Slovakia + - Slovenia + - Solomon Islands + - Somalia + - South Africa + - South Georgia and the South Sandwich Islands + - South Korea + - South Sudan + - Spain + - Sri Lanka + - Sudan + - Suriname + - Svalbard and Jan Mayen + - Sweden + - Switzerland + - Syria + - Taiwan + - Tajikistan + - Tanzania + - Thailand + - Timor-Leste + - Togo + - Tokelau + - Tonga + - Trinidad and Tobago + - Tunisia + - Türkiye + - Turkmenistan + - Turks and Caicos Islands + - Tuvalu + - Uganda + - Ukraine + - United Arab Emirates + - United Kingdom + - United States Minor Outlying Islands + - United States of America + - Uruguay + - Uzbekistan + - Vanuatu + - Venezuela + - Vietnam + - Virgin Islands (British) + - Virgin Islands (U.S.) + - Wallis and Futuna + - Western Sahara + - Yemen + - Zambia + - Zimbabwe CreateBasketWithProductsRequest: type: object description: Serializer for creating a basket with products. (For OpenAPI spec.) @@ -1468,17 +1508,17 @@ components: skus: type: array items: - $ref: '#/components/schemas/CreateBasketWithProductsSkuRequest' + $ref: "#/components/schemas/CreateBasketWithProductsSkuRequest" checkout: type: boolean discount_code: type: string minLength: 1 required: - - checkout - - discount_code - - skus - - system_slug + - checkout + - discount_code + - skus + - system_slug CreateBasketWithProductsSkuRequest: type: object description: Defines the schema for a SKU in the CreateBasketWithProductsSerializer. @@ -1490,11 +1530,12 @@ components: type: integer minimum: 1 required: - - quantity - - sku + - quantity + - sku CyberSourceCheckout: type: object - description: Really basic serializer for the payload that we need to send to + description: + Really basic serializer for the payload that we need to send to CyberSource. properties: payload: @@ -1505,9 +1546,9 @@ components: method: type: string required: - - method - - payload - - url + - method + - payload + - url Discount: type: object description: Serializer for discounts. @@ -1525,8 +1566,8 @@ components: payment_type: nullable: true oneOf: - - $ref: '#/components/schemas/PaymentTypeEnum' - - $ref: '#/components/schemas/NullEnum' + - $ref: "#/components/schemas/PaymentTypeEnum" + - $ref: "#/components/schemas/NullEnum" max_redemptions: type: integer maximum: 2147483647 @@ -1536,46 +1577,48 @@ components: type: string format: date-time nullable: true - description: If set, this discount code will not be redeemable before this + description: + If set, this discount code will not be redeemable before this date. expiration_date: type: string format: date-time nullable: true - description: If set, this discount code will not be redeemable after this + description: + If set, this discount code will not be redeemable after this date. integrated_system: - $ref: '#/components/schemas/IntegratedSystem' + $ref: "#/components/schemas/IntegratedSystem" product: - $ref: '#/components/schemas/Product' + $ref: "#/components/schemas/Product" assigned_users: type: array items: - $ref: '#/components/schemas/User' + $ref: "#/components/schemas/User" company: - $ref: '#/components/schemas/Company' + $ref: "#/components/schemas/Company" required: - - amount - - assigned_users - - company - - discount_code - - id - - integrated_system - - product + - amount + - assigned_users + - company + - discount_code + - id + - integrated_system + - product DiscountTypeEnum: enum: - - percent-off - - dollars-off - - fixed-price + - percent-off + - dollars-off + - fixed-price type: string description: |- * `percent-off` - percent-off * `dollars-off` - dollars-off * `fixed-price` - fixed-price x-enum-descriptions: - - percent-off - - dollars-off - - fixed-price + - percent-off + - dollars-off + - fixed-price IntegratedSystem: type: object description: Serializer for IntegratedSystem model. @@ -1593,8 +1636,8 @@ components: description: type: string required: - - id - - name + - id + - name IntegratedSystemRequest: type: object description: Serializer for IntegratedSystem model. @@ -1610,7 +1653,7 @@ components: description: type: string required: - - name + - name Line: type: object description: Serializes a line item for an order. @@ -1635,17 +1678,17 @@ components: format: decimal pattern: ^-?\d{0,7}(?:\.\d{0,2})?$ product: - $ref: '#/components/schemas/Product' + $ref: "#/components/schemas/Product" required: - - id - - item_description - - product - - quantity - - total_price - - unit_price + - id + - item_description + - product + - quantity + - total_price + - unit_price NullEnum: enum: - - null + - null OrderHistory: type: object description: Serializer for order history. @@ -1654,7 +1697,7 @@ components: type: integer readOnly: true state: - $ref: '#/components/schemas/StateEnum' + $ref: "#/components/schemas/StateEnum" reference_number: type: string maxLength: 255 @@ -1667,7 +1710,7 @@ components: lines: type: array items: - $ref: '#/components/schemas/Line' + $ref: "#/components/schemas/Line" created_on: type: string format: date-time @@ -1677,17 +1720,17 @@ components: format: date-time readOnly: true required: - - created_on - - id - - lines - - purchaser - - total_price_paid - - updated_on + - created_on + - id + - lines + - purchaser + - total_price_paid + - updated_on PaginatedBasketWithProductList: type: object required: - - count - - results + - count + - results properties: count: type: integer @@ -1705,12 +1748,12 @@ components: results: type: array items: - $ref: '#/components/schemas/BasketWithProduct' + $ref: "#/components/schemas/BasketWithProduct" PaginatedIntegratedSystemList: type: object required: - - count - - results + - count + - results properties: count: type: integer @@ -1728,12 +1771,12 @@ components: results: type: array items: - $ref: '#/components/schemas/IntegratedSystem' + $ref: "#/components/schemas/IntegratedSystem" PaginatedOrderHistoryList: type: object required: - - count - - results + - count + - results properties: count: type: integer @@ -1751,12 +1794,12 @@ components: results: type: array items: - $ref: '#/components/schemas/OrderHistory' + $ref: "#/components/schemas/OrderHistory" PaginatedProductList: type: object required: - - count - - results + - count + - results properties: count: type: integer @@ -1774,7 +1817,7 @@ components: results: type: array items: - $ref: '#/components/schemas/Product' + $ref: "#/components/schemas/Product" PatchedIntegratedSystemRequest: type: object description: Serializer for IntegratedSystem model. @@ -1820,18 +1863,19 @@ components: description: Price (decimal to two places) image_metadata: nullable: true - description: Image metadata including URL, alt text, and description (in + description: + Image metadata including URL, alt text, and description (in JSON). PaymentTypeEnum: enum: - - marketing - - sales - - financial-assistance - - customer-support - - staff - - legacy - - credit_card - - purchase_order + - marketing + - sales + - financial-assistance + - customer-support + - staff + - legacy + - credit_card + - purchase_order type: string description: |- * `marketing` - marketing @@ -1843,14 +1887,14 @@ components: * `credit_card` - credit_card * `purchase_order` - purchase_order x-enum-descriptions: - - marketing - - sales - - financial-assistance - - customer-support - - staff - - legacy - - credit_card - - purchase_order + - marketing + - sales + - financial-assistance + - customer-support + - staff + - legacy + - credit_card + - purchase_order Product: type: object description: Serializer for Product model. @@ -1885,16 +1929,17 @@ components: readOnly: true image_metadata: nullable: true - description: Image metadata including URL, alt text, and description (in + description: + Image metadata including URL, alt text, and description (in JSON). required: - - deleted_by_cascade - - description - - id - - name - - price - - sku - - system + - deleted_by_cascade + - description + - id + - name + - price + - sku + - system ProductRequest: type: object description: Serializer for Product model. @@ -1926,14 +1971,15 @@ components: description: Price (decimal to two places) image_metadata: nullable: true - description: Image metadata including URL, alt text, and description (in + description: + Image metadata including URL, alt text, and description (in JSON). required: - - description - - name - - price - - sku - - system + - description + - name + - price + - sku + - system SimpleDiscount: type: object description: Simpler serializer for discounts. @@ -1949,7 +1995,7 @@ components: format: decimal pattern: ^-?\d{0,18}(?:\.\d{0,2})?$ discount_type: - $ref: '#/components/schemas/DiscountTypeEnum' + $ref: "#/components/schemas/DiscountTypeEnum" formatted_discount_amount: type: string description: |- @@ -1958,20 +2004,20 @@ components: This quantizes percent discounts to whole numbers. This is probably fine. readOnly: true required: - - amount - - discount_code - - discount_type - - formatted_discount_amount - - id + - amount + - discount_code + - discount_type + - formatted_discount_amount + - id StateEnum: enum: - - pending - - fulfilled - - canceled - - refunded - - declined - - errored - - review + - pending + - fulfilled + - canceled + - refunded + - declined + - errored + - review type: string description: |- * `pending` - Pending @@ -1982,13 +2028,13 @@ components: * `errored` - Errored * `review` - Review x-enum-descriptions: - - Pending - - Fulfilled - - Canceled - - Refunded - - Declined - - Errored - - Review + - Pending + - Fulfilled + - Canceled + - Refunded + - Declined + - Errored + - Review TaxRate: type: object description: TaxRate model serializer @@ -1997,7 +2043,7 @@ components: type: integer readOnly: true country_code: - $ref: '#/components/schemas/CountryCodeEnum' + $ref: "#/components/schemas/CountryCodeEnum" tax_rate: type: string format: decimal @@ -2006,8 +2052,8 @@ components: type: string maxLength: 100 required: - - country_code - - id + - country_code + - id User: type: object description: Serializer for User model. @@ -2017,7 +2063,8 @@ components: readOnly: true username: type: string - description: Required. 150 characters or fewer. Letters, digits and @/./+/-/_ + description: + Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only. pattern: ^[\w.@+-]+$ maxLength: 150 @@ -2033,5 +2080,21 @@ components: type: string maxLength: 150 required: - - id - - username + - id + - username + sandbox_values: + type: object + properties: + id: + type: integer + name: + type: string + age: + type: integer + email: + type: string + required: + - age + - email + - id + - name diff --git a/sandbox/__init__.py b/sandbox/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/sandbox/apps.py b/sandbox/apps.py new file mode 100644 index 00000000..0e533591 --- /dev/null +++ b/sandbox/apps.py @@ -0,0 +1,8 @@ +"""Setup for the sandbox app.""" + +from django.apps import AppConfig + + +class SandboxConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "sandbox" diff --git a/sandbox/urls.py b/sandbox/urls.py new file mode 100644 index 00000000..30b126ed --- /dev/null +++ b/sandbox/urls.py @@ -0,0 +1,21 @@ +# ruff: noqa: ERA001 +"""Routes for the sandbox app.""" + +from django.urls import include, re_path +from rest_framework import routers + +from sandbox.views import SandboxViewSet + +v0_router = routers.DefaultRouter() + +v0_router.register( + r"^sandbox/zen", + SandboxViewSet, + basename="sandbox_zen_api", +) + +app_name = "v0" +urlpatterns = [ + re_path("^api/v0/", include((v0_router.urls, "v0"))), + # re_path("^api/v0/sandbox/return_nothing", return_nothing), +] diff --git a/sandbox/views.py b/sandbox/views.py new file mode 100644 index 00000000..ac0e81ff --- /dev/null +++ b/sandbox/views.py @@ -0,0 +1,89 @@ +# ruff: noqa: ERA001 +"""Views for the sandbox app.""" + +from drf_spectacular.openapi import OpenApiParameter, OpenApiTypes +from drf_spectacular.utils import extend_schema, inline_serializer +from rest_framework import status +from rest_framework.response import Response +from rest_framework.serializers import CharField, IntegerField +from rest_framework.viewsets import ViewSet + +SANDBOX_SERIALIZER = inline_serializer( + name="sandbox_values", + fields={ + "id": IntegerField(), + "name": CharField(), + "age": IntegerField(), + "email": CharField(), + }, +) + + +class SandboxViewSet(ViewSet): + """ + Sandbox viewset. + + This is a simple viewset that's just here to kick the OpenAPI generation + code into generating some new stuff, so we can trigger the formatting errors + that I'm trying to fix. + """ + + dataset = [ + { + "id": 1, + "name": "Alice", + "age": 25, + "email": "", + }, + { + "id": 2, + "name": "Bob", + "age": 30, + "email": "", + }, + ] + + @extend_schema( + description=("Retrieves the list of sandbox values."), + methods=["GET"], + request=None, + responses=SANDBOX_SERIALIZER, + operation_id="sandbox_zen_api_list", + ) + def list(self, request): # noqa: ARG002 + """List all items.""" + return Response(self.dataset) + + @extend_schema( + description=("Retrieves a single sandbox value."), + methods=["GET"], + request=None, + responses=SANDBOX_SERIALIZER, + operation_id="sandbox_zen_api_retrieve", + parameters=[ + OpenApiParameter("id", OpenApiTypes.INT, OpenApiParameter.PATH), + ], + ) + def retrieve(self, request, id: int): # noqa: A002, ARG002 + """Retrieve a single item.""" + try: + item = next(item for item in self.dataset if item["id"] == int(id)) + except StopIteration: + return Response(status=status.HTTP_404_NOT_FOUND) + return Response(item) + + +# Uncomment this stuff to test! + +# @extend_schema( +# description=("Retrieves the list of sandbox values."), +# methods=["GET"], +# request=None, +# responses=SANDBOX_SERIALIZER, +# operation_id="sandbox_zen_api_list", +# ) +# @api_view(["GET"]) +# def return_nothing(request): +# """Return nothing.""" + +# return Response() diff --git a/scripts/test/openapi_spec_check.sh b/scripts/test/openapi_spec_check.sh index 08bae8c3..b03f73bf 100755 --- a/scripts/test/openapi_spec_check.sh +++ b/scripts/test/openapi_spec_check.sh @@ -1,12 +1,14 @@ #!/usr/bin/env bash set -eo pipefail -TMPDIR="$(mktemp -d)" +TMPDIR="$(mktemp -p . -d)" SPECS_DIR=./openapi/specs/ ./manage.py generate_openapi_spec \ --directory=$TMPDIR --fail-on-warn +npx prettier --write $TMPDIR + diff $TMPDIR $SPECS_DIR if [ $? -eq 0 ]; then diff --git a/unified_ecommerce/settings.py b/unified_ecommerce/settings.py index 26db1866..49aab535 100644 --- a/unified_ecommerce/settings.py +++ b/unified_ecommerce/settings.py @@ -104,6 +104,7 @@ "cart", "mitol.payment_gateway.apps.PaymentGatewayApp", "openapi", + "sandbox", ] MIDDLEWARE = [ diff --git a/unified_ecommerce/urls.py b/unified_ecommerce/urls.py index 7c564ff2..a45354ad 100644 --- a/unified_ecommerce/urls.py +++ b/unified_ecommerce/urls.py @@ -41,6 +41,7 @@ re_path(r"", include("payments.urls")), re_path(r"", include("system_meta.urls")), re_path(r"", include("users.urls")), + re_path(r"", include("sandbox.urls")), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) if settings.DEBUG: