@@ -139,6 +139,7 @@ public T ReadFragment<T>(JsonNode input, AsyncApiVersion version, out AsyncApiDi
139139 where T : IAsyncApiElement
140140 {
141141 diagnostic = new AsyncApiDiagnostic ( ) ;
142+ diagnostic . SpecificationVersion = version ;
142143 this . context ??= new ParsingContext ( diagnostic , this . settings )
143144 {
144145 ExtensionParsers = this . settings . ExtensionParsers ,
@@ -363,58 +364,61 @@ private IAsyncApiSerializable ResolveStreamReference(Stream stream, IAsyncApiRef
363364 }
364365 }
365366
366- AsyncApiDiagnostic fragmentDiagnostic = new AsyncApiDiagnostic ( ) ;
367+ AsyncApiDiagnostic fragmentDiagnostic = new AsyncApiDiagnostic
368+ {
369+ SpecificationVersion = diagnostic . SpecificationVersion ,
370+ } ;
367371 IAsyncApiSerializable result = null ;
368372 switch ( reference . Reference . Type )
369373 {
370374 case ReferenceType . Schema :
371375 if ( reference is AsyncApiJsonSchemaReference )
372376 {
373- result = this . ReadFragment < AsyncApiJsonSchema > ( json , AsyncApiVersion . AsyncApi2_0 , out fragmentDiagnostic ) ;
377+ result = this . ReadFragment < AsyncApiJsonSchema > ( json , diagnostic . SpecificationVersion , out fragmentDiagnostic ) ;
374378 }
375379
376380 if ( reference is AsyncApiAvroSchemaReference )
377381 {
378- result = this . ReadFragment < AsyncApiAvroSchema > ( json , AsyncApiVersion . AsyncApi2_0 , out fragmentDiagnostic ) ;
382+ result = this . ReadFragment < AsyncApiAvroSchema > ( json , diagnostic . SpecificationVersion , out fragmentDiagnostic ) ;
379383 }
380384
381385 break ;
382386
383387 case ReferenceType . Server :
384- result = this . ReadFragment < AsyncApiServer > ( json , AsyncApiVersion . AsyncApi2_0 , out fragmentDiagnostic ) ;
388+ result = this . ReadFragment < AsyncApiServer > ( json , diagnostic . SpecificationVersion , out fragmentDiagnostic ) ;
385389 break ;
386390 case ReferenceType . Channel :
387- result = this . ReadFragment < AsyncApiChannel > ( json , AsyncApiVersion . AsyncApi2_0 , out fragmentDiagnostic ) ;
391+ result = this . ReadFragment < AsyncApiChannel > ( json , diagnostic . SpecificationVersion , out fragmentDiagnostic ) ;
388392 break ;
389393 case ReferenceType . Message :
390- result = this . ReadFragment < AsyncApiMessage > ( json , AsyncApiVersion . AsyncApi2_0 , out fragmentDiagnostic ) ;
394+ result = this . ReadFragment < AsyncApiMessage > ( json , diagnostic . SpecificationVersion , out fragmentDiagnostic ) ;
391395 break ;
392396 case ReferenceType . SecurityScheme :
393- result = this . ReadFragment < AsyncApiSecurityScheme > ( json , AsyncApiVersion . AsyncApi2_0 , out fragmentDiagnostic ) ;
397+ result = this . ReadFragment < AsyncApiSecurityScheme > ( json , diagnostic . SpecificationVersion , out fragmentDiagnostic ) ;
394398 break ;
395399 case ReferenceType . Parameter :
396- result = this . ReadFragment < AsyncApiParameter > ( json , AsyncApiVersion . AsyncApi2_0 , out fragmentDiagnostic ) ;
400+ result = this . ReadFragment < AsyncApiParameter > ( json , diagnostic . SpecificationVersion , out fragmentDiagnostic ) ;
397401 break ;
398402 case ReferenceType . CorrelationId :
399- result = this . ReadFragment < AsyncApiCorrelationId > ( json , AsyncApiVersion . AsyncApi2_0 , out fragmentDiagnostic ) ;
403+ result = this . ReadFragment < AsyncApiCorrelationId > ( json , diagnostic . SpecificationVersion , out fragmentDiagnostic ) ;
400404 break ;
401405 case ReferenceType . OperationTrait :
402- result = this . ReadFragment < AsyncApiOperationTrait > ( json , AsyncApiVersion . AsyncApi2_0 , out fragmentDiagnostic ) ;
406+ result = this . ReadFragment < AsyncApiOperationTrait > ( json , diagnostic . SpecificationVersion , out fragmentDiagnostic ) ;
403407 break ;
404408 case ReferenceType . MessageTrait :
405- result = this . ReadFragment < AsyncApiMessageTrait > ( json , AsyncApiVersion . AsyncApi2_0 , out fragmentDiagnostic ) ;
409+ result = this . ReadFragment < AsyncApiMessageTrait > ( json , diagnostic . SpecificationVersion , out fragmentDiagnostic ) ;
406410 break ;
407411 case ReferenceType . ServerBindings :
408- result = this . ReadFragment < AsyncApiBindings < IServerBinding > > ( json , AsyncApiVersion . AsyncApi2_0 , out fragmentDiagnostic ) ;
412+ result = this . ReadFragment < AsyncApiBindings < IServerBinding > > ( json , diagnostic . SpecificationVersion , out fragmentDiagnostic ) ;
409413 break ;
410414 case ReferenceType . ChannelBindings :
411- result = this . ReadFragment < AsyncApiBindings < IChannelBinding > > ( json , AsyncApiVersion . AsyncApi2_0 , out fragmentDiagnostic ) ;
415+ result = this . ReadFragment < AsyncApiBindings < IChannelBinding > > ( json , diagnostic . SpecificationVersion , out fragmentDiagnostic ) ;
412416 break ;
413417 case ReferenceType . OperationBindings :
414- result = this . ReadFragment < AsyncApiBindings < IOperationBinding > > ( json , AsyncApiVersion . AsyncApi2_0 , out fragmentDiagnostic ) ;
418+ result = this . ReadFragment < AsyncApiBindings < IOperationBinding > > ( json , diagnostic . SpecificationVersion , out fragmentDiagnostic ) ;
415419 break ;
416420 case ReferenceType . MessageBindings :
417- result = this . ReadFragment < AsyncApiBindings < IMessageBinding > > ( json , AsyncApiVersion . AsyncApi2_0 , out fragmentDiagnostic ) ;
421+ result = this . ReadFragment < AsyncApiBindings < IMessageBinding > > ( json , diagnostic . SpecificationVersion , out fragmentDiagnostic ) ;
418422 break ;
419423 default :
420424 diagnostic . Errors . Add ( new AsyncApiError ( reference . Reference . Reference , "Could not resolve reference." ) ) ;
0 commit comments