Repository navigation
openapi-codegen: complete QUERY fallback and cross-language schema types - #66
Open
chrischeng-c4 wants to merge 1 commit into
Open
chrischeng-c4 wants to merge 1 commit into
chrischeng-c4 wants to merge 1 commit into
Conversation
…emas Emit #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub enum Name for top-level component schemas with type: string and a non-empty all-string enum. Each variant gets #[serde(rename = "<value>")] preserving wire values, with PascalCase variant names via to_pascal. Disambiguate colliding variants and non-identifier values deterministically, and preserve String fallback for untyped, non-string, and inline enums.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #34
Summary of Changes
Implements the first slice of #34 for
crates/openapi-codegen:crates/openapi-codegen/src/domain/emit/rust/models_emit.rs:is_string_enumto identify component schemas eligible for Rust enum generation (type: string, non-empty all-stringenum, emptyproperties/unions).emit_enumto emit#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub enum Name { ... }with#[serde(rename = "<value>")]on each variant and PascalCase variant names viato_pascal, preserving declared order.NameRegistryfor colliding variant names (e.g.FooBar,FooBar_2) and non-identifier values (""->Anonymous,"123"->_123,"self"->Self_).String.crates/openapi-codegen/src/domain/emit/rust/rsmap.rs:String/Option<String>.crates/openapi-codegen/src/domain/emit/rust.rs:emits_string_enum_component_modelverifyingmodels.rsgeneration for string enum component schemas with struct$ref.Local Validation Results
Cancelled Broad Package Test:
cargo test --locked -p openapi-codegenhung on background network TLS testdomain::emit::py::tests::tls_alpn::generated_python_h2_runtime_negotiates_tls_alpn_h2and was terminated via supportedmanage_task(Action=kill)per local testing policy (Task0297a583-9bab-44e1-a787-5e6e80d8ff75/task-96). This broad package test is NOT RUN locally and left to cloud CI.Affected Isolated Unit Tests (PASSED):
cargo test --locked -p openapi-codegen --lib domain::emit::rust(19 passed, 0 failed):declared_order: passedrename_non_identifier_values: passedcollision_disambiguation: passednullable_enum_emits_same_enum: passedstruct_property_refs_enum: passednon_string_enum_left_as_string: passedserde_round_trip_rejects_undeclared_value: passedinline_and_non_string_enums_stay_string: passedemits_string_enum_component_model: passeddomain::emit::ts(27 passed)domain::emit::py::models_emit(1 passed)domain::emit::py::pymap(1 passed)domain::ir(14 passed)Negative Control:
emit_schemato the type-alias branch caused exactly the 6 new enum test rows to fail while all other rows passed.Formatting:
cargo fmt --check -p openapi-codegenpassed cleanly.Cloud CI Requirements