Skip to content

[WIP] The big rewrite #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 66 commits into from
Aug 22, 2015
Merged
Changes from 1 commit
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
490aad8
rewrite JSONAPI.NET to be compatible with JSON API 1.0
Jun 28, 2015
6e5fcd5
update TodoMVC project to use autofac integration
Jun 28, 2015
3664d39
change autofac configuration interface
Jun 28, 2015
3088b6b
remove redundant resolver statement
Jun 28, 2015
fefc3f2
allow UseJsonApiWithAutofac to take ILifetimeScope
Jun 28, 2015
00dee31
move generic parameter to interface for IPayloadMaterializer
Jun 29, 2015
a243266
fix mis-named class
Jun 29, 2015
84472a7
remove IMaterializer, IMetadataManager, and implementations
Jun 29, 2015
b75ae4e
make EFPayloadMaterializer method virtual
Jun 29, 2015
32779c5
use current request to get base url
Jun 29, 2015
78e7718
Add metadata param to resource collection payload builder
Jun 29, 2015
dea14d0
implement related resource URLs
Jun 29, 2015
dafa96d
implement related resource URLs for to-one relationships
Jun 29, 2015
25345f8
make new related methods protected
Jun 29, 2015
fc7732d
add IBaseUrlService
Jun 29, 2015
455af08
add new convenience methods for making JsonApiException
Jun 29, 2015
597513c
support custom filter and sort expressions for registered types
Jun 29, 2015
41d2b95
remove sorting by +
Jun 29, 2015
ec1cda6
rearrange acceptance tests
Jun 30, 2015
1abdddc
don't fail on unknown fields; ignore instead
Jun 30, 2015
f13058b
include relationships when materializing
Jun 30, 2015
e34d6f9
separate out value converters into files
Jun 30, 2015
2963d60
rename primitives and general cleanup
Jul 1, 2015
e27868b
make sure TodoMVC sample works.
Jul 1, 2015
f3ddb88
Move namespace of queryable transformers
Jul 1, 2015
edcb959
ensure not found works for fetching resource by ID
Jul 1, 2015
dae593f
return 404 for to-one related resources to non-existant resource
Jul 1, 2015
e1a78d2
return 404 for to-many related actions where primary resource doesn't…
Jul 1, 2015
b4fb7d2
provide serialization hooks for RelationshipObjectFormatter children
Jul 2, 2015
bc083df
don't crash when requesting related resource for non-existent relatio…
Jul 2, 2015
2e54d6a
make GetBaseUrl method virtual
Jul 4, 2015
b2a5213
allow specifying includes and metadata for queryable builder
Jul 4, 2015
7dc407e
don't fail on null to-many relationship
Jul 7, 2015
ba3388b
remove extraneous select
Jul 7, 2015
d1256af
simplify async queryable enumeration transformer
Jul 9, 2015
4d0de76
add queryable enumeration transform method
Jul 9, 2015
bf14fe0
add materializer for mapping entities to DTOs
Jul 9, 2015
464d648
allow serializing null related resources
Jul 10, 2015
48e19a4
allow serializing metadata with ISingleResourceDocumentBuilder
Jul 10, 2015
5dfaf4b
add some documentation
Jul 10, 2015
13b8c32
add single record filter to IDocumentMaterializer
Jul 10, 2015
91ca6a3
rearrange acceptance test projects
Jul 11, 2015
e5f9eb2
Refactor configuration and document materialization systems
Jul 12, 2015
0d2091b
split into new files
Jul 12, 2015
68dfca7
remove unused delegates
Jul 13, 2015
c2eaa23
sanitize configuration interfaces slightly
Jul 13, 2015
6ca6010
add way to configure a default related resource materializer per reso…
Jul 13, 2015
b963cd6
more configuration interface cleanup
Jul 13, 2015
d10b334
fix a couple mis-named things
Jul 13, 2015
d973bb1
provide hook for configuring lifetime scope before it is built
Jul 13, 2015
9db8a94
allow customizing DefaultNamingConventions
Jul 13, 2015
6b0ccc1
add convenience method for constructing 403 errors
Jul 14, 2015
e14592e
have MappedDocumentMaterializer punt on created, update, and delete
Jul 15, 2015
e851748
store relationship configurations by name instead of property
Jul 15, 2015
6bf83cc
make GetKeyNames work recursively
Jul 16, 2015
015b7ff
add test for subclass
Jul 17, 2015
9e185df
Adding globalization for decimal, double and single for conversion.
cybermats Jul 17, 2015
74fd025
convert linkage objects to using IResourceIdentifiers
Jul 17, 2015
f0324f5
Merge pull request #97 from cybermats/payload2
csantero Jul 18, 2015
fbc430a
make sure null to-one included relationships are serialized with null…
Jul 19, 2015
96b57f8
await tasks in JsonApiFormatter
Jul 21, 2015
8321989
allow specifying include paths
Jul 22, 2015
05cb963
expose PathVisitor
Jul 27, 2015
2d442ce
make GET methods virtual
Jul 30, 2015
adea1cb
send correct query to GetDocumentMetadata
Aug 2, 2015
aa795f0
make SetValue work with JToken null
Aug 13, 2015
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
Prev Previous commit
Next Next commit
allow customizing DefaultNamingConventions
  • Loading branch information
Chris Santero committed Jul 13, 2015
commit 9db8a94d8218772a434e3e6a41820a39513f96cd
27 changes: 19 additions & 8 deletions JSONAPI/Core/DefaultNamingConventions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public DefaultNamingConventions(IPluralizationService pluralizationService)
/// </summary>
/// <param name="property"></param>
/// <returns></returns>
public string GetFieldNameForProperty(PropertyInfo property)
public virtual string GetFieldNameForProperty(PropertyInfo property)
{
var jsonPropertyAttribute = (JsonPropertyAttribute)property.GetCustomAttributes(typeof(JsonPropertyAttribute)).FirstOrDefault();
return jsonPropertyAttribute != null ? jsonPropertyAttribute.PropertyName : property.Name.Dasherize();
Expand All @@ -43,19 +43,30 @@ public string GetFieldNameForProperty(PropertyInfo property)
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public string GetResourceTypeNameForType(Type type)
public virtual string GetResourceTypeNameForType(Type type)
{
var attrs = type.CustomAttributes.Where(x => x.AttributeType == typeof(JsonObjectAttribute)).ToList();
var jsonObjectAttribute = type.GetCustomAttributes().OfType<JsonObjectAttribute>().FirstOrDefault();

string title = type.Name;
if (attrs.Any())
string title = null;
if (jsonObjectAttribute != null)
{
var titles = attrs.First().NamedArguments.Where(arg => arg.MemberName == "Title")
.Select(arg => arg.TypedValue.Value.ToString()).ToList();
if (titles.Any()) title = titles.First();
title = jsonObjectAttribute.Title;
}

if (string.IsNullOrEmpty(title))
{
title = GetNameForType(type);
}

return _pluralizationService.Pluralize(title).Dasherize();
}

/// <summary>
/// Gets the name for a CLR type.
/// </summary>
protected virtual string GetNameForType(Type type)
{
return type.Name;
}
}
}