Repository navigation
Conversation
|
Reviewed Standards
SpecP2 — payload definitions from different endpoints overwrite each other. This violates the stated requirement to preserve reference scopes and metadata. For fields carrying For example, register two subscribers with these body parameters: # First subscriber
value: Annotated[int, Field(json_schema_extra={"$id": "https://example.test/A"})]
# Second subscriber
value: Annotated[str, Field(json_schema_extra={"$id": "https://example.test/B"})]Both payloads end up referencing Confirmed on the current commit with FastDepends 4.0.0a1 for both AsyncAPI versions, Pydantic and Msgspec, and subscribers and explicit publisher schemas. The simple Pydantic subscriber case also confirms a regression against the base implementation, which keeps the two payloads separate. Namespace the retained definitions per payload and rewrite their references consistently. A regression test with two endpoints in the same document should cover this. Standards: 2 findings, highest priority P3 (assertion structure). Spec: 1 finding, P2 (component collision). |
IvanKirpichnikov
left a comment
There was a problem hiding this comment.
- The
msgspecmodels of the same name replace each other's schemes. If two subscribers acceptlist[a.Record]andlist[b.Record]with different fields, both receive a$refoncomponents/schemas/Record. In both versions of AsyncAPI, only one definition is saved, without warning. Different definitions need separate keys. oneOffrommsgspecmetadata breaks AsyncAPI 2.6.msgspec.Meta(extra_json_schema={"oneOf": [{"minimum": 1}, {"maximum": -1}]})leads toAttributeError. The generator considers each element of the list to be a reference and calls.split()on the number. In 3.0, both restrictions remain. The 2.6 branch should save theoneOfarray inside the payload schema- The tagged union
msgspecgenerates an incorrect discriminator. ForCreated | Removed, where both structures are declared withtag=True, both versions of the generator output discriminator: type in the scheme withanyOf. The type field is declared and required only in child schemas. AsyncAPI 3.0 requires declaring it and including it in required on the discriminator schema itself.
|
Thx, fixed all three.
|
Generate AsyncAPI 2.6/3.0 payload schemas through the selected FastDepends backend for subscribers, publisher annotations and explicit
schema=types. Support Msgspec Structs, aliases and constraints, preserving reference scopes and metadata.Requires FastDepends 4 (minimum 4.0.0a0). Pydantic remains required for AsyncAPI document models and FastAPI. Publishers continue to use the generic broker encoder.
Local paired measurements: sample document generation 0.67 to 0.83 ms; no confirmed message dispatch slowdown.
Depends on #3333.
Closes #2101.