Skip to content

Support inferring Path types from structs #28

Description

@Flowneee

PR #27 added path schema inferring from function arguments, but it doesn't implement inferring when T in Path<T> is complex struct. This should be fairly easy to implement if T implements JsonSchema - just extract its schema and check inner fields. So basically logic would be like:

  1. get JSON schema for T;
  2. if it is primitive type (string, number, ...) - assume this is single path parameter
  3. if it is struct - assume each field is a separate parameter
  4. if it is a tuple - probably the same

When T is struct, deserializer will use field names rather than positions, so crate should also validate that names of parameters in path matches field names in struct (probably via T JSON schema as well).

For tuples probably good idea to add number of positional arguments validation against actual path as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions