Skip to content

Commit 93d131c

Browse files
committed
Improve documentation and code comments: spelling grammar tone
1 parent 75c33e5 commit 93d131c

11 files changed

Lines changed: 16 additions & 18 deletions

File tree

docs/usage/advanced/error-handling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
The code [here](https://github.com/json-api-dotnet/JsonApiDotNetCore/tree/master/test/JsonApiDotNetCoreTests/IntegrationTests/ExceptionHandling) shows how to customize error handling.
44

55
A user-defined exception, `ConsumerArticleIsNoLongerAvailableException`, is thrown from a resource service to demonstrate handling it.
6-
Note that this exception can be thrown from anywhere during request execution; a resource service is just used here for simplicity.
6+
Note that this exception can be thrown from anywhere during request execution; a resource service is used here for simplicity.
77

88
To handle the user-defined exception, `AlternateExceptionHandler` inherits from `ExceptionHandler` to:
99
- Customize the JSON:API error response by adding a `meta` entry when `ConsumerArticleIsNoLongerAvailableException` is thrown.

docs/usage/common-pitfalls.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ the richness of JSON:API. For example, it enables users to include related resou
7373
As an API developer, you'll benefit from rich input validation and fine-grained control for setting what's permitted when users access relationships.
7474

7575
#### Model relationships instead of complex (JSON) attributes
76-
Similar to the above, returning a complex object takes away all the relationship features of JSON:API. Users can't filter inside a complex object. Or update
77-
a nested value, without risking accidentally overwriting another unrelated nested value from a concurrent request. Basically, there's no partial PATCH to prevent that.
76+
Similar to the above, returning a complex object takes away all the relationship features of JSON:API. Users can't filter inside a complex object, nor update
77+
a nested value without risking accidentally overwriting another unrelated nested value from a concurrent request. There's no partial PATCH to prevent that.
7878

7979
#### Stay away from stored procedures
8080
There are [many reasons](https://stackoverflow.com/questions/1761601/is-the-usage-of-stored-procedures-a-bad-practice/9483781#9483781) to not use stored procedures.

docs/usage/extensibility/controllers.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ To provide read-only access, inherit from `JsonApiQueryController` instead, whic
123123
Likewise, to provide write-only access, inherit from `JsonApiCommandController`, which blocks all GET and HEAD requests.
124124

125125
You can even make your own mix of allowed routes by calling the alternate constructor of `JsonApiController` and injecting the set of service implementations available.
126-
In some cases, resources may be an aggregation of entities or a view on top of the underlying entities. In these cases, there may not be a writable `IResourceService` implementation, so simply inject the implementation that is available.
126+
In some cases, resources may be an aggregation of entities or a view on top of the underlying entities. In these cases, there may not be a writable `IResourceService` implementation. Inject the implementation that is available.
127127

128128
```c#
129129
public class ReportsController : JsonApiController<Report, long>
@@ -189,4 +189,3 @@ partial class TagsController
189189
return Ok(defaultTags);
190190
}
191191
}
192-
```

docs/usage/extensibility/query-strings.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ See [here](~/usage/extensibility/resource-definitions.md#custom-query-string-par
2121

2222
## Custom query string parsing
2323

24-
In order to add parsing of custom query string parameters, you can implement the `IQueryStringParameterReader` interface and register your reader.
24+
To add parsing of custom query string parameters, implement the `IQueryStringParameterReader` interface and register your reader.
2525

2626
```c#
2727
public class CustomQueryStringParameterReader : IQueryStringParameterReader

docs/usage/extensibility/services.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ IResourceCommandService <|-- ISetRelationshipService
111111
IResourceCommandService <|-- IRemoveFromRelationshipService
112112
```
113113

114-
In order to take advantage of these interfaces you first need to register the service for each implemented interface.
114+
To take advantage of these interfaces, register the service for each implemented interface.
115115

116116
```c#
117117
public class ArticleService : ICreateService<Article, long>, IDeleteService<Article, long>
@@ -158,4 +158,3 @@ public class ArticlesController : JsonApiController<Article, long>
158158
{
159159
}
160160
}
161-
```

docs/usage/faq.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ Aside from debugging, you can get more info by:
6464

6565
#### What if my JSON:API resources do not exactly match the shape of my database tables?
6666
We often find users trying to write custom code to solve that. They usually get it wrong or incomplete, and it may not perform well.
67-
Or it simply fails because it cannot be translated to SQL.
67+
Alternatively, it might fail because it cannot be translated to SQL.
68+
6869
The good news is that there's an easier solution most of the time: configure Entity Framework Core mappings to do the work.
6970

7071
For example, if your primary key column is named "CustomerId" instead of "Id":

docs/usage/resources/nullability.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public sealed class Label : Identifiable<long>
6060

6161
When NRT is turned on, use nullability annotations (?) on attributes and relationships. This makes Entity Framework Core generate non-nullable columns. And model errors are returned when non-nullable fields are omitted.
6262

63-
The [Entity Framework Core guide on NRT](https://learn.microsoft.com/ef/core/miscellaneous/nullable-reference-types) recommends to use constructor binding to initialize non-nullable properties, but JsonApiDotNetCore does not support that. For required navigation properties, it suggests to use a non-nullable property with a nullable backing field. JsonApiDotNetCore does not support that either. In both cases, just use the null-forgiving operator (!).
63+
The [Entity Framework Core guide on NRT](https://learn.microsoft.com/ef/core/miscellaneous/nullable-reference-types) recommends using constructor binding to initialize non-nullable properties, but JsonApiDotNetCore does not support that. For required navigation properties, it suggests using a non-nullable property with a nullable backing field. JsonApiDotNetCore does not support that either. In both cases, use the null-forgiving operator (!).
6464

6565
When ModelState validation is turned on, to-many relationships must be assigned an empty collection. Otherwise an error is returned when they don't occur in the request body.
6666

@@ -86,4 +86,3 @@ public sealed class Label : Identifiable<long>
8686
[HasMany]
8787
public ISet<TodoItem> TodoItems { get; set; } = new HashSet<TodoItem>();
8888
}
89-
```

src/Examples/DapperExample/FromEntitiesNavigationResolver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public FromEntitiesNavigationResolver(IResourceGraph resourceGraph, FromEntities
3232

3333
public void Resolve()
3434
{
35-
// In order to produce SQL, some knowledge of the underlying database model is required.
35+
// To produce SQL, some knowledge of the underlying database model is required.
3636
// Because the database in this example project is created using Entity Framework Core, we derive that information from its model.
3737
// Some alternative approaches to consider:
3838
// - Query the database to obtain model information at startup.

src/JsonApiDotNetCore.OpenApi.Swashbuckle/SwaggerComponents/DocumentationOpenApiOperationFilter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,12 @@ private void ApplyPostResource(OpenApiOperation operation, ResourceType resource
239239
SetResponseDescription(operation.Responses, HttpStatusCode.Created,
240240
$"The {singularName} was successfully created, which resulted in additional changes. The newly created {singularName} is returned.");
241241

242-
SetResponseHeaderLocation(operation.Responses, HttpStatusCode.Created, singularName);
242+
setResponseHeaderLocation(operation.Responses, HttpStatusCode.Created, singularName);
243243

244244
SetResponseDescription(operation.Responses, HttpStatusCode.NoContent,
245245
$"The {singularName} was successfully created, which did not result in additional changes.");
246246

247-
SetResponseDescription(operation.Responses, HttpStatusCode.BadRequest, TextQueryStringOrRequestBodyBad);
247+
setResponseDescription(operation.Responses, HttpStatusCode.BadRequest, TextQueryStringOrRequestBodyBad);
248248

249249
ClientIdGenerationMode clientIdGeneration = resourceType.ClientIdGeneration ?? _options.ClientIdGeneration;
250250

@@ -615,7 +615,7 @@ private static void ApplyPostOperations(OpenApiOperation operation)
615615

616616
SetResponseDescription(operation.Responses, HttpStatusCode.BadRequest, TextRequestBodyBad);
617617
SetResponseDescription(operation.Responses, HttpStatusCode.Forbidden, "An operation is not accessible or a client-generated ID is used.");
618-
SetResponseDescription(operation.Responses, HttpStatusCode.NotFound, "A resource or a related resource does not exist.");
618+
setResponseDescription(operation.Responses, HttpStatusCode.NotFound, "A resource or a related resource does not exist.");
619619
SetResponseDescription(operation.Responses, HttpStatusCode.Conflict, TextConflict);
620620
SetResponseDescription(operation.Responses, HttpStatusCode.UnprocessableEntity, TextRequestBodyValidationFailed);
621621
}

src/JsonApiDotNetCore/Configuration/JsonApiOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ public bool AllowClientGeneratedIds
106106
public JsonSerializerOptions SerializerOptions { get; } = new()
107107
{
108108
// These are the options common to serialization and deserialization.
109-
// At runtime, we actually use SerializerReadOptions and SerializerWriteOptions, which are customized copies of these settings,
109+
// At runtime, we use SerializerReadOptions and SerializerWriteOptions, which are customized copies of these settings,
110110
// to overcome the limitation in System.Text.Json that the JsonPath is incorrect when using custom converters.
111-
// Therefore we try to avoid using custom converters has much as possible.
111+
// Therefore we minimize custom converter usage.
112112
// https://github.com/Tarmil/FSharp.SystemTextJson/issues/37
113113
// https://github.com/dotnet/runtime/issues/50205#issuecomment-808401245
114114

0 commit comments

Comments
 (0)