Skip to content

Commit bbd062e

Browse files
committed
further test
1 parent bb67c72 commit bbd062e

File tree

5 files changed

+102069
-689
lines changed

5 files changed

+102069
-689
lines changed

compiler-rs/clients_schema_to_openapi/src/paths.rs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,13 @@ pub fn add_endpoint(
191191

192192
parameters.append(&mut query_params.clone());
193193

194+
let sum_desc = split_summary_desc(endpoint.description.clone());
195+
194196
// Create the operation, it will be repeated if we have several methods
195197
let operation = openapiv3::Operation {
196198
tags: vec![endpoint.name.clone()],
197-
summary: Some(get_first_line(endpoint.description.clone())),
198-
description: Some(endpoint.description.clone()),
199+
summary: Some(sum_desc.summary),
200+
description: Some(sum_desc.description),
199201
external_docs: tac.convert_external_docs(endpoint),
200202
operation_id: None, // set in clone_operation below with operation_counter
201203
parameters,
@@ -311,13 +313,29 @@ fn get_path_parameters(template: &str) -> Vec<&str> {
311313
result
312314
}
313315

314-
fn get_first_line(desc: String) -> String {
316+
fn split_summary_desc(desc: String) -> SplitDesc{
315317
let mut parts = desc.split(['.','\n',':']);
316318
if parts.clone().count() == 1{
317-
return String::from(parts.next().unwrap())
319+
return SplitDesc {
320+
summary: String::from(parts.next().unwrap()),
321+
description: String::new()
322+
}
323+
}
324+
let first_line = parts.next().unwrap_or_else(|| "");
325+
let new_desc = desc.replace(first_line,"");
326+
let trim = new_desc.trim();
327+
let remove_period = trim.strip_prefix('.').unwrap_or_else(|| trim);
328+
let remove_column = remove_period.strip_prefix(':').unwrap_or_else(|| remove_period);
329+
SplitDesc {
330+
summary: String::from(first_line.trim()),
331+
description: String::from(remove_column.trim())
318332
}
319-
let first = parts.next().unwrap_or_else(|| "");
320-
String::from(first) + "."
333+
334+
}
335+
336+
struct SplitDesc {
337+
summary: String,
338+
description: String
321339
}
322340

323341
#[cfg(test)]
Binary file not shown.

compiler/src/transform/schema-to-openapi.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,24 @@ import { readFileSync, writeFileSync } from 'fs'
2424

2525
const inputPath = argv.input ?? join(__dirname, '..', '..', '..', 'output', 'schema', 'schema.json')
2626
const outputPath = argv.output ?? join(__dirname, '..', '..', '..', 'output', 'openapi', 'elasticsearch-serverless-openapi.json')
27+
const outputPathStack = argv.output ?? join(__dirname, '..', '..', '..', 'output', 'openapi', 'elasticsearch-openapi.json')
2728

2829
const inputText = readFileSync(
2930
inputPath,
3031
{ encoding: 'utf8' }
3132
)
3233

3334
const output = convert_schema_to_openapi(inputText, 'serverless')
35+
const outputStack = convert_schema_to_openapi(inputText, 'stack')
3436

3537
writeFileSync(
3638
outputPath,
3739
output,
3840
'utf8'
3941
)
42+
43+
writeFileSync(
44+
outputPathStack,
45+
outputStack,
46+
'utf8'
47+
)

0 commit comments

Comments
 (0)