From d52d9fb31e55736bfa5260dba3f45cd2e2658e6a Mon Sep 17 00:00:00 2001 From: James Kachel Date: Thu, 23 Jan 2025 09:38:10 -0600 Subject: [PATCH] Remove the sandbox test app (#201) --- frontends/api/src/generated/v0/api.ts | 276 -------------------------- openapi/specs/v0.yaml | 50 ----- sandbox/__init__.py | 0 sandbox/apps.py | 8 - sandbox/urls.py | 21 -- sandbox/views.py | 89 --------- unified_ecommerce/settings.py | 1 - unified_ecommerce/urls.py | 1 - 8 files changed, 446 deletions(-) delete mode 100644 sandbox/__init__.py delete mode 100644 sandbox/apps.py delete mode 100644 sandbox/urls.py delete mode 100644 sandbox/views.py diff --git a/frontends/api/src/generated/v0/api.ts b/frontends/api/src/generated/v0/api.ts index 3e90b933..447d1563 100644 --- a/frontends/api/src/generated/v0/api.ts +++ b/frontends/api/src/generated/v0/api.ts @@ -2259,37 +2259,6 @@ export interface ProductRequest { */ details_url?: string } -/** - * - * @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 @@ -6717,251 +6686,6 @@ 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 2dfecd48..4ebb50b1 100644 --- a/openapi/specs/v0.yaml +++ b/openapi/specs/v0.yaml @@ -750,40 +750,6 @@ paths: schema: $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 @@ -2312,19 +2278,3 @@ components: required: - 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 deleted file mode 100644 index e69de29b..00000000 diff --git a/sandbox/apps.py b/sandbox/apps.py deleted file mode 100644 index 0e533591..00000000 --- a/sandbox/apps.py +++ /dev/null @@ -1,8 +0,0 @@ -"""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 deleted file mode 100644 index 30b126ed..00000000 --- a/sandbox/urls.py +++ /dev/null @@ -1,21 +0,0 @@ -# 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 deleted file mode 100644 index ac0e81ff..00000000 --- a/sandbox/views.py +++ /dev/null @@ -1,89 +0,0 @@ -# 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/unified_ecommerce/settings.py b/unified_ecommerce/settings.py index 49aab535..26db1866 100644 --- a/unified_ecommerce/settings.py +++ b/unified_ecommerce/settings.py @@ -104,7 +104,6 @@ "cart", "mitol.payment_gateway.apps.PaymentGatewayApp", "openapi", - "sandbox", ] MIDDLEWARE = [ diff --git a/unified_ecommerce/urls.py b/unified_ecommerce/urls.py index a45354ad..7c564ff2 100644 --- a/unified_ecommerce/urls.py +++ b/unified_ecommerce/urls.py @@ -41,7 +41,6 @@ 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: