This repository was archived by the owner on May 13, 2026. It is now read-only.
refactor(atom): use simple KeyMetadata name in Molecule field types - #679
Merged
Conversation
`utoipa::ToSchema` derives the `$ref` for a field's referenced type from
the path expression used at the field site. So
`super::KeyMetadata` produces `#/components/schemas/super.KeyMetadata`,
and `crate::atom::KeyMetadata` produces
`#/components/schemas/crate.atom.KeyMetadata` — neither matches the
component registration name (`KeyMetadata`), so downstream consumers
(e.g. fold_db_node's `npm run generate:api`) fail with unresolved $refs:
```
✘ Can't resolve $ref at #/components/schemas/MoleculeRange/properties/key_metadata/additionalProperties
✘ Can't resolve $ref at #/components/schemas/Molecule/properties/key_metadata/allOf/0
✘ Can't resolve $ref at #/components/schemas/MoleculeHash/properties/key_metadata/additionalProperties
✘ Can't resolve $ref at #/components/schemas/MoleculeHashRange/properties/key_metadata/additionalProperties/additionalProperties
```
Fix by adding `KeyMetadata` to the `super::{...}` imports in each
file (or `crate::atom::{...}` for `molecule_hash_range.rs`) and using
the bare name at the field site. utoipa now emits the canonical
`#/components/schemas/KeyMetadata` ref.
No behavior change — the runtime serialisation is identical. Verified
by running 88 atom-module tests and `cargo check -p fold_db`. Follow-up
to #678 (which added `ToSchema` derives to these types in the first
place).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
`utoipa::ToSchema` derives the `$ref` from the path expression at the field site, not the type's effective name. So `super::KeyMetadata` produces `#/components/schemas/super.KeyMetadata` and `crate::atom::KeyMetadata` produces `#/components/schemas/crate.atom.KeyMetadata` — neither matches the registered component name (`KeyMetadata`).
Downstream, fold_db_node's drift check (`npm run generate:api`) fails:
```
✘ Can't resolve $ref at #/components/schemas/MoleculeRange/properties/key_metadata/additionalProperties
✘ Can't resolve $ref at #/components/schemas/Molecule/properties/key_metadata/allOf/0
✘ Can't resolve $ref at #/components/schemas/MoleculeHash/properties/key_metadata/additionalProperties
✘ Can't resolve $ref at #/components/schemas/MoleculeHashRange/properties/key_metadata/additionalProperties/additionalProperties
```
Fix: add `KeyMetadata` to each file's `super::{...}` (or `crate::atom::{...}`) imports and reference it bare at the field site. utoipa then emits the canonical `#/components/schemas/KeyMetadata` ref.
Follow-up to #678 (which added `ToSchema` derives to these types but missed the simple-name issue).
Test plan
🤖 Generated with Claude Code