@@ -632,7 +632,8 @@ private void SerializeAsV2(
632632 private void SerializeTypeProperty ( JsonSchemaType ? type , IOpenApiWriter writer , OpenApiSpecVersion version )
633633 {
634634 // check whether nullable is true for upcasting purposes
635- var isNullable = Nullable ||
635+ var isNullable = Nullable ||
636+ Type is JsonSchemaType . Null ||
636637 Extensions is not null &&
637638 Extensions . TryGetValue ( OpenApiConstants . NullableExtension , out var nullExtRawValue ) &&
638639 nullExtRawValue is OpenApiAny { Node : JsonNode jsonNode } &&
@@ -652,9 +653,14 @@ Extensions is not null &&
652653 case OpenApiSpecVersion . OpenApi3_1 when isNullable :
653654 UpCastSchemaTypeToV31 ( type . Value , writer ) ;
654655 break ;
655- case OpenApiSpecVersion . OpenApi3_0 when isNullable :
656+ case OpenApiSpecVersion . OpenApi3_0 when isNullable && type . Value == JsonSchemaType . Null :
656657 writer . WriteProperty ( OpenApiConstants . Nullable , true ) ;
657- goto default ;
658+ writer . WriteProperty ( OpenApiConstants . Type , JsonSchemaType . Object . ToIdentifier ( ) ) ;
659+ break ;
660+ case OpenApiSpecVersion . OpenApi3_0 when isNullable && type . Value != JsonSchemaType . Null :
661+ writer . WriteProperty ( OpenApiConstants . Nullable , true ) ;
662+ writer . WriteProperty ( OpenApiConstants . Type , type . Value . ToIdentifier ( ) ) ;
663+ break ;
658664 default :
659665 writer . WriteProperty ( OpenApiConstants . Type , type . Value . ToIdentifier ( ) ) ;
660666 break ;
0 commit comments