Skip to content

Commit

Permalink
Fix swagger tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chidozieononiwu committed Jun 16, 2023
1 parent 119b0e3 commit d931b7b
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<CodeFileToken> ret = new List<CodeFileToken>();
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();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using SwaggerApiParser.SwaggerApiView;

namespace SwaggerApiParser.Specs
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public Schema GetResolvedSchema(Schema root, string currentSwaggerFilePath, Link

if (root.additionalProperties.ValueKind == JsonValueKind.Object)
{
var additionalProperties = JsonSerializer.Deserialize<Dictionary<string, string>>(root.additionalProperties);
var additionalProperties = JsonSerializer.Deserialize<Dictionary<string, object>>(root.additionalProperties);
if (additionalProperties.ContainsKey("$ref"))
{
var schema = new Schema();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<ItemGroup>
<PackageReference Include="Markdig.Signed" Version="0.30.2" />
<PackageReference Include="NuGet.CommandLine" Version="6.2.2">
<PackageReference Include="NuGet.CommandLine" Version="6.2.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ public static void SerializePatternedObjects(IDictionary<string, JsonElement> pa

public static void AddSchemaToRootDefinition(Schema schema, Dictionary<string, Definition> definitions)
{
if (schema == null)
{
return;
}

if (!String.IsNullOrEmpty(schema.originalRef))
{
var schemaKey = Utils.GetDefinitionType(schema.originalRef);
Expand Down

0 comments on commit d931b7b

Please sign in to comment.