Skip to content

Commit c46dfee

Browse files
committed
Change generate_codesamples to accept &OpenApi spec
1 parent 87c0f8a commit c46dfee

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/codesamples.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,19 +191,17 @@ impl CodesampleTemplates {
191191
}
192192

193193
pub async fn generate_codesamples(
194-
openapi_spec: &str,
194+
openapi_spec: &OpenApi,
195195
templates: CodesampleTemplates,
196196
excluded_operation_ids: BTreeSet<String>,
197197
path_param_example: fn(String) -> String,
198198
) -> anyhow::Result<BTreeMap<CodegenLanguage, Vec<CodeSample>>> {
199-
let openapi_spec: OpenApi =
200-
serde_json::from_str(openapi_spec).context("failed to parse OpenAPI spec")?;
201-
202199
let api_ir = crate::api::Api::new(
203200
openapi_spec
204201
.paths
205-
.expect("found no endpoints in input spec"),
206-
&mut openapi_spec.components.unwrap_or_default(),
202+
.clone()
203+
.context("found no endpoints in input spec")?,
204+
&mut openapi_spec.components.clone().unwrap_or_default(),
207205
&[],
208206
crate::IncludeMode::OnlyPublic,
209207
&excluded_operation_ids,

0 commit comments

Comments
 (0)