enum & allOf
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start with typify-impl/src/defaults.rs around line 320, then follow the convert_typed_enum and convert_schema_object frames in the reported backtrace. Reproduce generation using the linked Discord OpenAPI schema and the sciguy16/openapi31to30 conversion. Done means enum combined with allOf no longer reaches the unreachable panic and the schema is handled consistently.
Written by the indexing model from the issue text.
Description
https://github.com/discord/discord-api-spec/blob/main/specs/openapi.json contains a lot of schemas like this.
RoleSelectDefaultValueResponse:
type: object
properties:
type:
type: string
enum:
- role
allOf:
- $ref: '#/components/schemas/SnowflakeSelectDefaultValueTypes'
id:
$ref: '#/components/schemas/SnowflakeType'
required:
- type
- id
...
SnowflakeSelectDefaultValueTypes:
type: string
oneOf:
- title: USER
const: user
- title: ROLE
const: role
- title: CHANNEL
const: channel
Note I am using https://github.com/sciguy16/openapi31to30 to make it compatible with progenitor/typify
I checked the openapi doc using https://github.com/daveshanley/vacuum , and while there were a lot of warnings, they didnt appear to relate to the above https://github.com/discord/discord-api-spec/issues/41
I don't see any prohibition on using enum & allOf in this way...?
As I understand it, the addition of allOf SnowflakeSelectDefaultValueTypes is redundant, as SnowflakeSelectDefaultValueTypes is a superset of the enum, and could be simply discarded.
typify on main fails at https://github.com/oxidecomputer/typify/blob/7d61436/typify-impl/src/defaults.rs#L320
thread 'main' panicked at /Users/jayvdb/rust/typify/typify-impl/src/defaults.rs:320:47:
internal error: entered unreachable code
stack backtrace:
0: __rustc::rust_begin_unwind
at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/std/src/panicking.rs:697:5
1: core::panicking::panic_fmt
at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/core/src/panicking.rs:75:14
2: core::panicking::panic
at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/core/src/panicking.rs:145:5
3: typify_impl::defaults::<impl typify_impl::type_entry::TypeEntry>::validate_value
4: typify_impl::convert::<impl typify_impl::TypeSpace>::convert_typed_enum::{{closure}}
5: core::iter::traits::iterator::Iterator::try_for_each::call::{{closure}}
6: core::iter::traits::iterator::Iterator::try_fold
7: core::iter::traits::iterator::Iterator::try_for_each
8: typify_impl::convert::<impl typify_impl::TypeSpace>::convert_typed_enum
9: typify_impl::convert::<impl typify_impl::TypeSpace>::convert_schema_object
10: typify_impl::convert::<impl typify_impl::TypeSpace>::convert_schema
11: typify_impl::TypeSpace::id_for_schema
12: typify_impl::structs::<impl typify_impl::TypeSpace>::struct_property
13: typify_impl::structs::<impl typify_impl::TypeSpace>::struct_members::{{closure}}
14: core::iter::adapters::filter_map::filter_map_try_fold::{{closure}}
15: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
16: core::iter::traits::iterator::Iterator::try_fold
17: <core::iter::adapters::chain::Chain<A,B> as core::iter::traits::iterator::Iterator>::try_fold
18: <core::iter::adapters::filter_map::FilterMap<I,F> as core::iter::traits::iterator::Iterator>::try_fold
19: <core::iter::adapters::GenericShunt<I,R> as core::iter::traits::iterator::Iterator>::try_fold
20: <core::iter::adapters::GenericShunt<I,R> as core::iter::traits::iterator::Iterator>::next
21: alloc::vec::Vec<T,A>::extend_desugared
22: <alloc::vec::Vec<T,A> as alloc::vec::spec_extend::SpecExtend<T,I>>::spec_extend
23: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter
24: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
25: <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter
26: core::iter::traits::iterator::Iterator::collect
27: <core::result::Result<V,E> as core::iter::traits::collect::FromIterator<core::result::Result<A,E>>>::from_iter::{{closure}}
28: core::iter::adapters::try_process
29: <core::result::Result<V,E> as core::iter::traits::collect::FromIterator<core::result::Result<A,E>>>::from_iter
30: core::iter::traits::iterator::Iterator::collect
31: typify_impl::structs::<impl typify_impl::TypeSpace>::struct_members
32: typify_impl::convert::<impl typify_impl::TypeSpace>::convert_object
33: typify_impl::convert::<impl typify_impl::TypeSpace>::convert_schema_object
34: typify_impl::convert::<impl typify_impl::TypeSpace>::convert_schema
35: typify_impl::TypeSpace::convert_ref_type
36: typify_impl::TypeSpace::add_ref_types_impl
37: typify_impl::TypeSpace::add_ref_types
38: progenitor_impl::Generator::generate_tokens
- Dominant language
- Rust
- Stars
- 898
- Forks
- 114
- Avg merge
- 13h 19m
- Merged PRs (30d)
- 16
Getting set up
We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from oxidecomputer/typify
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
oxidecomputer/typify#1077 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
oxidecomputer/typify#1075 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 50/100
oxidecomputer/typify#1060 ·
-
Difficulty 5/5 Over a week Newbie friendliness 48/100
oxidecomputer/typify#1059 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
oxidecomputer/typify#1022 · 1 comment ·
All issues in oxidecomputer/typify
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
linebender/parley#849 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
boxlite-ai/boxlite#1729 ·
Maintainers usually reply within 1 day
-
external
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
langchain-ai/docs#6255 ·
Maintainers usually reply within 1 day
-
P2 testing
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 1 day