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
* Improvements to the ogschema tool
Added more documentation
Added file and directory validation
Added support for custom file name for output file
Added support for specifying your own namespace
Made all classes partial. This allow developers to add helper methods etc. without changing the generated file.
Made parameter parsing more robust
Uses IO classes to handle OS specific path delimiters
* Bugfix: check if schema property has searchable attribute
Custom content source might not have this attribute, and the generation fails. Added check, returns false by default.
* Missed the partial on classes with inheritance
---------
Co-authored-by: manh.nguyen <[email protected]>
Copy file name to clipboardExpand all lines: README.md
+49-7
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ From repository level:
17
17
18
18
#### Run Integration tests
19
19
- Configure appsettings.json file in `.\APIs\src\Testing\EPiServer.ContentGraph.IntegrationTests` to connect to GraphQL gateway.
20
-
If appsettings.json was ready, from repository level:
20
+
If appsettings.json was ready, from repository level:
21
21
- Run `cd msbuild`
22
22
- Run `powershell .\intergrationTest.ps1` if you're using Command Line or `.\intergrationTest.ps1` if PowerShell
23
23
@@ -32,15 +32,57 @@ If appsettings.json was ready, from repository level:
32
32
- On the way...
33
33
34
34
### Optimizely Graph Client Tool
35
-
This tool supports for generating Optimizely Graph's schema to C# object models. You do not need to create models manually if install this tool.
35
+
This tool will generate C# classes (models) based on Optimizely Graph's schema. The Client SDK graph builder classes uses these models to provide strongly typed access to the Graph data.
36
+
36
37
#### Install Optimizely Graph Client Tool
37
-
From repository level:
38
-
- Run `mkdir ogtools`
39
-
- Run `cd ogtools`
38
+
You typically want to install this tool into your solution directory. It is installed as a `dotnet tool` which you can invoke using the `dotnet` command. If you install the tool at the root of your solution (where your .sln and/or .git directory is located), the command will also work in all subdirectories.
39
+
Open a command line, navigate to the root of your repository/solution:
40
40
- Run `dotnet new tool-manifest`
41
41
- Run `dotnet tool install Optimizely.Graph.Client.Tools --local`
42
-
- Run `dotnet ogschema path_to_your_appsettings.json path_to_store_your_models`
43
-
When the last command is succeed you will see the models will be generated in file `GraphModels.cs` located in the `path_to_store_your_models` you have ran in last command.
42
+
43
+
You can now invoke the `ogschema` tool using the follwing command:\
This will create a file `GraphModels.cs` in the `path_to_store_your_models` directory.
47
+
48
+
#### Example installation
49
+
50
+
You have an ASP.NET project in `c:\dev\alloy\`, and the following file setup
51
+
```
52
+
alloy.sln
53
+
\src
54
+
alloy.csproj
55
+
\Models
56
+
\Controllers
57
+
...
58
+
\docs
59
+
readme.md
60
+
```
61
+
1. Open a command prompt at the root of your ASP.NET project (`c:\dev\alloy\`)
62
+
2. Run the following command: `dotnet new tool-manifest`
63
+
3. This will generate a `.config` folder with a dotnet tool manifest
64
+
4. Run the following command: `dotnet tool install Optimizely.Graph.Client.Tools --local`
65
+
5. This will register the ogschema tool in the manifest, and allow the tool to be invoked anywhere in or below `c:\dev\alloy\`
66
+
6. Change to your src directory: `cd src`
67
+
7. Run the following command: `dotnet ogschema appsettings.json Models`
68
+
8. This will generate a file called `GraphModels.cs` in the Models directory
69
+
70
+
In this example, your `appSettings.config` file must have the necessary Optimizely Graph settings. See the [developer documentation](https://docs.developers.optimizely.com/platform-optimizely/v1.4.0-optimizely-graph/docs/configure-package-settings-in-aspnet-core) for more information.
1. will look for an `appsettings.json` file in the current directory
83
+
2. will create a file called `MyContentSource.cs` in the `Models` directory below the current directory
84
+
3. will generate model classes for the [content source](https://docs.developers.optimizely.com/platform-optimizely/v1.4.0-optimizely-graph/docs/synchronize-content-types) called `dt1`. This could be a custom content source that you have created previously
85
+
4. The namespace used in the `MyContentSource.cs` file will be `Alloy.Models`
0 commit comments