@@ -13,46 +13,6 @@ export function isPathParam(str) {
1313 return pathParamRegEx . test ( str ) || pathParamWithCustomMethodRegEx . test ( str ) ;
1414}
1515
16- /**
17- * Extracts the schema path from the given JSONPath array.
18- *
19- * This function handles the following types of paths in OpenAPI definitions:
20- *
21- * 1. **Component Schema Paths**:
22- * - Represented as: `components.schemas.schemaName.enum`
23- * - This path indicates that the enum is defined directly within a schema under `components.schemas`.
24- * - The function returns the first three elements (`["components", "schemas", "schemaName"]`).
25- *
26- * 2. **Component Schema Property Paths**:
27- * - Represented as: `components.schemas.schemaName.properties.propertyName.enum`
28- * - This path indicates that the enum is defined for a specific property of a schema.
29- * - The function returns up to the property level (`["components", "schemas", "schemaName", "properties", "propertyName"]`).
30- *
31- * 3. **Parameter Schema Paths**:
32- * - Represented as: `paths.*.method.parameters[*].schema.enum`
33- * - This path indicates that the enum is part of a parameter's schema in an operation.
34- * - The function identifies the location of `schema` in the path and returns everything up to (and including) it.
35- *
36- * @param {string[] } path - An array representing the JSONPath structure of the OpenAPI definition.
37- * @returns {string[] } The truncated path pointing to the schema object or property.
38- */
39-
40- export function getSchemaPath ( path ) {
41- if ( path . includes ( 'components' ) ) {
42- const propertyIndex = path . findIndex ( ( item ) => item === 'properties' ) ;
43- if ( propertyIndex !== - 1 ) {
44- // Path is for a component.schema.property enum
45- return path . slice ( 0 , propertyIndex + 2 ) ;
46- }
47- // Path is for a component.schema enum
48- return path . slice ( 0 , 3 ) ;
49- } else if ( path . includes ( 'paths' ) ) {
50- const schemaIndex = path . findIndex ( ( item ) => item === 'schema' ) ;
51- return path . slice ( 0 , schemaIndex + 1 ) ;
52- }
53- return [ ] ;
54- }
55-
5616/**
5717 * Resolves the value of a nested property within an OpenAPI structure using a given path.
5818 *
0 commit comments