contrib icon indicating copy to clipboard operation
contrib copied to clipboard

feat(entoas): add field descriptions and fix examples

Open lrstanley opened this issue 9 months ago • 1 comments

This PR does a few things:

  • For all ent fields and edge requests, the description field is populated in the ogen schema.
    • Had to move away from the types map, because this was using the same fields, and changing the contents was impacting all fields of the same type. Don't see any noticeable performance difference -- not sure if this was intentional before or not.
    • Added ptr[T any](v) *v to help with code-duplication and should help with all of the pointer-to-base-types issues.
    • Fixes some cases of min/max not being properly applied.
  • The Example() annotation now works as expected. Previously, adding that annotation to any field, edge, or schema, didn't seem to have any affect.
  • When a field has a default value (function or static value), it is no longer required in POST bodies.
  • Edges which have an associated field (.Field()) that are readonly, the field is skipped for creates/updates.
  • When an edge has an associated field (.Field()) that isn't skipped, the edge object is skipped from the request body. If this isn't the case, two properties are required, which are in fact the same.
    • Example: a field of friend_id with an edge friend which is associated via .Field("friend_id"), results in POST requests both having friend and friend_id being required, but they both set the same thing.
  • Edge requests (e.g. /owners/<id>/pets) now have tags for both types, if they differ (e.g. Owner and Pet, rather than just Owner).

lrstanley avatar Apr 27 '24 20:04 lrstanley