You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-3Lines changed: 16 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,14 +44,27 @@ Typewriter is a new solution for generating code files using the GraphODataTempl
44
44
***-m**, **-metadata**: The local file path or URL to the target input metadata. The default value is `https://graph.microsoft.com/v1.0/$metadata`. This value is required.
45
45
***-v**, **-verbosity**: The log verbosity level. The values can be: `Minimal`, `Info`, `Debug`, or `Trace`. The default value is `Minimal`.
46
46
***-o**, **-output**: Specifies the path to the output folder. The default value is the directory that contains typewriter.exe. The structure and contents of the output directory will be different based on the `-generationmode` and `-language` options.
47
-
***-d**, **-docs**: Specifies the path to the local root of the [microsoft-graph-docs](https://github.com/microsoftgraph/microsoft-graph-docs) repo. The default value is the directory that contains typewriter.exe. The documentation is parsed to provide documentation annotations to the metadata which is then used to add doc comments in the generated code files. This option is required when using `-generationmode` values of `Metadata`or `Full`.
48
-
***-g**, **-generationmode**: Specifies the generation mode. The values can be: `Full`, `Metadata`, or `Files`. `Full` (default) generation mode produces the output code files by cleaning the input metadata, parsing the documentation, and adding annotations before generating the output files. `Metadata` generation mode produces an output metadata file by cleaning metadata, documentation parsing, and adding documentation annotations. `Files` generation mode produces code files from an input metadata and bypasses the cleaning, documentation parsing, and adding documentation annotations.
47
+
***-d**, **-docs**: Specifies the path to the local root of the [microsoft-graph-docs](https://github.com/microsoftgraph/microsoft-graph-docs) repo. The default value is the directory that contains typewriter.exe. The documentation is parsed to provide documentation annotations to the metadata which is then used to add doc comments in the generated code files. This option is required when using `-generationmode` values of `Metadata`, `Full`, or `TransformWithDocs`.
48
+
***-g**, **-generationmode**: Specifies the generation mode. The values can be: `Full`, `Metadata`, `Files`, `Transform`or `TransformWithDocs`. `Full` (default) generation mode produces the output code files by cleaning the input metadata, parsing the documentation, and adding annotations before generating the output files. `Metadata` generation mode produces an output metadata file by cleaning metadata, documentation parsing, and adding documentation annotations. `Files` generation mode produces code files from an input metadata and bypasses the cleaning, documentation parsing, and adding documentation annotations. `Transform` generation mode processes the metadata according to the XSLT provided with the -t option. `TransformWithDocs` generation mode processes the metadata according to the XSLT and adds documentation annotations. `Transform` and `TransformWithDocs` require the -t argument to specify the XSLT file.
49
49
***-f**, **-outputMetadataFileName**: The base output metadata filename. Only applicable for `-generationmode Metadata`. The default value is `cleanMetadataWithDescriptions` which is used with the value of the `-endpointVersion` to generate a metadata file named `cleanMetadataWithDescriptionsv1.0.xml`.
50
50
***-e**, **-endpointVersion**: The endpoint version used when naming a metadata file. Expected values are `v1.0` and `beta`. Only applicable for `-generationmode Metadata`.
51
51
***-p**, **-properties**: Specify properties to support generation logic in the T4 templates. Properties must take the form of *key-string:value-string*. Multiple properties can be specified by setting a space in between property. The only property currently supported is the *php.namespace* property to specify the generated model file namespace. This property is optional.
52
+
***-t**, **-transform**: Specify the URI to the XSLT that will preprocess the metadata. Only applicable for `-generationmode Transform` or `-generationmode TransformWitDocs`.
52
53
53
54
### Example typewriter usage
54
55
56
+
#### Transform metadata with XSLT.
57
+
58
+
The output `cleanMetadata.xml` will be located in the same directory as typewriter.exe.
59
+
60
+
`.\typewriter.exe -v Info -m https://raw.githubusercontent.com/microsoftgraph/msgraph-metadata/mm/xslt/v1.0_metadata.xml -g Transform -t https://raw.githubusercontent.com/microsoftgraph/msgraph-metadata/mm/xslt/transforms/csdl/preprocess_csdl.xsl`
61
+
62
+
#### Transform metadata with XSLT and add documentation annotations.
63
+
64
+
The output `cleanMetadataWithDescriptionsv1.0.xml` will be located in the same directory as typewriter.exe.
#### Generate TypeScript typings from a CSDL (metadata) file without cleaning or annotating the CSDL.
56
69
57
70
The output will go in to the `outputTypeScript` directory.
@@ -113,7 +126,7 @@ Example :
113
126
114
127
It is important to understand that subprocessors are mapped to methods that query the **OdcmModel** and return a set of OData objects. This mapping is maintained in [TemplateProcess.InitializeSubprocessor()](https://github.com/microsoftgraph/MSGraph-SDK-Code-Generator/blob/dev/src/GraphODataTemplateWriter/TemplateProcessor/TemplateProcessor.cs#L54). The language specific mappings exist in the [config directory](https://github.com/microsoftgraph/MSGraph-SDK-Code-Generator/tree/dev/src/GraphODataTemplateWriter/.config). Each OData object returned by the subprocessor is applied to the mapped template which results in a code file output per each OData object.
115
128
116
-
In the above example, the objects in result set of the NavigationCollectionProperty subprocessor will each be applied to the EntityCollectionPage template. Each result will be a code file for each object returned by the NavigationCollectionProperty subprocessor.
129
+
In the above example, the objects in result set of the NavigationCollectionProperty subprocessor will each be applied to the EntityCollectionPage template. Each result will be a code file for each object returned by the NavigationCollectionProperty subprocessor.
Copy file name to clipboardExpand all lines: src/Typewriter/Options.cs
+16-3Lines changed: 16 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,15 @@ public enum GenerationMode
32
32
/// <summary>
33
33
/// Uses the input metadata and only generates code files for the target platform. It bypasses the cleaning, doc parsing, and adding doc annotations.
34
34
/// </summary>
35
-
Files
35
+
Files,
36
+
/// <summary>
37
+
/// Uses the input metadata to transform the CSDL with the specified XSLT.
38
+
/// </summary>
39
+
Transform,
40
+
/// <summary>
41
+
/// Uses the input metadata to transform the CSDL with the specified XSLT and adds documentation annotations.
42
+
/// </summary>
43
+
TransformWithDocs
36
44
}
37
45
38
46
publicclassOptions
@@ -52,10 +60,11 @@ public class Options
52
60
[Option('d',"docs",Default=".",HelpText="Path to the root of the documentation repo folder")]
53
61
publicstringDocsRoot{get;set;}
54
62
55
-
[Option('g',"generationmode",Default=GenerationMode.Full,HelpText="Specifies the generation mode. The values can be: Full, Metadata, or Files. Full generation mode produces "+
63
+
[Option('g',"generationmode",Default=GenerationMode.Full,HelpText="Specifies the generation mode. The values can be: Full, Metadata, Files, Transform, or TransformWithDocs. Full generation mode produces "+
56
64
"the output code files by cleaning the input metadata, parsing the documentation, and adding annotations before generating the output files. Metadata generation mode"+
57
65
"produces an output metadata file by cleaning metadata, documentation parsing, and adding documentation annotations. Files generation mode produces code files from"+
58
-
"an input metadata and bypasses the cleaning, documentation parsing, and adding documentation annotations.")]
66
+
"an input metadata and bypasses the cleaning, documentation parsing, and adding documentation annotations. Transform generation mode processes the metadata according to the"+
67
+
"XSLT provided with the -t option. TransformWithDocs generation mode processes the metadata according to the XSLT and adds documentation annotations.")]
59
68
publicGenerationModeGenerationMode{get;set;}
60
69
61
70
[Option('f',"outputMetadataFileName",Default="cleanMetadataWithDescriptions",HelpText="The output metadata filename. Only applicable for GenerationMode.Metadata.")]
@@ -68,5 +77,9 @@ public class Options
68
77
"templates from the TemplateWriterSettings object returned by ConfigurationService.Settings. The suggested convention for specifying a key should be "+
69
78
"the targeted template language name and the property name. For example, php.namespace:Microsoft\\Graph\\Beta\\Model would be a property to be consumed in the PHP templates.")]
70
79
publicIEnumerable<string>Properties{get;set;}
80
+
81
+
[Option('t',"transform",HelpText="Specify the URI to the XSLT that will preprocess the metadata. Overrides the"+
82
+
"cleaning done by embeddeded typewriter.exe rules.")]
Copy file name to clipboardExpand all lines: test/Typewriter.Test/Given_a_valid_metadata_file_to_Typewriter.cs
+52Lines changed: 52 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -468,5 +468,57 @@ public void It_creates_disambiguated_IEntityRequestBuilder_parameters()
468
468
469
469
Assert.IsTrue(hasTestParameter,$"The expected test token string, '{testParameter}', was not set in the generated test file. We didn't properly generate the parameter.");
0 commit comments