mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-10 19:27:09 +02:00
Create WireMock.Net.ProtoBuf project (#1350)
* Create WireMock.Net.ProtoBuf project * ok * Update Directory.Build.props Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,62 +0,0 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using AnyOfTypes;
|
||||
using Newtonsoft.Json;
|
||||
using WireMock.Models.GraphQL;
|
||||
|
||||
namespace WireMock.Models;
|
||||
|
||||
/// <summary>
|
||||
/// GraphQLSchemaDetails
|
||||
/// </summary>
|
||||
public class GraphQLSchemaDetails
|
||||
{
|
||||
/// <summary>
|
||||
/// The GraphQL schema as a string.
|
||||
/// </summary>
|
||||
public string? SchemaAsString { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The GraphQL schema as a StringPattern.
|
||||
/// </summary>
|
||||
public StringPattern? SchemaAsStringPattern { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The GraphQL schema as a <seealso cref="ISchemaData"/>.
|
||||
/// </summary>
|
||||
public ISchemaData? SchemaAsISchemaData { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The GraphQL Schema.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public AnyOf<string, StringPattern, ISchemaData>? Schema
|
||||
{
|
||||
get
|
||||
{
|
||||
if (SchemaAsString != null)
|
||||
{
|
||||
return SchemaAsString;
|
||||
}
|
||||
|
||||
if (SchemaAsStringPattern != null)
|
||||
{
|
||||
return SchemaAsStringPattern;
|
||||
}
|
||||
|
||||
if (SchemaAsISchemaData != null)
|
||||
{
|
||||
return new AnyOf<string, StringPattern, ISchemaData>(SchemaAsISchemaData);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The custom Scalars to define for this schema.
|
||||
/// </summary>
|
||||
public IDictionary<string, Type>? CustomScalars { get; set; }
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Stef.Validation;
|
||||
|
||||
namespace WireMock.Models;
|
||||
|
||||
/// <summary>
|
||||
/// A placeholder class for Proto Definitions.
|
||||
/// </summary>
|
||||
public class ProtoDefinitionData
|
||||
{
|
||||
private readonly IDictionary<string, string> _filenameMappedToProtoDefinition;
|
||||
|
||||
internal ProtoDefinitionData(IDictionary<string, string> filenameMappedToProtoDefinition)
|
||||
{
|
||||
_filenameMappedToProtoDefinition = filenameMappedToProtoDefinition;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all the ProtoDefinitions.
|
||||
/// Note: the main ProtoDefinition will be the first one in the list.
|
||||
/// </summary>
|
||||
/// <param name="mainProtoFilename">The main ProtoDefinition filename.</param>
|
||||
public IReadOnlyList<string> ToList(string mainProtoFilename)
|
||||
{
|
||||
Guard.NotNullOrEmpty(mainProtoFilename);
|
||||
|
||||
if (!_filenameMappedToProtoDefinition.TryGetValue(mainProtoFilename, out var mainProtoDefinition))
|
||||
{
|
||||
throw new KeyNotFoundException($"The ProtoDefinition with filename '{mainProtoFilename}' was not found.");
|
||||
}
|
||||
|
||||
var list = new List<string> { mainProtoDefinition };
|
||||
list.AddRange(_filenameMappedToProtoDefinition.Where(kvp => kvp.Key != mainProtoFilename).Select(kvp => kvp.Value));
|
||||
return list;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user