fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add Redfish-like YAML test for versioned schemas

- Created test specs with YAML files mimicking Redfish structure
- Added comprehensive test for versioned schema names
- Verified sibling schemas are hoisted correctly with YAML
- All 4 bundle tests pass

Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>

+108 -1
-1
.github/workflows/pullfrog.yml
··· 43 43 GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }} 44 44 DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }} 45 45 OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }} 46 -
+55
packages/json-schema-ref-parser/src/__tests__/bundle.test.ts
··· 106 106 type: 'object', 107 107 }); 108 108 }); 109 + 110 + it('hoists sibling schemas from YAML files with versioned names (Redfish-like)', async () => { 111 + const refParser = new $RefParser(); 112 + const pathOrUrlOrSchema = path.join( 113 + getSpecsPath(), 114 + 'json-schema-ref-parser', 115 + 'redfish-like.yaml', 116 + ); 117 + const schema = (await refParser.bundle({ pathOrUrlOrSchema })) as any; 118 + 119 + // Verify the main schema references are hoisted 120 + const systemsSchema = 121 + schema.paths['/redfish/v1/Systems'].get.responses['200'].content['application/json'].schema; 122 + expect(systemsSchema.$ref).toContain('ResolutionStep'); 123 + 124 + const actionsSchema = 125 + schema.paths['/redfish/v1/Actions'].post.responses['200'].content['application/json'].schema; 126 + expect(actionsSchema.$ref).toContain('ActionParameters'); 127 + 128 + // All three schemas from the external YAML should be hoisted 129 + expect(schema.components).toBeDefined(); 130 + expect(schema.components.schemas).toBeDefined(); 131 + 132 + const schemaKeys = Object.keys(schema.components.schemas); 133 + 134 + // ResolutionStep (directly referenced) 135 + const resolutionStepKey = schemaKeys.find( 136 + (k) => k.includes('ResolutionStep') && !k.includes('Type') && !k.includes('ActionParameters'), 137 + ); 138 + expect(resolutionStepKey).toBeDefined(); 139 + 140 + // ResolutionType (sibling, referenced by ResolutionStep and ActionParameters) 141 + const resolutionTypeKey = schemaKeys.find((k) => k.includes('ResolutionType')); 142 + expect(resolutionTypeKey).toBeDefined(); 143 + expect(schema.components.schemas[resolutionTypeKey!]).toEqual({ 144 + description: 'Types of resolution actions', 145 + enum: ['ContactVendor', 'ResetToDefaults', 'RetryOperation'], 146 + type: 'string', 147 + }); 148 + 149 + // ActionParameters (directly referenced) 150 + const actionParamsKey = schemaKeys.find((k) => k.includes('ActionParameters')); 151 + expect(actionParamsKey).toBeDefined(); 152 + 153 + // Verify that internal $refs in hoisted schemas point to hoisted locations 154 + const resolutionStep = schema.components.schemas[resolutionStepKey!]; 155 + expect(resolutionStep.properties.ResolutionType.oneOf[0].$ref).toContain('ResolutionType'); 156 + expect(resolutionStep.properties.ResolutionType.oneOf[0].$ref).toMatch( 157 + /^#\/components\/schemas\//, 158 + ); 159 + 160 + const actionParams = schema.components.schemas[actionParamsKey!]; 161 + expect(actionParams.properties.ActionType.$ref).toContain('ResolutionType'); 162 + expect(actionParams.properties.ActionType.$ref).toMatch(/^#\/components\/schemas\//); 163 + }); 109 164 });
+25
specs/json-schema-ref-parser/ResolutionStep.v1_0_1.yaml
··· 1 + components: 2 + schemas: 3 + ResolutionStep_v1_0_1_ResolutionStep: 4 + type: object 5 + properties: 6 + ResolutionType: 7 + oneOf: 8 + - $ref: '#/components/schemas/ResolutionStep_v1_0_1_ResolutionType' 9 + ActionName: 10 + type: string 11 + description: Name of the action 12 + ResolutionStep_v1_0_1_ResolutionType: 13 + type: string 14 + enum: 15 + - ContactVendor 16 + - ResetToDefaults 17 + - RetryOperation 18 + description: Types of resolution actions 19 + ResolutionStep_v1_0_1_ActionParameters: 20 + type: object 21 + properties: 22 + ActionId: 23 + type: string 24 + ActionType: 25 + $ref: '#/components/schemas/ResolutionStep_v1_0_1_ResolutionType'
+28
specs/json-schema-ref-parser/redfish-like.yaml
··· 1 + openapi: 3.0.0 2 + info: 3 + title: Redfish-like API 4 + version: '1.0.0' 5 + description: Test API simulating Redfish structure with versioned schemas 6 + paths: 7 + /redfish/v1/Systems: 8 + get: 9 + summary: Get Systems 10 + responses: 11 + '200': 12 + description: Success 13 + content: 14 + application/json: 15 + schema: 16 + $ref: 'ResolutionStep.v1_0_1.yaml#/components/schemas/ResolutionStep_v1_0_1_ResolutionStep' 17 + default: 18 + description: Error 19 + /redfish/v1/Actions: 20 + post: 21 + summary: Submit Action 22 + responses: 23 + '200': 24 + description: Success 25 + content: 26 + application/json: 27 + schema: 28 + $ref: 'ResolutionStep.v1_0_1.yaml#/components/schemas/ResolutionStep_v1_0_1_ActionParameters'