File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
src/Microsoft.OpenApi/Models Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -587,6 +587,21 @@ public static ReadResult Parse(string input,
587587 {
588588 return OpenApiModelFactory . Parse ( input , format , settings ) ;
589589 }
590+ /// <summary>
591+ /// Adds a schema to the components object of the current document.
592+ /// </summary>
593+ /// <param name="openApiSchema">The schema to add</param>
594+ /// <param name="id">The id for the component</param>
595+ /// <returns>Whether the schema was added to the components.</returns>
596+ public bool AddComponentSchema ( string id , OpenApiSchema openApiSchema )
597+ {
598+ Utils . CheckArgumentNull ( openApiSchema ) ;
599+ Utils . CheckArgumentNullOrEmpty ( id ) ;
600+ Components ??= new ( ) ;
601+ Components . Schemas ??= new Dictionary < string , OpenApiSchema > ( ) ;
602+ Components . Schemas . Add ( id , openApiSchema ) ;
603+ return Workspace ? . RegisterSchemaForDocument ( this , openApiSchema , id ) ?? false ;
604+ }
590605 }
591606
592607 internal class FindSchemaReferences : OpenApiVisitorBase
You can’t perform that action at this time.
0 commit comments