Replies: 2 comments 1 reply
|
Vincent Biret (@baywet) Was it considered to keep the property setters in the interfaces? rwb196884 You can achieve that today by doing a type check. In all common cases, the instance will be of type |
1 reply
|
You don’t need to stay on v9 🙂 foreach (var property in schema.Properties
?? new Dictionary<string, IOpenApiSchema>())
{
if (property.Value is not OpenApiSchema targetSchema)
continue;
var propertyInfo = context.Type.GetProperties()
.SingleOrDefault(p => string.Equals(
p.Name, property.Key,
StringComparison.InvariantCultureIgnoreCase));
var attribute = propertyInfo?
.GetCustomAttribute<StringLengthAttribute>();
if (attribute is not null)
targetSchema.MaxLength = attribute.MaximumLength;
}The catch is that this skips reference schemas. That’s intentional: changing a referenced schema could affect other properties that share it. The type check makes you choose whether you want to edit an inline schema or the shared reference target, which is why the interface no longer exposes setters. Maintainer’s explanation. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I was doing this sort of thing
However this has been broken in version 10 because
OpenApiSchemahas been replaced byIOpenApiSchemawhich is not editable.I couldn't find anything about this in the upgrade notes, and I haven't been able to find a workaround.
Can it work or do I need to stay on version 9?
All reactions