@@ -15,6 +15,7 @@ public class OpenApiReferenceTests
1515 [ InlineData ( "#/components/schemas/Pet" , ReferenceType . Schema , "Pet" ) ]
1616 [ InlineData ( "#/components/parameters/name" , ReferenceType . Parameter , "name" ) ]
1717 [ InlineData ( "#/components/responses/200" , ReferenceType . Response , "200" ) ]
18+ [ InlineData ( "#/components/schemas/HttpValidationsProblem" , ReferenceType . Schema , "HttpValidationsProblem" ) ]
1819 public void SettingInternalReferenceForComponentsStyleReferenceShouldSucceed (
1920 string input ,
2021 ReferenceType type ,
@@ -43,6 +44,7 @@ public void SettingInternalReferenceForComponentsStyleReferenceShouldSucceed(
4344 [ InlineData ( "Pet.json#/components/schemas/Pet" , "Pet.json" , "Pet" , ReferenceType . Schema ) ]
4445 [ InlineData ( "Pet.yaml#/components/schemas/Pet" , "Pet.yaml" , "Pet" , ReferenceType . Schema ) ]
4546 [ InlineData ( "abc#/components/schemas/Pet" , "abc" , "Pet" , ReferenceType . Schema ) ]
47+ [ InlineData ( "abc#/components/schemas/HttpsValidationProblem" , "abc" , "HttpsValidationProblem" , ReferenceType . Schema ) ]
4648 public void SettingExternalReferenceV3ShouldSucceed ( string expected , string externalResource , string id , ReferenceType ? type )
4749 {
4850 // Arrange & Act
@@ -105,6 +107,30 @@ public async Task SerializeSchemaReferenceAsJsonV3Works()
105107 Assert . Equal ( expected , actual ) ;
106108 }
107109
110+ [ Theory ]
111+ [ InlineData ( "HttpValidationProblemDetails" , "#/components/schemas/HttpValidationProblemDetails" ) ]
112+ [ InlineData ( "http://example.com" , "http://example.com" ) ]
113+ [ InlineData ( "https://example.com" , "https://example.com" ) ]
114+ public async Task SerializeHttpSchemaReferenceAsJsonV31Works ( string id , string referenceV3 )
115+ {
116+ // Arrange
117+ var reference = new OpenApiReference { Type = ReferenceType . Schema , Id = id } ;
118+ var expected =
119+ $$ """
120+ {
121+ "$ref": "{{ referenceV3 }} "
122+ }
123+ """ ;
124+
125+ // Act
126+ var actual = await reference . SerializeAsJsonAsync ( OpenApiSpecVersion . OpenApi3_1 ) ;
127+ expected = expected . MakeLineBreaksEnvironmentNeutral ( ) ;
128+ actual = actual . MakeLineBreaksEnvironmentNeutral ( ) ;
129+
130+ // Assert
131+ Assert . Equal ( expected , actual ) ;
132+ }
133+
108134 [ Fact ]
109135 public async Task SerializeSchemaReferenceAsYamlV3Works ( )
110136 {
0 commit comments