-
Notifications
You must be signed in to change notification settings - Fork 99
Openapi: adding more info in x-state, adding x-state info to fields and params #4431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
l-trotta
wants to merge
5
commits into
main
Choose a base branch
from
detailed-availability
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,8 +23,9 @@ pub mod cli; | |
|
||
use indexmap::IndexMap; | ||
|
||
use clients_schema::{Availabilities, Flavor, IndexedModel, Stability, Visibility}; | ||
use clients_schema::{Availabilities, Availability, Flavor, IndexedModel, Stability, Visibility}; | ||
use openapiv3::{Components, OpenAPI}; | ||
use serde_json::Value; | ||
use clients_schema::transform::ExpandConfig; | ||
use crate::components::TypesAndComponents; | ||
|
||
|
@@ -103,7 +104,7 @@ pub fn convert_expanded_schema(model: &IndexedModel, config: &Configuration) -> | |
continue; | ||
} | ||
} | ||
paths::add_endpoint(endpoint, &mut tac, &mut openapi.paths)?; | ||
paths::add_endpoint(endpoint, &mut tac, &mut openapi.paths, &config.flavor)?; | ||
} | ||
|
||
// // Sort maps to ensure output stability | ||
|
@@ -149,30 +150,37 @@ fn info(model: &IndexedModel) -> openapiv3::Info { | |
} | ||
} | ||
|
||
pub fn availability_as_extensions(availabilities: &Option<Availabilities>) -> IndexMap<String, serde_json::Value> { | ||
pub fn availability_as_extensions(availabilities: &Option<Availabilities>, flavor: &Option<Flavor>) -> IndexMap<String, serde_json::Value> { | ||
let mut result = IndexMap::new(); | ||
convert_availabilities(availabilities, flavor, &mut result); | ||
result | ||
} | ||
|
||
pub fn convert_availabilities(availabilities: &Option<Availabilities>, flavor: &Option<Flavor>, result: &mut IndexMap<String, Value>) { | ||
if let Some(avails) = availabilities { | ||
// We may have several availabilities, but since generally exists only on stateful (stack) | ||
for (_, availability) in avails { | ||
if let Some(stability) = &availability.stability { | ||
match stability { | ||
if let Some(flav) = flavor { | ||
if let Some(availability) = avails.get(flav) { | ||
let Availability {since,stability,..} = &availability; | ||
let stab = stability.clone().unwrap_or(Stability::Stable); | ||
let mut since_str = "".to_string(); | ||
if let Some(since) = since { | ||
since_str = "; Added in ".to_string() + since; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
} | ||
match stab { | ||
Stability::Beta => { | ||
result.insert("x-beta".to_string(), serde_json::Value::Bool(true)); | ||
let beta_since = "Beta".to_string() + &since_str; | ||
result.insert("x-state".to_string(), Value::String(beta_since)); | ||
} | ||
Stability::Experimental => { | ||
result.insert("x-state".to_string(), serde_json::Value::String("Technical preview".to_string())); | ||
let exp_since = "Technical preview".to_string() + &since_str; | ||
result.insert("x-state".to_string(), Value::String(exp_since)); | ||
} | ||
Stability::Stable => { | ||
if let Some(since) = &availability.since { | ||
let stable_since = "Added in ".to_string() + since; | ||
result.insert("x-state".to_string(), serde_json::Value::String(stable_since)); | ||
} | ||
let stable_since = "Generally available".to_string() + &since_str; | ||
result.insert("x-state".to_string(), Value::String(stable_since)); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
result | ||
} |
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
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
Binary file modified
BIN
+3.77 KB
(100%)
compiler-rs/compiler-wasm-lib/pkg/compiler_wasm_lib_bg.wasm
Binary file not shown.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The config is part of
tac
, I added it in #4313. This effectively makesTypesAndComponents
more than types and components. I'll open a PR to rename it to something more "kitchensink-esque" likeContext
.