Skip to content

Commit a23bbc1

Browse files
authored
docs-util: throw when schema parsing fails (#12846)
1 parent fcfd35a commit a23bbc1

3 files changed

Lines changed: 29 additions & 10 deletions

File tree

www/utils/generated/oas-output/schemas/AdminShippingOptionRule.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,18 @@
3535
* - gte
3636
* - nin
3737
* value:
38-
* type: string
39-
* title: value
38+
* oneOf:
39+
* - type: string
40+
* title: value
41+
* description: The shipping option rule's value.
42+
* example: "true"
43+
* - type: array
44+
* description: The shipping option rule's values.
45+
* items:
46+
* type: string
47+
* title: value
48+
* description: A value of the shipping option rule.
49+
* example: "true"
4050
* shipping_option_id:
4151
* type: string
4252
* title: shipping_option_id
@@ -56,5 +66,6 @@
5666
* format: date-time
5767
* title: deleted_at
5868
* description: The date the shipping option rule was deleted.
59-
*
60-
*/
69+
*
70+
*/
71+

www/utils/generated/oas-output/schemas/AdminWorkflowExecutionExecution.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,5 +147,6 @@
147147
* type: number
148148
* title: startedAt
149149
* description: The timestamp the step started executing.
150-
*
151-
*/
150+
*
151+
*/
152+

www/utils/packages/docs-generator/src/classes/helpers/oas-schema.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { parse } from "yaml"
99
import formatOas from "../../utils/format-oas.js"
1010
import pluralize from "pluralize"
1111
import { capitalize, wordsToPascal } from "utils"
12+
import chalk from "chalk"
1213
import { OasArea } from "../kinds/oas.js"
1314
import {
1415
isLevelExceeded,
@@ -307,7 +308,7 @@ class OasSchemaHelper {
307308
return
308309
}
309310

310-
return this.parseSchema(schemaFileContent)
311+
return this.parseSchema(schemaFileContent, true)
311312
}
312313

313314
/**
@@ -316,7 +317,10 @@ class OasSchemaHelper {
316317
* @param content - The schema comment string
317318
* @returns If the schema is valid and parsed successfully, the schema and its prefix are retrieved.
318319
*/
319-
parseSchema(content: string): ParsedSchema | undefined {
320+
parseSchema(
321+
content: string,
322+
failOnParseError = false
323+
): ParsedSchema | undefined {
320324
const schemaFileContent = content
321325
.replace(`/**\n`, "")
322326
.replaceAll(DOCBLOCK_LINE_ASTRIX, "")
@@ -334,8 +338,11 @@ class OasSchemaHelper {
334338
try {
335339
schema = parse(splitContent.slice(1).join("\n"))
336340
} catch (e) {
337-
// couldn't parse the OAS, so consider it
338-
// not existent
341+
if (failOnParseError) {
342+
throw e
343+
}
344+
345+
console.error(chalk.red(e))
339346
}
340347

341348
return schema

0 commit comments

Comments
 (0)