@@ -41,6 +41,7 @@ use dsc_lib::{
4141 extension_manifest:: ExtensionManifest ,
4242 } ,
4343 functions:: FunctionDefinition ,
44+ schemas:: dsc_repo:: { DscRepoSchema , RecognizedSchemaVersion , SchemaForm , SchemaUriPrefix } ,
4445 util:: {
4546 get_setting,
4647 parse_input_to_json,
@@ -162,37 +163,37 @@ pub fn add_fields_to_json(json: &str, fields_to_add: &HashMap<String, String>) -
162163pub fn get_schema ( schema : SchemaType ) -> Schema {
163164 match schema {
164165 SchemaType :: AdaptedDscResourceManifest => {
165- schema_for ! ( AdaptedDscResourceManifest )
166+ repo_schema :: < AdaptedDscResourceManifest > ( )
166167 } ,
167168 SchemaType :: Configuration => {
168- schema_for ! ( Configuration )
169+ repo_schema :: < Configuration > ( )
169170 } ,
170171 SchemaType :: ConfigurationExportResult => {
171- schema_for ! ( ConfigurationExportResult )
172+ repo_schema :: < ConfigurationExportResult > ( )
172173 } ,
173174 SchemaType :: ConfigurationGetResult => {
174- schema_for ! ( ConfigurationGetResult )
175+ repo_schema :: < ConfigurationGetResult > ( )
175176 } ,
176177 SchemaType :: ConfigurationSetResult => {
177- schema_for ! ( ConfigurationSetResult )
178+ repo_schema :: < ConfigurationSetResult > ( )
178179 } ,
179180 SchemaType :: ConfigurationTestResult => {
180- schema_for ! ( ConfigurationTestResult )
181+ repo_schema :: < ConfigurationTestResult > ( )
181182 } ,
182183 SchemaType :: DscResource => {
183- schema_for ! ( DscResource )
184+ repo_schema :: < DscResource > ( )
184185 } ,
185186 SchemaType :: ExtensionDiscoverResult => {
186- schema_for ! ( DiscoverResult )
187+ repo_schema :: < DiscoverResult > ( )
187188 } ,
188189 SchemaType :: ExtensionManifest => {
189- schema_for ! ( ExtensionManifest )
190+ repo_schema :: < ExtensionManifest > ( )
190191 } ,
191192 SchemaType :: FunctionDefinition => {
192- schema_for ! ( FunctionDefinition )
193+ repo_schema :: < FunctionDefinition > ( )
193194 } ,
194195 SchemaType :: GetResult => {
195- schema_for ! ( GetResult )
196+ repo_schema :: < GetResult > ( )
196197 } ,
197198 SchemaType :: Include => {
198199 schema_for ! ( Include )
@@ -201,35 +202,48 @@ pub fn get_schema(schema: SchemaType) -> Schema {
201202 schema_for ! ( ManifestList )
202203 } ,
203204 SchemaType :: ResolveResult => {
204- schema_for ! ( ResolveResult )
205+ repo_schema :: < ResolveResult > ( )
205206 } ,
206207 SchemaType :: Resource => {
207- schema_for ! ( Resource )
208+ repo_schema :: < Resource > ( )
208209 } ,
209210 SchemaType :: ResourceGetResult => {
210- schema_for ! ( ResourceGetResult )
211+ repo_schema :: < ResourceGetResult > ( )
211212 } ,
212213 SchemaType :: ResourceSetResult => {
213- schema_for ! ( ResourceSetResult )
214+ repo_schema :: < ResourceSetResult > ( )
214215 } ,
215216 SchemaType :: ResourceTestResult => {
216- schema_for ! ( ResourceTestResult )
217+ repo_schema :: < ResourceTestResult > ( )
217218 } ,
218219 SchemaType :: ResourceManifest => {
219- schema_for ! ( ResourceManifest )
220+ repo_schema :: < ResourceManifest > ( )
220221 } ,
221222 SchemaType :: RestartRequired => {
222- schema_for ! ( RestartRequired )
223+ repo_schema :: < RestartRequired > ( )
223224 } ,
224225 SchemaType :: SetResult => {
225- schema_for ! ( SetResult )
226+ repo_schema :: < SetResult > ( )
226227 } ,
227228 SchemaType :: TestResult => {
228- schema_for ! ( TestResult )
229+ repo_schema :: < TestResult > ( )
229230 } ,
230231 }
231232}
232233
234+ fn repo_schema < T : DscRepoSchema > ( ) -> Schema {
235+ let schema_form = if T :: SCHEMA_SHOULD_BUNDLE {
236+ SchemaForm :: Bundled
237+ } else {
238+ SchemaForm :: Canonical
239+ } ;
240+ T :: generate_schema (
241+ RecognizedSchemaVersion :: default ( ) ,
242+ schema_form,
243+ SchemaUriPrefix :: AkaDotMs
244+ )
245+ }
246+
233247/// Write the JSON object to the console
234248///
235249/// # Arguments
0 commit comments