-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update REST API specs to v7.4.0 (#4117)
* Transform REST API spec to existing format This commit changes the in memory structure of the ApiEndpoint in 7.4.0 to the old structure expected by the ApiGenerator. * Update specs to v7.4.0 This commit updates the REST API specs to those in the v7.4.0 branch, and re-runs the ApiGenerator. New 7.4.0 APIs are excluded from code generation for now. * Patch 7.4.0 breaking changes - delete_by_query - msearch_template - search_template (cherry picked from commit 6da223b)
- Loading branch information
Showing
326 changed files
with
14,164 additions
and
9,831 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/CodeGeneration/ApiGenerator/Domain/Specification/Documentation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace ApiGenerator.Domain.Specification | ||
{ | ||
[JsonConverter(typeof(DocumentationConverter))] | ||
public class Documentation | ||
{ | ||
public string Description { get; set; } | ||
public string Url { get; set; } | ||
} | ||
|
||
public class DocumentationConverter : JsonConverter | ||
{ | ||
public override bool CanWrite { get; } = false; | ||
|
||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) => throw new NotSupportedException(); | ||
|
||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) | ||
{ | ||
|
||
var documentation = new Documentation(); | ||
|
||
if (reader.TokenType == JsonToken.String) | ||
{ | ||
documentation.Url = (string)reader.Value; | ||
return documentation; | ||
} | ||
|
||
while (reader.Read()) | ||
{ | ||
if (reader.TokenType == JsonToken.EndObject) | ||
break; | ||
|
||
var prop = (string)reader.Value; | ||
switch (prop) | ||
{ | ||
case "url": | ||
documentation.Url = reader.ReadAsString(); | ||
break; | ||
case "description": | ||
documentation.Description = reader.ReadAsString(); | ||
break; | ||
default: | ||
throw new Exception($"Property '{prop}' unexpected in documentation object"); | ||
} | ||
} | ||
return documentation; | ||
} | ||
|
||
public override bool CanConvert(Type objectType) => true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.