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
|
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
|
@dataclasses.dataclass
|
||||||
class DeckCard:
|
class DeckCard:
|
||||||
card: Card
|
card: Card
|
||||||
|
|
|
@ -21,6 +21,9 @@ tags:
|
||||||
- name: Card Copy
|
- name: Card Copy
|
||||||
description: >-
|
description: >-
|
||||||
<SchemaDefinition schemaRef="#/components/schemas/copy" />
|
<SchemaDefinition schemaRef="#/components/schemas/copy" />
|
||||||
|
- name: Deck
|
||||||
|
description: >-
|
||||||
|
<SchemaDefinition schemaRef="#/components/schemas/deck" />
|
||||||
- name: Collection Statistics
|
- name: Collection Statistics
|
||||||
description: >-
|
description: >-
|
||||||
<SchemaDefinition schemaRef="#/components/schemas/collection_statistics" />
|
<SchemaDefinition schemaRef="#/components/schemas/collection_statistics" />
|
||||||
|
@ -31,10 +34,12 @@ x-tagGroups:
|
||||||
- name: Operations
|
- name: Operations
|
||||||
tags:
|
tags:
|
||||||
- Collection
|
- Collection
|
||||||
|
- Decks
|
||||||
- name: Models
|
- name: Models
|
||||||
tags:
|
tags:
|
||||||
- Card
|
- Card
|
||||||
- Card Copy
|
- Card Copy
|
||||||
|
- Deck
|
||||||
- Collection Statistics
|
- Collection Statistics
|
||||||
paths:
|
paths:
|
||||||
/api:
|
/api:
|
||||||
|
@ -195,6 +200,38 @@ paths:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/collection_statistics'
|
$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:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
uuid: &uuid
|
uuid: &uuid
|
||||||
|
@ -371,6 +408,37 @@ components:
|
||||||
description: >-
|
description: >-
|
||||||
A free-form description of the condition of the card.
|
A free-form description of the condition of the card.
|
||||||
example: 'Lightly played'
|
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:
|
collection_statistics:
|
||||||
type: object
|
type: object
|
||||||
description: >-
|
description: >-
|
||||||
|
|
Loading…
Reference in a new issue