Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/LEGO.AsyncAPI.Bindings/Http/HttpMessageBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class HttpMessageBinding : MessageBinding<HttpMessageBinding>
/// <summary>
/// A Schema object containing the definitions for HTTP-specific headers. This schema MUST be of type object and have a properties key.
/// </summary>
public AsyncApiSchema Headers { get; set; }
public AsyncApiJsonSchema Headers { get; set; }

/// <summary>
/// Serialize to AsyncAPI V2 document without using reference.
Expand Down
2 changes: 1 addition & 1 deletion src/LEGO.AsyncAPI.Bindings/Http/HttpOperationBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public enum HttpOperationType
/// <summary>
/// A Schema object containing the definitions for each query parameter. This schema MUST be of type object and have a properties key.
/// </summary>
public AsyncApiSchema Query { get; set; }
public AsyncApiJsonSchema Query { get; set; }

/// <summary>
/// Serialize to AsyncAPI V2 document without using reference.
Expand Down
2 changes: 1 addition & 1 deletion src/LEGO.AsyncAPI.Bindings/Kafka/KafkaMessageBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class KafkaMessageBinding : MessageBinding<KafkaMessageBinding>
/// <summary>
/// The message key. NOTE: You can also use the <a href="https://www.asyncapi.com/docs/reference/specification/v2.4.0#referenceObject">reference object</a> way.
/// </summary>
public AsyncApiSchema Key { get; set; }
public AsyncApiJsonSchema Key { get; set; }

/// <summary>
/// If a Schema Registry is used when performing this operation, tells where the id of schema is stored (e.g. header or payload).
Expand Down
4 changes: 2 additions & 2 deletions src/LEGO.AsyncAPI.Bindings/Kafka/KafkaOperationBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ public class KafkaOperationBinding : OperationBinding<KafkaOperationBinding>
/// <summary>
/// Id of the consumer group.
/// </summary>
public AsyncApiSchema GroupId { get; set; }
public AsyncApiJsonSchema GroupId { get; set; }

/// <summary>
/// Id of the consumer inside a consumer group.
/// </summary>
public AsyncApiSchema ClientId { get; set; }
public AsyncApiJsonSchema ClientId { get; set; }

public override string BindingKey => "kafka";

Expand Down
2 changes: 1 addition & 1 deletion src/LEGO.AsyncAPI.Bindings/MQTT/MQTTMessageBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class MQTTMessageBinding : MessageBinding<MQTTMessageBinding>
/// <summary>
/// Correlation Data is used to identify the request the response message is for.
/// </summary>
public AsyncApiSchema CorrelationData { get; set; }
public AsyncApiJsonSchema CorrelationData { get; set; }

/// <summary>
/// String describing the content type of the message payload.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ public class WebSocketsChannelBinding : ChannelBinding<WebSocketsChannelBinding>
/// <summary>
/// A Schema object containing the definitions for each query parameter. This schema MUST be of type 'object' and have a 'properties' key.
/// </summary>
public AsyncApiSchema Query { get; set; }
public AsyncApiJsonSchema Query { get; set; }

/// <summary>
/// A Schema object containing the definitions of the HTTP headers to use when establishing the connection. This schma MUST be of type 'object' and have a 'properties' key.
/// </summary>
public AsyncApiSchema Headers { get; set; }
public AsyncApiJsonSchema Headers { get; set; }

