open5e / open5e-api

The api for open5e.com
Other
156 stars 97 forks source link

API V2: `weapon` model not returning `properties` field when access as a ForeignKey via `/items` endpoint #572

Closed calumbell closed 1 month ago

calumbell commented 1 month ago

Description

Observed Behaviour. When working with the /v2/items endpoint, ForeignKeys on the weapons field do not include the properties field (this is an array of weapon properies, ie. ['Versatile', 'Thrown'] etc.

Desired Behaviour. That the properties field be returned when the model is accessed via a ForeignKey on the /items endpoint

Recreation

  1. First take a look at the weapon API V2 model. Observe that the properties property is already a part of this model: https://github.com/open5e/open5e-api/blob/730a66273f03737ef9ab9bbb9943089ea00b5521/api_v2/models/weapon.py#L136-L167

  2. Fork the open5e-api repo and checkout the staging branch. Setup and run test server.

  3. Visit the /v2/items/srd_battleaxe/?depth=1&fields=name,key,weapon (fields omitted for brevity)

Screenshot 2024-10-16 at 11 39 04

Notice that the properties field is not returned as a child of the weapon field.