diff --git a/tools/apiview/parsers/swagger-api-parser/SwaggerApiParser/Specs/Header.cs b/tools/apiview/parsers/swagger-api-parser/SwaggerApiParser/Specs/Header.cs index 3827859a1fa5..2efc1c413b4a 100644 --- a/tools/apiview/parsers/swagger-api-parser/SwaggerApiParser/Specs/Header.cs +++ b/tools/apiview/parsers/swagger-api-parser/SwaggerApiParser/Specs/Header.cs @@ -3,11 +3,23 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using SwaggerApiParser.SwaggerApiView; namespace SwaggerApiParser.Specs { public class Header : Items { public string description { get; set; } + + public CodeFileToken[] TokenSerialize(SerializeContext context) + { + List ret = new List(); + ret.AddRange(TokenSerializer.KeyValueTokens("type", type, true, context.IteratorPath.CurrentNextPath("type"))); + + if (description != null) + ret.AddRange(TokenSerializer.KeyValueTokens("description", description, true, context.IteratorPath.CurrentNextPath("description"))); + + return ret.ToArray(); + } } } diff --git a/tools/apiview/parsers/swagger-api-parser/SwaggerApiParser/Specs/Items.cs b/tools/apiview/parsers/swagger-api-parser/SwaggerApiParser/Specs/Items.cs index 94012617e946..562dcb2b00af 100644 --- a/tools/apiview/parsers/swagger-api-parser/SwaggerApiParser/Specs/Items.cs +++ b/tools/apiview/parsers/swagger-api-parser/SwaggerApiParser/Specs/Items.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; +using SwaggerApiParser.SwaggerApiView; namespace SwaggerApiParser.Specs { diff --git a/tools/apiview/parsers/swagger-api-parser/SwaggerApiParser/Specs/SchemaCache.cs b/tools/apiview/parsers/swagger-api-parser/SwaggerApiParser/Specs/SchemaCache.cs index 3c14e7cff91a..ac40164bdfee 100644 --- a/tools/apiview/parsers/swagger-api-parser/SwaggerApiParser/Specs/SchemaCache.cs +++ b/tools/apiview/parsers/swagger-api-parser/SwaggerApiParser/Specs/SchemaCache.cs @@ -247,7 +247,7 @@ public Schema GetResolvedSchema(Schema root, string currentSwaggerFilePath, Link if (root.additionalProperties.ValueKind == JsonValueKind.Object) { - var additionalProperties = JsonSerializer.Deserialize>(root.additionalProperties); + var additionalProperties = JsonSerializer.Deserialize>(root.additionalProperties); if (additionalProperties.ContainsKey("$ref")) { var schema = new Schema(); diff --git a/tools/apiview/parsers/swagger-api-parser/SwaggerApiParser/SwaggerApiParser - Backup.csproj b/tools/apiview/parsers/swagger-api-parser/SwaggerApiParser/SwaggerApiParser - Backup.csproj deleted file mode 100644 index 78d291a3ec97..000000000000 --- a/tools/apiview/parsers/swagger-api-parser/SwaggerApiParser/SwaggerApiParser - Backup.csproj +++ /dev/null @@ -1,45 +0,0 @@ - - - - Exe - true - swaggerAPIParser - net6.0 - swagger_api_parser - 1.0.8 - Azure.Sdk.Tools.SwaggerApiParser - True - $(OfficialBuildId) - - - - $(NoWarn);NU5105;NU5119 - - - - $(NoWarn);NU5105;NU5119 - - - - - - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - - - - diff --git a/tools/apiview/parsers/swagger-api-parser/SwaggerApiParser/SwaggerApiParser.csproj b/tools/apiview/parsers/swagger-api-parser/SwaggerApiParser/SwaggerApiParser.csproj index 88a3dff3d457..fd5fb4bf2009 100644 --- a/tools/apiview/parsers/swagger-api-parser/SwaggerApiParser/SwaggerApiParser.csproj +++ b/tools/apiview/parsers/swagger-api-parser/SwaggerApiParser/SwaggerApiParser.csproj @@ -32,7 +32,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tools/apiview/parsers/swagger-api-parser/SwaggerApiParser/SwaggerApiView/SwaggerApiViewResponse.cs b/tools/apiview/parsers/swagger-api-parser/SwaggerApiParser/SwaggerApiView/SwaggerApiViewResponse.cs index 5e500771415f..005195cb7ac4 100644 --- a/tools/apiview/parsers/swagger-api-parser/SwaggerApiParser/SwaggerApiView/SwaggerApiViewResponse.cs +++ b/tools/apiview/parsers/swagger-api-parser/SwaggerApiParser/SwaggerApiView/SwaggerApiViewResponse.cs @@ -26,8 +26,12 @@ public CodeFileToken[] TokenSerialize(SerializeContext context) ret.Add(TokenSerializer.NewLine()); foreach (var header in headers) { - ret.AddRange(TokenSerializer.KeyValueTokens(header.Key, "")); + ret.Add(new CodeFileToken(header.Key, CodeFileTokenKind.FoldableSectionHeading)); + ret.Add(TokenSerializer.Colon()); + ret.Add(TokenSerializer.NewLine()); + ret.Add(TokenSerializer.FoldableContentStart()); ret.AddRange(header.Value.TokenSerialize(context)); + ret.Add(TokenSerializer.FoldableContentEnd()); } ret.Add(TokenSerializer.NewLine()); diff --git a/tools/apiview/parsers/swagger-api-parser/SwaggerApiParser/Utils.cs b/tools/apiview/parsers/swagger-api-parser/SwaggerApiParser/Utils.cs index 644a8aedf105..2da2ccbed17b 100644 --- a/tools/apiview/parsers/swagger-api-parser/SwaggerApiParser/Utils.cs +++ b/tools/apiview/parsers/swagger-api-parser/SwaggerApiParser/Utils.cs @@ -258,6 +258,11 @@ public static void SerializePatternedObjects(IDictionary pa public static void AddSchemaToRootDefinition(Schema schema, Dictionary definitions) { + if (schema == null) + { + return; + } + if (!String.IsNullOrEmpty(schema.originalRef)) { var schemaKey = Utils.GetDefinitionType(schema.originalRef);