Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions src/OpenApi/gen/XmlCommentGenerator.Emitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ private static OpenApiParameter UnwrapOpenApiParameter(IOpenApiParameter sourceP
}
else
{
throw new InvalidOperationException("The input schema must be an OpenApiParameter or OpenApiParameterReference.");
throw new InvalidOperationException($"The input schema must be an {nameof(OpenApiParameter)} or {nameof(OpenApiParameterReference)}.");
}
}
else if (sourceParameter is OpenApiParameter directParameter)
Expand All @@ -407,7 +407,7 @@ private static OpenApiParameter UnwrapOpenApiParameter(IOpenApiParameter sourceP
}
else
{
throw new InvalidOperationException("The input schema must be an OpenApiParameter or OpenApiParameterReference.");
throw new InvalidOperationException("The input schema must be an {nameof(OpenApiParameter)} or {nameof(OpenApiParameterReference)}.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw new InvalidOperationException("The input schema must be an {nameof(OpenApiParameter)} or {nameof(OpenApiParameterReference)}.");
throw new InvalidOperationException($"The input schema must be an {nameof(OpenApiParameter)} or {nameof(OpenApiParameterReference)}.");

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

omg I hate myself

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one did make me feel bad 😅 when I spotted it in the snapshots

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's ok I groaned harder on the other whitespace issue

I really wish there was a nicer templating story for source generated files so you could catch these kinds of things more easily

}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/OpenApi/src/Services/Schemas/OpenApiSchemaService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ internal static IOpenApiSchema ResolveReferenceForSchema(OpenApiDocument documen
var schema = UnwrapOpenApiSchema(inputSchema);

if (schema.Metadata is not null &&
schema.Metadata.TryGetValue(OpenApiConstants.SchemaId, out var resolvedBaseSchemaId))
schema.Metadata.TryGetValue(OpenApiConstants.SchemaId, out var resolvedBaseSchemaId))
{
if (schema.AnyOf is { Count: > 0 })
{
Expand Down Expand Up @@ -241,7 +241,7 @@ private static OpenApiSchema UnwrapOpenApiSchema(IOpenApiSchema sourceSchema)
}
else
{
throw new InvalidOperationException("The input schema must be an OpenApiSchema or OpenApiSchemaReference.");
throw new InvalidOperationException($"The input schema must be an {nameof(OpenApiSchema)} or {nameof(OpenApiSchemaReference)}.");
}
}
else if (sourceSchema is OpenApiSchema directSchema)
Expand All @@ -250,7 +250,7 @@ private static OpenApiSchema UnwrapOpenApiSchema(IOpenApiSchema sourceSchema)
}
else
{
throw new InvalidOperationException("The input schema must be an OpenApiSchema or OpenApiSchemaReference.");
throw new InvalidOperationException($"The input schema must be an {nameof(OpenApiSchema)} or {nameof(OpenApiSchemaReference)}.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ private static OpenApiParameter UnwrapOpenApiParameter(IOpenApiParameter sourceP
}
else
{
throw new InvalidOperationException("The input schema must be an OpenApiParameter or OpenApiParameterReference.");
throw new InvalidOperationException($"The input schema must be an {nameof(OpenApiParameter)} or {nameof(OpenApiParameterReference)}.");
}
}
else if (sourceParameter is OpenApiParameter directParameter)
Expand All @@ -389,7 +389,7 @@ private static OpenApiParameter UnwrapOpenApiParameter(IOpenApiParameter sourceP
}
else
{
throw new InvalidOperationException("The input schema must be an OpenApiParameter or OpenApiParameterReference.");
throw new InvalidOperationException("The input schema must be an {nameof(OpenApiParameter)} or {nameof(OpenApiParameterReference)}.");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ private static OpenApiParameter UnwrapOpenApiParameter(IOpenApiParameter sourceP
}
else
{
throw new InvalidOperationException("The input schema must be an OpenApiParameter or OpenApiParameterReference.");
throw new InvalidOperationException($"The input schema must be an {nameof(OpenApiParameter)} or {nameof(OpenApiParameterReference)}.");
}
}
else if (sourceParameter is OpenApiParameter directParameter)
Expand All @@ -418,7 +418,7 @@ private static OpenApiParameter UnwrapOpenApiParameter(IOpenApiParameter sourceP
}
else
{
throw new InvalidOperationException("The input schema must be an OpenApiParameter or OpenApiParameterReference.");
throw new InvalidOperationException("The input schema must be an {nameof(OpenApiParameter)} or {nameof(OpenApiParameterReference)}.");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ private static OpenApiParameter UnwrapOpenApiParameter(IOpenApiParameter sourceP
}
else
{
throw new InvalidOperationException("The input schema must be an OpenApiParameter or OpenApiParameterReference.");
throw new InvalidOperationException($"The input schema must be an {nameof(OpenApiParameter)} or {nameof(OpenApiParameterReference)}.");
}
}
else if (sourceParameter is OpenApiParameter directParameter)
Expand All @@ -508,7 +508,7 @@ private static OpenApiParameter UnwrapOpenApiParameter(IOpenApiParameter sourceP
}
else
{
throw new InvalidOperationException("The input schema must be an OpenApiParameter or OpenApiParameterReference.");
throw new InvalidOperationException("The input schema must be an {nameof(OpenApiParameter)} or {nameof(OpenApiParameterReference)}.");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ private static OpenApiParameter UnwrapOpenApiParameter(IOpenApiParameter sourceP
}
else
{
throw new InvalidOperationException("The input schema must be an OpenApiParameter or OpenApiParameterReference.");
throw new InvalidOperationException($"The input schema must be an {nameof(OpenApiParameter)} or {nameof(OpenApiParameterReference)}.");
}
}
else if (sourceParameter is OpenApiParameter directParameter)
Expand All @@ -393,7 +393,7 @@ private static OpenApiParameter UnwrapOpenApiParameter(IOpenApiParameter sourceP
}
else
{
throw new InvalidOperationException("The input schema must be an OpenApiParameter or OpenApiParameterReference.");
throw new InvalidOperationException("The input schema must be an {nameof(OpenApiParameter)} or {nameof(OpenApiParameterReference)}.");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ private static OpenApiParameter UnwrapOpenApiParameter(IOpenApiParameter sourceP
}
else
{
throw new InvalidOperationException("The input schema must be an OpenApiParameter or OpenApiParameterReference.");
throw new InvalidOperationException($"The input schema must be an {nameof(OpenApiParameter)} or {nameof(OpenApiParameterReference)}.");
}
}
else if (sourceParameter is OpenApiParameter directParameter)
Expand All @@ -411,7 +411,7 @@ private static OpenApiParameter UnwrapOpenApiParameter(IOpenApiParameter sourceP
}
else
{
throw new InvalidOperationException("The input schema must be an OpenApiParameter or OpenApiParameterReference.");
throw new InvalidOperationException("The input schema must be an {nameof(OpenApiParameter)} or {nameof(OpenApiParameterReference)}.");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ private static OpenApiParameter UnwrapOpenApiParameter(IOpenApiParameter sourceP
}
else
{
throw new InvalidOperationException("The input schema must be an OpenApiParameter or OpenApiParameterReference.");
throw new InvalidOperationException($"The input schema must be an {nameof(OpenApiParameter)} or {nameof(OpenApiParameterReference)}.");
}
}
else if (sourceParameter is OpenApiParameter directParameter)
Expand All @@ -419,7 +419,7 @@ private static OpenApiParameter UnwrapOpenApiParameter(IOpenApiParameter sourceP
}
else
{
throw new InvalidOperationException("The input schema must be an OpenApiParameter or OpenApiParameterReference.");
throw new InvalidOperationException("The input schema must be an {nameof(OpenApiParameter)} or {nameof(OpenApiParameterReference)}.");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,8 @@ await VerifyOpenApiDocument(action, document =>
[([MinLength(2)] int[] id) => {}, (OpenApiSchema schema) => Assert.Equal(2, schema.MinItems)],
[([Length(4, 8)] int[] id) => {}, (OpenApiSchema schema) => { Assert.Equal(4, schema.MinItems); Assert.Equal(8, schema.MaxItems); }],
[([Range(4, 8)]int id) => {}, (OpenApiSchema schema) => { Assert.Equal("4", schema.Minimum); Assert.Equal("8", schema.Maximum); }],
[([Range(1234, 5678)]int id) => {}, (OpenApiSchema schema) => { Assert.Equal("1234", schema.Minimum); Assert.Equal("5678", schema.Maximum); }],
[([Range(1234.56, 7891.1)] decimal id) => {}, (OpenApiSchema schema) => { Assert.Equal("1234.56", schema.Minimum); Assert.Equal("7891.1", schema.Maximum); }],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[([Range(1234.56, 7891.1)] decimal id) => {}, (OpenApiSchema schema) => { Assert.Equal("1234.56", schema.Minimum); Assert.Equal("7891.1", schema.Maximum); }],
[([Range(1234.56, 7891.1)] decimal id) => {}, (OpenApiSchema schema) => { Assert.Equal("1234.56", schema.Minimum); Assert.Equal("7891.1", schema.Maximum); }],

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:groan:

[([Range(typeof(DateTime), "2024-02-01", "2024-02-031")] DateTime id) => {}, (OpenApiSchema schema) => { Assert.Null(schema.Minimum); Assert.Null(schema.Maximum); }],
[([StringLength(10)] string name) => {}, (OpenApiSchema schema) => { Assert.Equal(10, schema.MaxLength); Assert.Equal(0, schema.MinLength); }],
[([StringLength(10, MinimumLength = 5)] string name) => {}, (OpenApiSchema schema) => { Assert.Equal(10, schema.MaxLength); Assert.Equal(5, schema.MinLength); }],
Expand Down
Loading