@@ -64,7 +64,7 @@ public void RegisterComponents(OpenApiDocument document)
64
64
{
65
65
if ( document ? . Components == null ) return ;
66
66
67
- string baseUri = document . BaseUri + OpenApiConstants . ComponentsSegment ;
67
+ string baseUri = getBaseUri ( document ) ;
68
68
string location ;
69
69
70
70
// Register Schema
@@ -139,6 +139,33 @@ public void RegisterComponents(OpenApiDocument document)
139
139
}
140
140
}
141
141
142
+ private string getBaseUri ( OpenApiDocument openApiDocument )
143
+ {
144
+ return openApiDocument . BaseUri + OpenApiConstants . ComponentsSegment ;
145
+ }
146
+
147
+ /// <summary>
148
+ /// Registers a schema for a document in the workspace
149
+ /// </summary>
150
+ /// <param name="openApiDocument">The document to register the schema for.</param>
151
+ /// <param name="openApiSchema">The schema to register.</param>
152
+ /// <param name="id">The id of the schema.</param>
153
+ /// <returns>true if the schema is successfully registered; otherwise false.</returns>
154
+ /// <exception cref="ArgumentNullException">openApiDocument is null</exception>
155
+ /// <exception cref="ArgumentNullException">openApiSchema is null</exception>
156
+ /// <exception cref="ArgumentNullException">id is null or empty</exception>
157
+ public bool RegisterSchemaForDocument ( OpenApiDocument openApiDocument , OpenApiSchema openApiSchema , string id )
158
+ {
159
+ Utils . CheckArgumentNull ( openApiDocument ) ;
160
+ Utils . CheckArgumentNull ( openApiSchema ) ;
161
+ Utils . CheckArgumentNullOrEmpty ( id ) ;
162
+
163
+ var baseUri = getBaseUri ( openApiDocument ) ;
164
+
165
+ var location = baseUri + ReferenceType . Schema . GetDisplayName ( ) + ComponentSegmentSeparator + id ;
166
+
167
+ return RegisterComponent ( location , openApiSchema ) ;
168
+ }
142
169
143
170
/// <summary>
144
171
/// Registers a component in the component registry.
0 commit comments