Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update spec generation to align with reality #620

Merged
merged 3 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"dev": "nodemon npm run start",
"lint": "eslint . --config eslint.config.js",
"validate-swagger": "swagger-cli validate src/swagger/swagger.yml",
"bundle-swagger": "npm run validate-swagger && swagger-cli bundle --outfile src/swagger/dist/openapi.yml --type yaml src/swagger/swagger.yml && swagger-cli bundle --outfile src/swagger/dist/openapi.json --type json src/swagger/swagger.yml",
"bundle-swagger": "npm run validate-swagger && swagger-cli bundle --outfile src/swagger/api-spec/openapi.yml --type yaml src/swagger/swagger.yml && swagger-cli bundle --outfile src/swagger/api-spec/openapi.json --type json src/swagger/swagger.yml",
"gen-postman": "npm run bundle-swagger && portman --cliOptionsFile portman-cli.json",
"test": "npm run test:unit && npm run test:integration:local",
"test:unit": "node --experimental-vm-modules node_modules/jest/bin/jest.js -c jest.config.unit.ts",
Expand Down
6,200 changes: 6,200 additions & 0 deletions src/swagger/api-spec/openapi.json

Large diffs are not rendered by default.

4,189 changes: 4,189 additions & 0 deletions src/swagger/api-spec/openapi.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/swagger/paths/classes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class-spells-path:
content:
application/json:
schema:
$ref: '../schemas/combined.yml#/APIReferenceList'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw, in a versioned world i would totally look at reworking the actual endpoint implementation for all of these to return a more uniform shape for "spells with a level". but if feels more important to have the docs match the actual response first.

$ref: '../schemas/combined.yml#/ClassSpellList'
example:
count: 2
results:
Expand Down
23 changes: 23 additions & 0 deletions src/swagger/schemas/classes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,26 @@ class-level-model:
- $ref: '#/cs-sorcerer'
- $ref: '#/cs-warlock'
- $ref: '#/cs-wizard'
class-level-spell-model:
description: |
`ClassLevelSpell`
allOf:
- $ref: './combined.yml#/APIReference'
- type: object
properties:
level:
type: number
description: 'The level of the spell slot used to cast the spell.'

class-spell-list-model:
description: |
`ClassSpellList`
type: object
properties:
count:
description: 'Total number of resources available.'
type: number
results:
type: array
items:
$ref: '#/class-level-spell-model'
4 changes: 4 additions & 0 deletions src/swagger/schemas/combined.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,7 @@ OptionSet:
$ref: './common.yml#/option-set-model'
Option:
$ref: './common.yml#/option-model'
ClassLevelSpell:
$ref: './classes.yml#/class-level-spell-model'
ClassSpellList:
$ref: './classes.yml#/class-spell-list-model'
14 changes: 1 addition & 13 deletions src/swagger/schemas/monsters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,9 @@ monster-model:
subtype:
description: The sub-category of a monster used for classification of monsters."
type: string
alignments:
alignment:
description: "A creature's general moral and personal attitudes."
type: string
enum:
- chaotic neutral
- chaotic evil
- chaotic good
- lawful neutral
- lawful evil
- lawful good
- neutral
- neutral evil
- neutral good
- any alignment
- unaligned
armor_class:
description: 'The difficulty for a player to successfully deal damage to a monster.'
type: array
Expand Down
1 change: 1 addition & 0 deletions src/swagger/schemas/subclass.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ subclass-model:
$ref: "./combined.yml#/SpellPrerequisite"
spell:
$ref: "./combined.yml#/APIReference"

subclass-level-resource-model:
type: object
properties:
Expand Down
Loading