WIP: Formalize and implement deck API
This commit is contained in:
parent
165429710a
commit
3790d98153
3 changed files with 84 additions and 0 deletions
8
postgres/001-deck-cards.sql
Normal file
8
postgres/001-deck-cards.sql
Normal file
|
@ -0,0 +1,8 @@
|
|||
DROP TABLE IF EXISTS "deck_cards";
|
||||
CREATE TABLE "deck_cards"(
|
||||
"deck_id" INTEGER NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"set_code" TEXT,
|
||||
"collector_number" TEXT,
|
||||
"foil" BOOLEAN
|
||||
)
|
|
@ -111,6 +111,14 @@ class CardCopy:
|
|||
condition: typing.Optional[str] = None
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
class CardConstraint:
|
||||
name: str
|
||||
set_code: typing.Optional[str] = None
|
||||
collector_number: typing.Optional[str] = None
|
||||
language: typing.Optional[str] = None
|
||||
foil: typing.Optional[str] = None
|
||||
|
||||
@dataclasses.dataclass
|
||||
class DeckCard:
|
||||
card: Card
|
||||
|
|
|
@ -21,6 +21,9 @@ tags:
|
|||
- name: Card Copy
|
||||
description: >-
|
||||
<SchemaDefinition schemaRef="#/components/schemas/copy" />
|
||||
- name: Deck
|
||||
description: >-
|
||||
<SchemaDefinition schemaRef="#/components/schemas/deck" />
|
||||
- name: Collection Statistics
|
||||
description: >-
|
||||
<SchemaDefinition schemaRef="#/components/schemas/collection_statistics" />
|
||||
|
@ -31,10 +34,12 @@ x-tagGroups:
|
|||
- name: Operations
|
||||
tags:
|
||||
- Collection
|
||||
- Decks
|
||||
- name: Models
|
||||
tags:
|
||||
- Card
|
||||
- Card Copy
|
||||
- Deck
|
||||
- Collection Statistics
|
||||
paths:
|
||||
/api:
|
||||
|
@ -195,6 +200,38 @@ paths:
|
|||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/collection_statistics'
|
||||
/api/decks:
|
||||
post:
|
||||
summary: Create deck
|
||||
tags:
|
||||
- Decks
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/card_constraint'
|
||||
text/csv:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/card_constraint'
|
||||
example: |-
|
||||
Name,Quantity,Set Code,Collector Number
|
||||
"Sol Ring",1,CMR,472
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
example: |-
|
||||
1 Sol Ring (CMR) 472
|
||||
responses:
|
||||
'200':
|
||||
description: Deck created
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/deck'
|
||||
components:
|
||||
schemas:
|
||||
uuid: &uuid
|
||||
|
@ -371,6 +408,37 @@ components:
|
|||
description: >-
|
||||
A free-form description of the condition of the card.
|
||||
example: 'Lightly played'
|
||||
card_constraint:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
set_code:
|
||||
type: string
|
||||
collector_number:
|
||||
type: string
|
||||
language:
|
||||
type: string
|
||||
foil:
|
||||
type: boolean
|
||||
required:
|
||||
- name
|
||||
deck_card:
|
||||
type: object
|
||||
properties:
|
||||
constraint:
|
||||
$ref: '#/components/schemas/card_constraint'
|
||||
best_match:
|
||||
$ref: '#/components/schemas/card'
|
||||
deck:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
cards:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/deck_card'
|
||||
collection_statistics:
|
||||
type: object
|
||||
description: >-
|
||||
|
|
Loading…
Reference in a new issue