From 0bf04dcd1ee8b8b2561ba9e548970e2f25661d1d Mon Sep 17 00:00:00 2001 From: brittonhayes Date: Fri, 28 Jul 2023 17:28:13 -0700 Subject: [PATCH 1/2] feat: migrate weapon stats to type string to support D{n},-n, and n+ values --- api/api.gen.go | 68 +++++------ api/openapi.yaml | 291 +++++++++++++++++++++----------------------- fixtures/units.yaml | 38 ++++-- web/index.html | 10 +- 4 files changed, 204 insertions(+), 203 deletions(-) diff --git a/api/api.gen.go b/api/api.gen.go index a537ce0..0c9dd70 100644 --- a/api/api.gen.go +++ b/api/api.gen.go @@ -141,13 +141,13 @@ type Warscroll struct { // Weapon defines model for Weapon. type Weapon struct { ID *string `bun:",pk" json:"_id,omitempty"` - Attacks *int64 `json:"attacks,omitempty"` - Damage *int64 `json:"damage,omitempty"` + Attacks *string `json:"attacks,omitempty"` + Damage *string `json:"damage,omitempty"` Name *string `json:"name,omitempty"` - Range *int64 `json:"range,omitempty"` - Rend *int64 `json:"rend,omitempty"` - ToHit *int64 `json:"to_hit,omitempty"` - ToWound *int64 `json:"to_wound,omitempty"` + Range *string `json:"range,omitempty"` + Rend *string `json:"rend,omitempty"` + ToHit *string `json:"to_hit,omitempty"` + ToWound *string `json:"to_wound,omitempty"` } // GetAllegiancesParams defines parameters for GetAllegiances. @@ -1265,34 +1265,34 @@ func WithErrorHandler(handler func(w http.ResponseWriter, r *http.Request, err e // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "H4sIAAAAAAAC/9RaW2/bOBP9KwK/72EXcCK3DfbBb95eg93uFpsGfSgKg5bGNhteVJJKohb57wtSknWj", - "LKqxs/ZTU2s4Q845Z4aU+ANFgiWCA9cKzX4gFW2AYfvnfEko0Zn5M5EiAakJ2AcxqEiSRBPBzX91lgCa", - "IaUl4Wv0MEEcM3A8eJiUv4jlV4i0MZ1TCmuCeQTdMAsSd71M0P3ZWpzBvZb4TOO1tVymHM0QiSfJjQ0z", - "NMG1xDxeYEq3kTsmTEiN6UICpmzkI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rXJ1KrYOyK+dXQUJkelmfw+XSaH0+4Bm6TiZOEFiQJv6lchZU/v9bcqIqts3h7", + "h4H++sNYXUwvRk1kV/z8wOYIVTugmRKVMobN9s5JGWNR51v4k8QPQ6Qr6bHMAhLvZt3v2eWrIeLlhGjS", + "ToJOJS+ZYKRREcHGrLqmlikckgy+HDhmzJuI5aBLRnzqS27mArl88gRSkyw7NZHl2aml2kNakmU7RCVZ", + "NkJOxtcJCckifLyIVshYRKPt6XaneAozB5gvyydeLTkiOttLM36SxvjS+UPDUau1AKqG7bBaLSi9ajVJ", + "8FdrCfCJqDVH+GgRrSFjEY1FtFurZsseiyhlwLWdpQvRV8bLYFI13OtwoxltrnF7QFwSjq1k23gdazK7", + "ubE5tbvxs3I3PlwKm/t9Z01snPGfZmPR+VnhhGpWO6MuWIarWOsc1lvPGpnyL2zdY96JlLgWM46WCU78", + "alRQ+Qsm4i3R2oA+GlzVTZ5IpNsXZaco0lpOndD4yrQYkQ3ItMzVWJlu3Z+YTCtuHLlMW/hZLmzsC9Uf", + "O9HPbYLi3akD9neFkwNmunjxe7wpbibJ5nZ7rWZn3cutHFm9Lh54ndGMl8P8YNoq8SNijfjJtCfqlrGj", + "o5Yjx0XN376MiVa8r3FEqV6+PMmxt+dW1jF3p5z5lVSG+5BFpbf7mBT4N50S4RNpNTm+R4tnDZkWoGHj", + "OkZ/KSyt7Fuz3UDPS9s3Qj4G9GbQo6DA467THK/c+9C1ZLkrrxcMd8uaqYMYn+tPvfrm1t9hmmfVUEYF", + "8ukqnVjtew+jo3YuToxaqiI/xoe0NxhGhbFXJ8YjZy9c/OvCre7RnFanrqmuJdjhnl3h1FvPt2nxL+QN", + "9E+khdfQP1q022jZ4QrkrRuM9yLCNMifN26tzMIQC3WGE3JOjc1GKLM9bY//KEWcRvayjMOJqnmJBEMP", + "Xx/+CQAA//8al0M9jDIAAA==", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/api/openapi.yaml b/api/openapi.yaml index 35f0c2d..fa5ef8d 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -8,10 +8,10 @@ info: url: https://opensource.org/licenses/MIT security: [] servers: -- url: http://aos-api.localhost - description: Local server -- url: https://aos-api.com - description: Production server + - url: http://aos-api.localhost + description: Local server + - url: https://aos-api.com + description: Production server paths: /healthz: get: @@ -37,18 +37,18 @@ paths: description: Get all allegiances operationId: getAllegiances parameters: - - name: name - in: query - description: name of allegiance to filter by - required: false - schema: - type: string - - name: grand_alliance - in: query - description: id of grand alliance to filter by - required: false - schema: - type: string + - name: name + in: query + description: name of allegiance to filter by + required: false + schema: + type: string + - name: grand_alliance + in: query + description: id of grand alliance to filter by + required: false + schema: + type: string responses: '200': description: OK @@ -70,12 +70,12 @@ paths: description: Get allegiance by id operationId: getAllegianceById parameters: - - name: id - in: path - description: id of allegiance to return - required: true - schema: - type: string + - name: id + in: path + description: id of allegiance to return + required: true + schema: + type: string responses: '200': description: OK @@ -115,12 +115,12 @@ paths: description: Get army by id operationId: getArmyById parameters: - - name: id - in: path - description: id of army to return - required: true - schema: - type: string + - name: id + in: path + description: id of army to return + required: true + schema: + type: string responses: '200': description: OK @@ -140,12 +140,12 @@ paths: description: Get all cities operationId: getCities parameters: - - name: name - in: query - description: name of city to filter by - required: false - schema: - type: string + - name: name + in: query + description: name of city to filter by + required: false + schema: + type: string responses: '200': description: OK @@ -167,12 +167,12 @@ paths: description: Get city by id operationId: getCityById parameters: - - name: id - in: path - description: id of city to return - required: true - schema: - type: string + - name: id + in: path + description: id of city to return + required: true + schema: + type: string responses: '200': description: OK @@ -231,12 +231,12 @@ paths: description: Get grand alliance by id operationId: getGrandAllianceById parameters: - - name: id - in: path - description: id of grand alliance to return - required: true - schema: - type: string + - name: id + in: path + description: id of grand alliance to return + required: true + schema: + type: string responses: '200': description: OK @@ -276,12 +276,12 @@ paths: description: Get grand strategy by id operationId: getGrandStrategyById parameters: - - name: id - in: path - description: id of grand strategy to return - required: true - schema: - type: string + - name: id + in: path + description: id of grand strategy to return + required: true + schema: + type: string responses: '200': description: OK @@ -301,30 +301,30 @@ paths: description: Get all units operationId: getUnits parameters: - - name: name - in: query - description: name of unit to filter by - required: false - schema: - type: string - - name: grand_alliance - in: query - description: grand alliance of unit to filter by - required: false - schema: - type: string - - name: grand_strategy - in: query - description: grand strategy of unit to filter by - required: false - schema: - type: string - - name: points - in: query - description: points of unit to filter by - required: false - schema: - type: integer + - name: name + in: query + description: name of unit to filter by + required: false + schema: + type: string + - name: grand_alliance + in: query + description: grand alliance of unit to filter by + required: false + schema: + type: string + - name: grand_strategy + in: query + description: grand strategy of unit to filter by + required: false + schema: + type: string + - name: points + in: query + description: points of unit to filter by + required: false + schema: + type: integer responses: '200': description: OK @@ -346,12 +346,12 @@ paths: description: Get unit by id operationId: getUnitById parameters: - - name: id - in: path - description: id of unit to return - required: true - schema: - type: string + - name: id + in: path + description: id of unit to return + required: true + schema: + type: string responses: '200': description: OK @@ -371,12 +371,12 @@ paths: description: Get abilities for unit by id operationId: getAbilitiesForUnitById parameters: - - name: id - in: path - description: id of unit to return abilities for - required: true - schema: - type: string + - name: id + in: path + description: id of unit to return abilities for + required: true + schema: + type: string responses: '200': description: OK @@ -398,36 +398,36 @@ paths: description: Get all warscrolls operationId: getWarscrolls parameters: - - name: name - in: query - description: name of warscroll to filter by - required: false - schema: - type: string - - name: points - in: query - description: points of warscroll to filter by - required: false - schema: - type: integer - - name: battlefield_role - in: query - description: battlefield_role of warscroll to filter by - required: false - schema: - type: string - - name: size - in: query - description: size of warscroll to filter by - required: false - schema: - type: string - - name: notes - in: query - description: notes of warscroll to filter by - required: false - schema: - type: string + - name: name + in: query + description: name of warscroll to filter by + required: false + schema: + type: string + - name: points + in: query + description: points of warscroll to filter by + required: false + schema: + type: integer + - name: battlefield_role + in: query + description: battlefield_role of warscroll to filter by + required: false + schema: + type: string + - name: size + in: query + description: size of warscroll to filter by + required: false + schema: + type: string + - name: notes + in: query + description: notes of warscroll to filter by + required: false + schema: + type: string responses: '200': description: OK @@ -449,12 +449,12 @@ paths: description: Get warscroll by id operationId: getWarscrollById parameters: - - name: id - in: path - description: id of warscroll to return - required: true - schema: - type: string + - name: id + in: path + description: id of warscroll to return + required: true + schema: + type: string responses: '200': description: OK @@ -468,20 +468,19 @@ paths: application/json: schema: $ref: '#/components/schemas/Error' - components: schemas: Health: required: - - status + - status type: object properties: status: type: string Error: required: - - code - - message + - code + - message type: object properties: code: @@ -589,28 +588,23 @@ components: bun: ',pk' name: type: string + example: "Lance and Sword" range: - type: integer - format: int64 + type: string attacks: - type: integer - format: int64 + type: string to_hit: - type: integer - format: int64 + type: string to_wound: - type: integer - format: int64 + type: string rend: - type: integer - format: int64 + type: string damage: - type: integer - format: int64 + type: string GrandAlliance: type: object required: - - name + - name properties: _id: type: string @@ -623,7 +617,7 @@ components: GrandStrategy: type: object required: - - name + - name properties: _id: type: string @@ -636,7 +630,7 @@ components: Allegiance: type: object required: - - name + - name properties: _id: type: string @@ -653,7 +647,7 @@ components: Unit: type: object required: - - name + - name properties: _id: type: string @@ -696,20 +690,14 @@ components: type: string command_abilities: type: array - # x-go-extra-tags: - # bun: "rel:has-many,join:id=unit_id" items: $ref: '#/components/schemas/Attribute' magic: type: array - # x-go-extra-tags: - # bun: "rel:has-many,join:id=unit_id" items: $ref: '#/components/schemas/Attribute' damage_table: type: array - # x-go-extra-tags: - # bun: "rel:has-many,join:id=unit_id" items: $ref: '#/components/schemas/DamageTable' missile_weapons: @@ -720,11 +708,10 @@ components: type: array items: $ref: '#/components/schemas/Weapon' - Army: type: object required: - - name + - name properties: _id: type: string diff --git a/fixtures/units.yaml b/fixtures/units.yaml index 727759d..4225dff 100644 --- a/fixtures/units.yaml +++ b/fixtures/units.yaml @@ -35,12 +35,26 @@ min_wounds_suffered: 0 melee_weapons: - name: Celestine Hammer - range: 1 - attacks: 4 - to_hit: 3 - to_wound: 3 - rend: -1 - damage: 2 + range: '1' + attacks: '4+' + to_hit: '3+' + to_wound: '3+' + rend: '-1' + damage: 'D3' + - name: Stormbound Blade + range: '1' + attacks: '1' + to_hit: '3+' + to_wound: '4+' + rend: '-1' + damage: '2' + - name: Great Claws + range: '1' + attacks: '2' + to_hit: '3+' + to_wound: '3+' + rend: '-1' + damage: '1' missile_weapons: [] - id: liberators name: Liberators @@ -75,10 +89,10 @@ min_wounds_suffered: 0 melee_weapons: - name: Warhammer - range: 1 - attacks: 1 - to_hit: 4 - to_wound: 3 - rend: -1 - damage: 1 + range: '1' + attacks: '1+' + to_hit: '4+' + to_wound: '3+' + rend: '-1' + damage: '1' missile_weapons: [] diff --git a/web/index.html b/web/index.html index 773c583..ec88c4a 100644 --- a/web/index.html +++ b/web/index.html @@ -378,13 +378,13 @@

Response samples

Content type
application/json
[
  • {
    }
]

Get army by id

Get army by id

+
https://aos-api.com/armies

Response samples

Content type
application/json
[
  • {
    }
]

Get army by id

Get army by id

path Parameters
id
required
string

id of army to return

Responses

Response samples

Content type
application/json
{
  • "_id": "string",
  • "name": "string",
  • "units": [
    ]
}

Get all cities

Get all cities

+
https://aos-api.com/armies/{id}

Response samples

Content type
application/json
{
  • "_id": "string",
  • "name": "string",
  • "units": [
    ]
}

Get all cities

Get all cities

query Parameters
name
string

name of city to filter by

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Get unit by id

Get unit by id

+
https://aos-api.com/units

Response samples

Content type
application/json
[
  • {
    }
]

Get unit by id

Get unit by id

path Parameters
id
required
string

id of unit to return

Responses

Response samples

Content type
application/json
{
  • "_id": "string",
  • "name": "string",
  • "grand_alliance": "string",
  • "champion": "string",
  • "size": {
    },
  • "move": {
    },
  • "description": "string",
  • "save": 0,
  • "bravery": 0,
  • "models": 0,
  • "points": 0,
  • "wounds": 0,
  • "abilities": [
    ],
  • "keywords": [
    ],
  • "command_abilities": [
    ],
  • "magic": [
    ],
  • "damage_table": [
    ],
  • "missile_weapons": [
    ],
  • "melee_weapons": [
    ]
}

Get abilities for unit by id

Get abilities for unit by id

+
https://aos-api.com/units/{id}

Response samples

Content type
application/json
{
  • "_id": "string",
  • "name": "string",
  • "grand_alliance": "string",
  • "champion": "string",
  • "size": {
    },
  • "move": {
    },
  • "description": "string",
  • "save": 0,
  • "bravery": 0,
  • "models": 0,
  • "points": 0,
  • "wounds": 0,
  • "abilities": [
    ],
  • "keywords": [
    ],
  • "command_abilities": [
    ],
  • "magic": [
    ],
  • "damage_table": [
    ],
  • "missile_weapons": [
    ],
  • "melee_weapons": [
    ]
}

Get abilities for unit by id

Get abilities for unit by id

path Parameters
id
required
string

id of unit to return abilities for

Responses

http://aos-api.localhost/warscrolls/{id}

Production server

https://aos-api.com/warscrolls/{id}

Response samples

Content type
application/json
{
  • "_id": "string",
  • "name": "string",
  • "allegiance_id": "string",
  • "allegiance": {
    },
  • "grand_alliance_id": "string",
  • "grand_alliance": {
    },
  • "size": 0,
  • "points": 0,
  • "battlefield_role": "string",
  • "notes": "string"
}