Skip to content

Commit 4bd1685

Browse files
committed
Add document to its workspace when created via parameterless constructor
1 parent 76512a2 commit 4bd1685

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/Microsoft.OpenApi/Models/OpenApiDocument.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft Corporation. All rights reserved.
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

44
using System;
@@ -23,7 +23,7 @@ public class OpenApiDocument : IOpenApiSerializable, IOpenApiExtensible, IBaseDo
2323
/// <summary>
2424
/// Related workspace containing OpenApiDocuments that are referenced in this document
2525
/// </summary>
26-
public OpenApiWorkspace Workspace { get; set; } = new();
26+
public OpenApiWorkspace Workspace { get; set; }
2727

2828
/// <summary>
2929
/// REQUIRED. Provides metadata about the API. The metadata MAY be used by tooling as required.
@@ -88,20 +88,14 @@ public class OpenApiDocument : IOpenApiSerializable, IOpenApiExtensible, IBaseDo
8888
/// </summary>
8989
public Uri BaseUri { get; }
9090

91-
/// <summary>
92-
///
93-
/// </summary>
94-
public string DocumentID { get; }
95-
9691
/// <summary>
9792
/// Parameter-less constructor
9893
/// </summary>
9994
public OpenApiDocument()
10095
{
101-
var documentId = (Servers.FirstOrDefault()?.Url.ToString())
102-
?? "http://openapi.net/" + HashCode;
103-
DocumentID = documentId;
104-
Workspace.AddDocument(documentId, this);
96+
BaseUri = new Uri ("http://openapi.net/" + Guid.NewGuid());
97+
Workspace = new OpenApiWorkspace(BaseUri);
98+
Workspace.AddDocument(this);
10599
}
106100

107101
/// <summary>

0 commit comments

Comments
 (0)