Skip to content

Commit 86e46ab

Browse files
authored
Merge pull request #50 from MakingSense/DSL-612_quoted_profile
DSL-612 - Quoted Profile
2 parents 9b670cb + ff9ce71 commit 86e46ab

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/MakingSense.AspNetCore.HypermediaApi/Metadata/ActionRelationAttribute.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,23 @@ public void OnResultExecuting([NotNull]ResultExecutingContext context)
9090

9191
if (schemaAttribute != null)
9292
{
93+
var keepUnquoted = context.HttpContext.Request.Query.ContainsKey("keep-unquoted-profile");
94+
9395
context.HttpContext.Response.OnStarting((o) =>
9496
{
95-
context.HttpContext.Response.ContentType += $"; profile={schemaAttribute.SchemaFilePath}";
97+
AddProfileToContentType(context, schemaAttribute, keepUnquoted);
9698
return Task.FromResult(0);
9799
}, null);
98100
}
99101
}
100102

103+
private static void AddProfileToContentType(ResultExecutingContext context, SchemaAttribute schemaAttribute, bool keepUnquoted = false)
104+
{
105+
var profile = keepUnquoted ? schemaAttribute.SchemaFilePath
106+
: $"\"{schemaAttribute.SchemaFilePath?.Replace("\"", "\\\"")}\"";
107+
context.HttpContext.Response.ContentType += $"; profile={profile}";
108+
}
109+
101110
private SchemaAttribute GetSchemaAttributeFromOutputModel()
102111
{
103112
var attr = OutputModel?.GetSchemaAttribute();

0 commit comments

Comments
 (0)