Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

enum & allOf

Ouverte
#853 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
35/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
À l'abandon
Stack technique
openapi, rust
Domaine
compilers, tooling

Piste de recherche

Commencez par typify-impl/src/defaults.rs vers la ligne 320, puis suivez les frames convert_typed_enum et convert_schema_object dans le backtrace signalé. Reproduisez la génération avec le schéma Discord OpenAPI lié et la conversion sciguy16/openapi31to30. C’est terminé lorsque enum combiné à allOf n’atteint plus le panic unreachable et que le schéma est traité de manière cohérente.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

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
Langage dominant
Rust
Étoiles
905
Forks
116
Merge moyen
13 h 19 min
PR mergées (30 j)
16

Préparer son environnement

Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de oxidecomputer/typify

Toutes les issues de oxidecomputer/typify

Issues similaires

Plus d'issues Rust

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.