Skip to content

Commit 421e64c

Browse files
committed
Update README.md
1 parent 13615b2 commit 421e64c

1 file changed

Lines changed: 54 additions & 19 deletions

File tree

‎README.md‎

Lines changed: 54 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
# Contentstack model generator
44
This utility is use to generate models based on ContentTypes in Stack.
55

6+
## Requirements
7+
**As of v1.0.0**, this tool targets **.NET 10.0** and requires the **.NET 10.0 SDK or later**. Versions prior to v1.0.0 targeted .NET 7.0.
8+
69
## Installation
710
To install Contenstack model generator run following command:
811
```
@@ -27,11 +30,11 @@ The Contentstack Model Generator supports two authentication methods:
2730
| `-A` | `--authtoken` | The Authtoken for the Content Management API (required for traditional auth) |
2831
| `-b` | `--branch` | The branch header in the API request to fetch or manage modules located within specific branches. |
2932
| `-e` | `--endpoint` | The Contentstack Host for the Content Management API |
30-
| `-n` | `--namespace` | The namespace the classes should be created in |
33+
| `-n` | `--namespace` | The namespace the classes should be created in (Default Value: ContentstackModels) |
3134
| `-N` | `--is-nullable` | The features that protect against throwing a System.NullReferenceException can be disruptive when turned on. |
3235
| `-f` | `--force` | Automatically overwrite files that already exist |
33-
| `-m` | `--modular-block-prefix` | The Modular block Class Prefix. |
34-
| `-g` | `--group-prefix` | The Group Class Prefix. |
36+
| `-m` | `--modular-block-prefix` | The Modular block Class Prefix. (Default Value: MB) |
37+
| `-g` | `--group-prefix` | The Group Class Prefix. (Default Value: Group) |
3538
| `-p` | `--path` | Path to the file or directory to create files in. |
3639

3740
### OAuth 2.0 Options
@@ -106,40 +109,72 @@ Here's what you'll see when running an OAuth command:
106109

107110
$ contentstack.model.generator --oauth -a <api_key> --client-id myclient123 --redirect-uri http://localhost:8184
108111

109-
Contentstack Model Generator v0.5.0
110-
=====================================
111-
112112
OAuth Authentication Required
113113
=============================
114114

115115
Please open the following URL in your browser to authorize the application:
116116

117-
https://app.contentstack.com/#!/apps/6400aa06db64de001a31c8a9/authorize?response_type=code&client_id=myclient123&redirect_uri=http%3A%2F%2Flocalhost%3A8184&code_challenge=...
117+
https://app.contentstack.com/#!/apps/6400aa06db64de001a31c8a9/authorize?response_type=code&client_id=myclient123&redirect_uri=http%3A%2F%2Flocalhost%3A8184&code_challenge=...&code_challenge_method=S256
118118

119119
After authorization, you will be redirected to a local URL.
120120
Please copy the 'code' parameter from the redirect URL and paste it here:
121121

122-
Authorization code: [User pastes the code here]
122+
Authorization code: [paste the code here]
123123

124124
Exchanging authorization code for access token...
125125
OAuth authentication successful!
126-
Access token expires at: 2024-01-15 14:30:00 UTC
126+
Access token expires at: 2026-01-15 14:30:00 UTC
127+
Fetching stack details for the provided API key.
128+
No path specified. Generating files in the current working directory: /Users/you/project.
129+
Fetching content types from My Contentstack Stack stack.
130+
Found 5 content types.
131+
Total content types fetched: 5.
132+
Fetching global fields from stack: My Contentstack Stack.
133+
Found 2 global fields.
134+
Total global fields fetched: 2.
135+
Generating files from content types.
136+
Files created successfully.
137+
Opening output directory: /Users/you/project.
127138

128-
Fetching stack information...
129-
Stack: My Contentstack Stack
130-
API Key: api_key
139+
Logging out from OAuth...
140+
OAuth logout successful!
141+
```
131142

132-
Fetching content types...
133-
Found 5 content types:
134-
Generating files from content type
143+
## Generated Code
135144

136-
Files successfully created!
137-
Opening <file_path>/Models
145+
**As of v1.0.0**, generated model files use **System.Text.Json** instead of Newtonsoft.Json:
138146

139-
Logging out from OAuth...
140-
OAuth logout successful!
147+
- Properties are decorated with `[JsonPropertyName("...")]` instead of `[JsonProperty(propertyName: "...")]`.
148+
- Generated files reference `System.Text.Json`, `System.Text.Json.Nodes`, and `System.Text.Json.Serialization` instead of `Newtonsoft.Json`.
149+
- Generated converters (for embedded objects and modular blocks) inherit `System.Text.Json.Serialization.JsonConverter<T>` and implement `Read`/`Write` instead of Newtonsoft's `JsonConverter<T>` with `ReadJson`/`WriteJson`.
150+
151+
A generated model file looks like this:
152+
153+
```csharp
154+
using System;
155+
using System.Text.Json;
156+
using System.Text.Json.Nodes;
157+
using System.Text.Json.Serialization;
158+
using Contentstack.Core.Models;
159+
using Contentstack.Utils.Interfaces;
160+
161+
namespace ContentstackModels.Models
162+
{
163+
public partial class BlogPost : IEmbeddedObject
164+
{
165+
public const string ContentType = "blog_post";
166+
[JsonPropertyName("uid")]
167+
public string Uid { get; set; }
168+
[JsonPropertyName("_content_type_uid")]
169+
public string ContentTypeUid { get; set; }
170+
[JsonPropertyName("title")]
171+
public string Title { get; set; }
172+
}
173+
}
141174
```
142175

176+
**Breaking change:** if you regenerate models for an existing project using v1.0.0 or later, the attributes and converter base classes in the output will change from the Newtonsoft-based shape to the System.Text.Json-based shape shown above. Update your consuming code and Contentstack .NET SDK versions accordingly before regenerating.
177+
143178
### MIT License
144179

145180
Copyright (c) 2012-2026 Contentstack

0 commit comments

Comments
 (0)