Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ namespace GettingStarted.ResourceDefinitionExample
public class Model : Identifiable
{
[Attr]
public string DontExpose { get; set; }
public string DoNotExpose { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public ModelDefinition(IResourceGraph resourceGraph) : base(resourceGraph)
// this might be used if the incoming value gets hashed or
// encrypted prior to being persisted and this value should
// never be sent back to the client
HideFields(model => model.DontExpose);
HideFields(model => model.DoNotExpose);
}
}
}
2 changes: 1 addition & 1 deletion src/Examples/GettingStarted/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void ConfigureServices(IServiceCollection services)

public void Configure(IApplicationBuilder app, SampleDbContext context)
{
context.Database.EnsureDeleted(); // indicies need to be reset
context.Database.EnsureDeleted(); // indices need to be reset
app.UseJsonApi();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
namespace JsonApiDotNetCore.Configuration
namespace JsonApiDotNetCore.Configuration
{
/// <summary>
/// Allows default valued attributes to be ommitted from the response payload
/// Allows default valued attributes to be omitted from the response payload
/// </summary>
public struct DefaultAttributeResponseBehavior
{

/// <param name="omitNullValuedAttributes">Do not serialize default value attributes</param>
/// <param name="allowClientOverride">
/// Allow clients to override the serialization behavior through a query parmeter.
/// Allow clients to override the serialization behavior through a query parameter.
/// <example>
/// ```
/// GET /articles?omitDefaultValuedAttributes=true
Expand Down
10 changes: 5 additions & 5 deletions src/JsonApiDotNetCore/Configuration/ILinksConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using JsonApiDotNetCore.Models.Links;
using JsonApiDotNetCore.Models.Links;

namespace JsonApiDotNetCore.Configuration
{
Expand Down Expand Up @@ -33,20 +33,20 @@ public interface ILinksConfiguration
/// <summary>
/// Configures globally which links to show in the <see cref="TopLevelLinks"/>
/// object for a requested resource. Setting can be overriden per resource by
/// adding a <see cref="LinksAttribute"/> to the class definitio of that resource.
/// adding a <see cref="LinksAttribute"/> to the class definition of that resource.
/// </summary>
Link TopLevelLinks { get; }

/// <summary>
/// Configures globally which links to show in the <see cref="ResourceLinks"/>
/// object for a requested resource. Setting can be overriden per resource by
/// adding a <see cref="LinksAttribute"/> to the class definitio of that resource.
/// adding a <see cref="LinksAttribute"/> to the class definition of that resource.
/// </summary>
Link ResourceLinks { get; }
/// <summary>
/// Configures globally which links to show in the <see cref="RelationshipLinks"/>
/// object for a requested resource. Setting can be overriden per resource by
/// adding a <see cref="LinksAttribute"/> to the class definitio of that resource.
/// adding a <see cref="LinksAttribute"/> to the class definition of that resource.
/// Option can also be specified per relationship by using the associated links argument
/// in the constructor of <see cref="RelationshipAttribute"/>.
/// </summary>
Expand All @@ -68,4 +68,4 @@ public interface ILinksConfiguration
Link RelationshipLinks { get; }

}
}
}
2 changes: 1 addition & 1 deletion src/JsonApiDotNetCore/Configuration/JsonApiOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class JsonApiOptions : IJsonApiOptions
/// <summary>
/// Whether or not clients can provide ids when creating resources.
/// Defaults to false. When disabled the application will respond
/// with a 403 Forbidden respponse if a client attempts to create a
/// with a 403 Forbidden response if a client attempts to create a
/// resource with a defined id.
/// </summary>
/// <example>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
namespace JsonApiDotNetCore.Configuration
{
/// <summary>
/// Allows null attributes to be ommitted from the response payload
/// Allows null attributes to be omitted from the response payload
/// </summary>
public struct NullAttributeResponseBehavior
{
/// <param name="omitNullValuedAttributes">Do not serialize null attributes</param>
/// <param name="allowClientOverride">
/// Allow clients to override the serialization behavior through a query parmeter.
/// Allow clients to override the serialization behavior through a query parameter.
/// <example>
/// ```
/// GET /articles?omitNullValuedAttributes=true
Expand Down
10 changes: 5 additions & 5 deletions src/JsonApiDotNetCore/Data/DefaultResourceRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private bool IsHasOneRelationship(string internalRelationshipName, Type type)
return false;
}
// relationshipAttr is null when we don't put a [RelationshipAttribute] on the inverse navigation property.
// In this case we use relfection to figure out what kind of relationship is pointing back.
// In this case we use reflection to figure out what kind of relationship is pointing back.
return !type.GetProperty(internalRelationshipName).PropertyType.Inherits(typeof(IEnumerable));
}

Expand Down Expand Up @@ -359,12 +359,12 @@ public async Task<IReadOnlyList<TResource>> ToListAsync(IQueryable<TResource> en

/// <summary>
/// Before assigning new relationship values (UpdateAsync), we need to
/// attach the current database values of the relationship to the dbcontext, else
/// attach the current database values of the relationship to the dbContext, else
/// it will not perform a complete-replace which is required for
/// one-to-many and many-to-many.
/// <para />
/// For example: a person `p1` has 2 todoitems: `t1` and `t2`.
/// If we want to update this todoitem set to `t3` and `t4`, simply assigning
/// For example: a person `p1` has 2 todo-items: `t1` and `t2`.
/// If we want to update this todo-item set to `t3` and `t4`, simply assigning
/// `p1.todoItems = [t3, t4]` will result in EF Core adding them to the set,
/// resulting in `[t1 ... t4]`. Instead, we should first include `[t1, t2]`,
/// after which the reassignment `p1.todoItems = [t3, t4]` will actually
Expand All @@ -383,7 +383,7 @@ protected void LoadCurrentRelationships(TResource oldEntity, RelationshipAttribu
}

/// <summary>
/// Given a iidentifiable relationshipvalue, verify if an entity of the underlying
/// Given a IIdentifiable relationship value, verify if an entity of the underlying
/// type with the same ID is already attached to the dbContext, and if so, return it.
/// If not, attach the relationship value to the dbContext.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static IServiceCollection AddResourceService<T>(this IServiceCollection s
{
foreach (var openGenericType in ServiceDiscoveryFacade.ServiceInterfaces)
{
// A shorthand interface is one where the id type is ommitted
// A shorthand interface is one where the id type is omitted
// e.g. IResourceService<T> is the shorthand for IResourceService<T, TId>
var isShorthandInterface = (openGenericType.GetTypeInfo().GenericTypeParameters.Length == 1);
if (isShorthandInterface && resourceDescriptor.IdType != typeof(int))
Expand All @@ -102,7 +102,7 @@ public static IServiceCollection AddResourceService<T>(this IServiceCollection s

private static HashSet<ResourceDescriptor> GetResourceTypesFromServiceImplementation(Type type)
{
var resourceDecriptors = new HashSet<ResourceDescriptor>();
var resourceDescriptors = new HashSet<ResourceDescriptor>();
var interfaces = type.GetInterfaces();
foreach (var i in interfaces)
{
Expand All @@ -111,11 +111,11 @@ private static HashSet<ResourceDescriptor> GetResourceTypesFromServiceImplementa
var firstGenericArgument = i.GenericTypeArguments.FirstOrDefault();
if (TypeLocator.TryGetResourceDescriptor(firstGenericArgument, out var resourceDescriptor) == true)
{
resourceDecriptors.Add(resourceDescriptor);
resourceDescriptors.Add(resourceDescriptor);
}
}
}
return resourceDecriptors;
return resourceDescriptors;
}
}
}
4 changes: 2 additions & 2 deletions src/JsonApiDotNetCore/Formatters/JsonApiWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace JsonApiDotNetCore.Formatters
/// <summary>
/// Formats the response data used https://docs.microsoft.com/en-us/aspnet/core/web-api/advanced/formatting?view=aspnetcore-3.0.
/// It was intended to have as little dependencies as possible in formatting layer for greater extensibility.
/// It onls depends on <see cref="IJsonApiSerializer"/>.
/// It only depends on <see cref="IJsonApiSerializer"/>.
/// </summary>
public class JsonApiWriter : IJsonApiWriter
{
Expand Down Expand Up @@ -57,7 +57,7 @@ public async Task WriteAsync(OutputFormatterWriteContext context)
}
catch (Exception e)
{
_logger?.LogError(new EventId(), e, "An error ocurred while formatting the response");
_logger?.LogError(new EventId(), e, "An error occurred while formatting the response");
var errors = new ErrorCollection();
errors.Add(new Error(500, e.Message, ErrorMeta.FromException(e)));
responseContent = _serializer.Serialize(errors);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public interface IResourceNameFormatter
string FormatPropertyName(PropertyInfo property);

/// <summary>
/// Aoplies the desired casing convention to the internal string.
/// Applies the desired casing convention to the internal string.
/// This is generally applied to the type name after pluralization.
/// </summary>
string ApplyCasingConvention(string properName);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Reflection;
using Humanizer;
using JsonApiDotNetCore.Models;
Expand Down Expand Up @@ -28,7 +28,7 @@ public string FormatResourceName(Type type)
}

/// <summary>
/// Aoplies the desired casing convention to the internal string.
/// Applies the desired casing convention to the internal string.
/// This is generally applied to the type name after pluralization.
/// </summary>
public abstract string ApplyCasingConvention(string properName);
Expand Down
8 changes: 4 additions & 4 deletions src/JsonApiDotNetCore/Graph/ServiceDiscoveryFacade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public ServiceDiscoveryFacade AddAssembly(Assembly assembly)
{
AddDbContextResolvers(assembly);

var resourceDescriptors = TypeLocator.GetIdentifableTypes(assembly);
var resourceDescriptors = TypeLocator.GetIdentifiableTypes(assembly);
foreach (var resourceDescriptor in resourceDescriptors)
{
AddResource(assembly, resourceDescriptor);
Expand Down Expand Up @@ -109,7 +109,7 @@ private void AddDbContextResolvers(Assembly assembly)
/// <param name="assembly">The assembly to search for resources in.</param>
public ServiceDiscoveryFacade AddResources(Assembly assembly)
{
var identifiables = TypeLocator.GetIdentifableTypes(assembly);
var identifiables = TypeLocator.GetIdentifiableTypes(assembly);
foreach (var identifiable in identifiables)
AddResource(assembly, identifiable);

Expand Down Expand Up @@ -149,7 +149,7 @@ private void AddResourceToGraph(ResourceDescriptor identifiable)
/// <param name="assembly">The assembly to search for resources in.</param>
public ServiceDiscoveryFacade AddServices(Assembly assembly)
{
var resourceDescriptors = TypeLocator.GetIdentifableTypes(assembly);
var resourceDescriptors = TypeLocator.GetIdentifiableTypes(assembly);
foreach (var resourceDescriptor in resourceDescriptors)
{
AddServices(assembly, resourceDescriptor);
Expand All @@ -171,7 +171,7 @@ private void AddServices(Assembly assembly, ResourceDescriptor resourceDescripto
/// <param name="assembly">The assembly to search for resources in.</param>
public ServiceDiscoveryFacade AddRepositories(Assembly assembly)
{
var resourceDescriptors = TypeLocator.GetIdentifableTypes(assembly);
var resourceDescriptors = TypeLocator.GetIdentifiableTypes(assembly);
foreach (var resourceDescriptor in resourceDescriptors)
{
AddRepositories(assembly, resourceDescriptor);
Expand Down
10 changes: 5 additions & 5 deletions src/JsonApiDotNetCore/Graph/TypeLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ public static Type GetIdType(Type resourceType)
/// <summary>
/// Get all implementations of <see cref="IIdentifiable"/> in the assembly
/// </summary>
public static IEnumerable<ResourceDescriptor> GetIdentifableTypes(Assembly assembly)
public static IEnumerable<ResourceDescriptor> GetIdentifiableTypes(Assembly assembly)
=> (_identifiableTypeCache.TryGetValue(assembly, out var descriptors) == false)
? FindIdentifableTypes(assembly)
? FindIdentifiableTypes(assembly)
: _identifiableTypeCache[assembly];

private static IEnumerable<ResourceDescriptor> FindIdentifableTypes(Assembly assembly)
private static IEnumerable<ResourceDescriptor> FindIdentifiableTypes(Assembly assembly)
{
var descriptors = new List<ResourceDescriptor>();
_identifiableTypeCache[assembly] = descriptors;
Expand Down Expand Up @@ -107,7 +107,7 @@ public static (Type implementation, Type registrationInterface) GetGenericInterf
}

/// <summary>
/// Get all derivitives of the concrete, generic type.
/// Get all derivatives of the concrete, generic type.
/// </summary>
/// <param name="assembly">The assembly to search</param>
/// <param name="openGenericType">The open generic type, e.g. `typeof(ResourceDefinition&lt;&gt;)`</param>
Expand All @@ -124,7 +124,7 @@ public static IEnumerable<Type> GetDerivedGenericTypes(Assembly assembly, Type o
}

/// <summary>
/// Get all derivitives of the specified type.
/// Get all derivatives of the specified type.
/// </summary>
/// <param name="assembly">The assembly to search</param>
/// <param name="openGenericType">The inherited type</param>
Expand Down
14 changes: 7 additions & 7 deletions src/JsonApiDotNetCore/Hooks/Execution/HookExecutorHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ public IEnumerable LoadDbValues(LeftType entityTypeForRepository, IEnumerable en
var parameterizedGetWhere = GetType()
.GetMethod(nameof(GetWhereAndInclude), BindingFlags.NonPublic | BindingFlags.Instance)
.MakeGenericMethod(entityTypeForRepository, idType);
var casted = ((IEnumerable<object>)entities).Cast<IIdentifiable>();
var ids = casted.Select(e => e.StringId).Cast(idType);
var cast = ((IEnumerable<object>)entities).Cast<IIdentifiable>();
var ids = cast.Select(e => e.StringId).Cast(idType);
var values = (IEnumerable)parameterizedGetWhere.Invoke(this, new object[] { ids, relationshipsToNextLayer });
if (values == null) return null;
return (IEnumerable)Activator.CreateInstance(typeof(HashSet<>).MakeGenericType(entityTypeForRepository), values.Cast(entityTypeForRepository));
Expand Down Expand Up @@ -155,7 +155,7 @@ public Dictionary<RelationshipAttribute, IEnumerable> LoadImplicitlyAffected(
{
if (IsHasManyThrough(kvp, out var lefts, out var relationship)) continue;

// note that we dont't have to check if BeforeImplicitUpdate hook is implemented. If not, it wont ever get here.
// note that we don't have to check if BeforeImplicitUpdate hook is implemented. If not, it wont ever get here.
var includedLefts = LoadDbValues(relationship.LeftType, lefts, ResourceHook.BeforeImplicitUpdateRelationship, relationship);

foreach (IIdentifiable ip in includedLefts)
Expand All @@ -171,17 +171,17 @@ public Dictionary<RelationshipAttribute, IEnumerable> LoadImplicitlyAffected(
{
dbRightEntityList = (IList)relationshipValue;
}
var dbRightEntityListCasted = dbRightEntityList.Cast<IIdentifiable>().ToList();
if (existingRightEntities != null) dbRightEntityListCasted = dbRightEntityListCasted.Except(existingRightEntities.Cast<IIdentifiable>(), _comparer).ToList();
var dbRightEntityListCast = dbRightEntityList.Cast<IIdentifiable>().ToList();
if (existingRightEntities != null) dbRightEntityListCast = dbRightEntityListCast.Except(existingRightEntities.Cast<IIdentifiable>(), _comparer).ToList();

if (dbRightEntityListCasted.Any())
if (dbRightEntityListCast.Any())
{
if (!implicitlyAffected.TryGetValue(relationship, out IEnumerable affected))
{
affected = TypeHelper.CreateListFor(relationship.RightType);
implicitlyAffected[relationship] = affected;
}
((IList)affected).AddRange(dbRightEntityListCasted);
((IList)affected).AddRange(dbRightEntityListCast);
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/JsonApiDotNetCore/Hooks/Execution/IHookExecutorHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections;
using System.Collections.Generic;
using JsonApiDotNetCore.Models;
Expand All @@ -9,7 +9,7 @@ namespace JsonApiDotNetCore.Hooks
/// A helper class for retrieving meta data about hooks,
/// fetching database values and performing other recurring internal operations.
///
/// Used internalyl by <see cref="ResourceHookExecutor"/>
/// Used internally by <see cref="ResourceHookExecutor"/>
/// </summary>
internal interface IHookExecutorHelper
{
Expand Down Expand Up @@ -49,13 +49,13 @@ internal interface IHookExecutorHelper
IEnumerable LoadDbValues(Type repositoryEntityType, IEnumerable entities, ResourceHook hook, params RelationshipAttribute[] relationships);

/// <summary>
/// Checks if the display database values option is allowed for the targetd hook, and for
/// Checks if the display database values option is allowed for the targeted hook, and for
/// a given resource of type <paramref name="entityType"/> checks if this hook is implemented and if the
/// database values option is enabled.
/// </summary>
/// <returns><c>true</c>, if load db values was shoulded, <c>false</c> otherwise.</returns>
/// <returns><c>true</c>, if should load db values, <c>false</c> otherwise.</returns>
/// <param name="entityType">Container entity type.</param>
/// <param name="hook">Hook.</param>
bool ShouldLoadDbValues(Type entityType, ResourceHook hook);
}
}
}
Loading