public override string BindingKey => "websockets";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public override void Visit(AsyncApiMessage message)
switch (message.Payload)
{
case AsyncApiJsonSchemaPayload json:
this.ResolveObject<AsyncApiSchema>(message.Payload as AsyncApiJsonSchemaPayload, r => message.Payload = new AsyncApiJsonSchemaPayload(r));
this.ResolveObject<AsyncApiJsonSchema>(message.Payload as AsyncApiJsonSchemaPayload, r => message.Payload = new AsyncApiJsonSchemaPayload(r));
break;
case AsyncApiAvroSchemaPayload avro:
// ToFix: this might not resolve correctly.
Expand Down Expand Up @@ -153,7 +153,7 @@ public override void Visit(AsyncApiParameter parameter)
/// <summary>
/// Resolve all references used in a schema.
/// </summary>
public override void Visit(AsyncApiSchema schema)
public override void Visit(AsyncApiJsonSchema schema)
{
this.ResolveObject(schema.Items, r => schema.Items = r);
this.ResolveList(schema.OneOf);
Expand Down
4 changes: 2 additions & 2 deletions src/LEGO.AsyncAPI.Readers/ParseNodes/AnyFieldMapParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal class AnyFieldMapParameter<T>
public AnyFieldMapParameter(
Func<T, AsyncApiAny> propertyGetter,
Action<T, AsyncApiAny> propertySetter,
Func<T, AsyncApiSchema> schemaGetter)
Func<T, AsyncApiJsonSchema> schemaGetter)
{
this.PropertyGetter = propertyGetter;
this.PropertySetter = propertySetter;
Expand All @@ -21,6 +21,6 @@ public AnyFieldMapParameter(

public Action<T, AsyncApiAny> PropertySetter { get; }

public Func<T, AsyncApiSchema> SchemaGetter { get; }
public Func<T, AsyncApiJsonSchema> SchemaGetter { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal class AnyListFieldMapParameter<T>
public AnyListFieldMapParameter(
Func<T, IList<AsyncApiAny>> propertyGetter,
Action<T, IList<AsyncApiAny>> propertySetter,
Func<T, AsyncApiSchema> schemaGetter)
Func<T, AsyncApiJsonSchema> schemaGetter)
{
this.PropertyGetter = propertyGetter;
this.PropertySetter = propertySetter;
Expand All @@ -22,6 +22,6 @@ public AnyListFieldMapParameter(

public Action<T, IList<AsyncApiAny>> PropertySetter { get; }

public Func<T, AsyncApiSchema> SchemaGetter { get; }
public Func<T, AsyncApiJsonSchema> SchemaGetter { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public AnyMapFieldMapParameter(
Func<T, IDictionary<string, U>> propertyMapGetter,
Func<U, AsyncApiAny> propertyGetter,
Action<U, AsyncApiAny> propertySetter,
Func<T, AsyncApiSchema> schemaGetter)
Func<T, AsyncApiJsonSchema> schemaGetter)
{
this.PropertyMapGetter = propertyMapGetter;
this.PropertyGetter = propertyGetter;
Expand All @@ -26,6 +26,6 @@ public AnyMapFieldMapParameter(

public Action<U, AsyncApiAny> PropertySetter { get; }

public Func<T, AsyncApiSchema> SchemaGetter { get; }
public Func<T, AsyncApiJsonSchema> SchemaGetter { get; }
}
}
10 changes: 5 additions & 5 deletions src/LEGO.AsyncAPI.Readers/V2/AsyncApiSchemaDeserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace LEGO.AsyncAPI.Readers

public class AsyncApiSchemaDeserializer
{
private static readonly FixedFieldMap<AsyncApiSchema> schemaFixedFields = new()
private static readonly FixedFieldMap<AsyncApiJsonSchema> schemaFixedFields = new()
{
{
"title", (a, n) => { a.Title = n.GetScalarValue(); }
Expand Down Expand Up @@ -215,28 +215,28 @@ public class AsyncApiSchemaDeserializer
},
};

private static readonly PatternFieldMap<AsyncApiSchema> schemaPatternFields =
private static readonly PatternFieldMap<AsyncApiJsonSchema> schemaPatternFields =
new()
{
{ s => s.StartsWith("x-"), (o, p, n) => o.AddExtension(p, AsyncApiV2Deserializer.LoadExtension(p, n)) },
};

public static AsyncApiSchema LoadSchema(ParseNode node)
public static AsyncApiJsonSchema LoadSchema(ParseNode node)
{
var mapNode = node.CheckMapNode(AsyncApiConstants.Schema);

var pointer = mapNode.GetReferencePointer();

if (pointer != null)
{
return new AsyncApiSchema
return new AsyncApiJsonSchema
{
UnresolvedReference = true,
Reference = node.Context.VersionService.ConvertToAsyncApiReference(pointer, ReferenceType.Schema),
};
}

var schema = new AsyncApiSchema();
var schema = new AsyncApiJsonSchema();

foreach (var propertyNode in mapNode)
{
Expand Down
2 changes: 1 addition & 1 deletion src/LEGO.AsyncAPI.Readers/V2/AsyncApiV2VersionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public AsyncApiV2VersionService(AsyncApiDiagnostic diagnostic)
[typeof(AsyncApiOAuthFlows)] = AsyncApiV2Deserializer.LoadOAuthFlows,
[typeof(AsyncApiOperation)] = AsyncApiV2Deserializer.LoadOperation,
[typeof(AsyncApiParameter)] = AsyncApiV2Deserializer.LoadParameter,
[typeof(AsyncApiSchema)] = AsyncApiSchemaDeserializer.LoadSchema,
[typeof(AsyncApiJsonSchema)] = AsyncApiSchemaDeserializer.LoadSchema,
[typeof(AvroSchema)] = AsyncApiAvroSchemaDeserializer.LoadSchema,
[typeof(AsyncApiJsonSchemaPayload)] = AsyncApiV2Deserializer.LoadJsonSchemaPayload,
[typeof(AsyncApiAvroSchemaPayload)] = AsyncApiV2Deserializer.LoadAvroPayload,
Expand Down
8 changes: 4 additions & 4 deletions src/LEGO.AsyncAPI/Models/AsyncApiComponents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class AsyncApiComponents : IAsyncApiExtensible, IAsyncApiSerializable
/// <summary>
/// An object to hold reusable Schema Objects.
/// </summary>
public IDictionary<string, AsyncApiSchema> Schemas { get; set; } = new Dictionary<string, AsyncApiSchema>();
public IDictionary<string, AsyncApiJsonSchema> Schemas { get; set; } = new Dictionary<string, AsyncApiJsonSchema>();

/// <summary>
/// An object to hold reusable Server Objects.
Expand Down Expand Up @@ -101,10 +101,10 @@ public void SerializeV2(IAsyncApiWriter writer)
{
var loops = writer.GetSettings().LoopDetector.Loops;
writer.WriteStartObject();
if (loops.TryGetValue(typeof(AsyncApiSchema), out List<object> schemas))
if (loops.TryGetValue(typeof(AsyncApiJsonSchema), out List<object> schemas))
{
var asyncApiSchemas = schemas.Cast<AsyncApiSchema>().Distinct().ToList()
.ToDictionary<AsyncApiSchema, string>(k => k.Reference.Id);
var asyncApiSchemas = schemas.Cast<AsyncApiJsonSchema>().Distinct().ToList()
.ToDictionary<AsyncApiJsonSchema, string>(k => k.Reference.Id);

writer.WriteOptionalMap(
AsyncApiConstants.Schemas,
Expand Down
2 changes: 1 addition & 1 deletion src/LEGO.AsyncAPI/Models/AsyncApiMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class AsyncApiMessage : IAsyncApiExtensible, IAsyncApiReferenceable, IAsy
/// <summary>
/// schema definition of the application headers. Schema MUST be of type "object".
/// </summary>
public AsyncApiSchema Headers { get; set; }
public AsyncApiJsonSchema Headers { get; set; }

/// <summary>
/// definition of the message payload. It can be of any type but defaults to Schema object. It must match the schema format, including encoding type - e.g Avro should be inlined as either a YAML or JSON object NOT a string to be parsed as YAML or JSON.
Expand Down
2 changes: 1 addition & 1 deletion src/LEGO.AsyncAPI/Models/AsyncApiMessageTrait.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class AsyncApiMessageTrait : IAsyncApiExtensible, IAsyncApiReferenceable,
/// <summary>
/// schema definition of the application headers. Schema MUST be of type "object".
/// </summary>
public AsyncApiSchema Headers { get; set; }
public AsyncApiJsonSchema Headers { get; set; }

/// <summary>
/// definition of the correlation ID used for message tracing or matching.
Expand Down
2 changes: 1 addition & 1 deletion src/LEGO.AsyncAPI/Models/AsyncApiParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class AsyncApiParameter : IAsyncApiReferenceable, IAsyncApiExtensible, IA
/// <summary>
/// Gets or sets definition of the parameter.
/// </summary>
public AsyncApiSchema Schema { get; set; }
public AsyncApiJsonSchema Schema { get; set; }

/// <summary>
/// Gets or sets a runtime expression that specifies the location of the parameter value.
Expand Down
38 changes: 19 additions & 19 deletions src/LEGO.AsyncAPI/Models/AsyncApiSchemaPayload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
using LEGO.AsyncAPI.Models.Interfaces;
using LEGO.AsyncAPI.Writers;

public class AsyncApiJsonSchemaPayload : IAsyncApiMessagePayload

Check warning on line 9 in src/LEGO.AsyncAPI/Models/AsyncApiSchemaPayload.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Check warning on line 9 in src/LEGO.AsyncAPI/Models/AsyncApiSchemaPayload.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

{
private readonly AsyncApiSchema schema;
private readonly AsyncApiJsonSchema schema;

public AsyncApiJsonSchemaPayload()
{
this.schema = new AsyncApiSchema();
this.schema = new AsyncApiJsonSchema();
}

public AsyncApiJsonSchemaPayload(AsyncApiSchema schema)
public AsyncApiJsonSchemaPayload(AsyncApiJsonSchema schema)
{
this.schema = schema;
}
Expand Down Expand Up @@ -50,43 +50,43 @@

public bool WriteOnly { get => this.schema.WriteOnly; set => this.schema.WriteOnly = value; }

public IList<AsyncApiSchema> AllOf { get => this.schema.AllOf; set => this.schema.AllOf = value; }
public IList<AsyncApiJsonSchema> AllOf { get => this.schema.AllOf; set => this.schema.AllOf = value; }

public IList<AsyncApiSchema> OneOf { get => this.schema.OneOf; set => this.schema.OneOf = value; }
public IList<AsyncApiJsonSchema> OneOf { get => this.schema.OneOf; set => this.schema.OneOf = value; }

public IList<AsyncApiSchema> AnyOf { get => this.schema.AnyOf; set => this.schema.AnyOf = value; }
public IList<AsyncApiJsonSchema> AnyOf { get => this.schema.AnyOf; set => this.schema.AnyOf = value; }

public AsyncApiSchema Not { get => this.schema.Not; set => this.schema.Not = value; }
public AsyncApiJsonSchema Not { get => this.schema.Not; set => this.schema.Not = value; }

public AsyncApiSchema Contains { get => this.schema.Contains; set => this.schema.Contains = value; }
public AsyncApiJsonSchema Contains { get => this.schema.Contains; set => this.schema.Contains = value; }

public AsyncApiSchema If { get => this.schema.If; set => this.schema.If = value; }
public AsyncApiJsonSchema If { get => this.schema.If; set => this.schema.If = value; }

public AsyncApiSchema Then { get => this.schema.Then; set => this.schema.Then = value; }
public AsyncApiJsonSchema Then { get => this.schema.Then; set => this.schema.Then = value; }

public AsyncApiSchema Else { get => this.schema.Else; set => this.schema.Else = value; }
public AsyncApiJsonSchema Else { get => this.schema.Else; set => this.schema.Else = value; }

public ISet<string> Required { get => this.schema.Required; set => this.schema.Required = value; }

public AsyncApiSchema Items { get => this.schema.Items; set => this.schema.Items = value; }
public AsyncApiJsonSchema Items { get => this.schema.Items; set => this.schema.Items = value; }

public AsyncApiSchema AdditionalItems { get => this.schema.AdditionalItems; set => this.schema.AdditionalItems = value; }
public AsyncApiJsonSchema AdditionalItems { get => this.schema.AdditionalItems; set => this.schema.AdditionalItems = value; }

public int? MaxItems { get => this.schema.MaxItems; set => this.schema.MaxItems = value; }

public int? MinItems { get => this.schema.MinItems; set => this.schema.MinItems = value; }

public bool? UniqueItems { get => this.schema.UniqueItems; set => this.schema.UniqueItems = value; }

public IDictionary<string, AsyncApiSchema> Properties { get => this.schema.Properties; set => this.schema.Properties = value; }
public IDictionary<string, AsyncApiJsonSchema> Properties { get => this.schema.Properties; set => this.schema.Properties = value; }

public int? MaxProperties { get => this.schema.MaxProperties; set => this.schema.MaxProperties = value; }

public int? MinProperties { get => this.schema.MinProperties; set => this.schema.MinProperties = value; }

public IDictionary<string, AsyncApiSchema> PatternProperties { get => this.schema.PatternProperties; set => this.schema.PatternProperties = value; }
public IDictionary<string, AsyncApiJsonSchema> PatternProperties { get => this.schema.PatternProperties; set => this.schema.PatternProperties = value; }

public AsyncApiSchema PropertyNames { get => this.schema.PropertyNames; set => this.schema.PropertyNames = value; }
public AsyncApiJsonSchema PropertyNames { get => this.schema.PropertyNames; set => this.schema.PropertyNames = value; }

public string Discriminator { get => this.schema.Discriminator; set => this.schema.Discriminator = value; }

Expand All @@ -108,11 +108,11 @@

public IDictionary<string, IAsyncApiExtension> Extensions { get => this.schema.Extensions; set => this.schema.Extensions = value; }

public AsyncApiSchema AdditionalProperties { get => this.schema.AdditionalProperties; set => this.schema.AdditionalProperties = value; }
public AsyncApiJsonSchema AdditionalProperties { get => this.schema.AdditionalProperties; set => this.schema.AdditionalProperties = value; }

public static implicit operator AsyncApiSchema(AsyncApiJsonSchemaPayload payload) => payload.schema;
public static implicit operator AsyncApiJsonSchema(AsyncApiJsonSchemaPayload payload) => payload.schema;

public static implicit operator AsyncApiJsonSchemaPayload(AsyncApiSchema schema) => new AsyncApiJsonSchemaPayload(schema);
public static implicit operator AsyncApiJsonSchemaPayload(AsyncApiJsonSchema schema) => new AsyncApiJsonSchemaPayload(schema);

public void SerializeV2(IAsyncApiWriter writer)
{
Expand Down
Loading
Loading