Skip to content

Not possible to set x-enum-varnames and other "well known" properties #5305

@Demivan

Description

@Demivan

Describe the bug

Fix from #1993 (comment) is not possible to do now.

Version of NSwag toolchain, computer and .NET runtime used

NSwag 14.6.2
Dotnet 10

To Reproduce

public class EnumDocumentProcessor : IDocumentProcessor
{
	public void Process(DocumentProcessorContext context)
	{
		foreach (var schemaPair in context.Document.Components.Schemas)
		{
			var schema = schemaPair.Value;

			if (schema.IsEnumeration)
			{
				schema.ExtensionData ??= new Dictionary<string, object>();
				schema.ExtensionData.Add("x-enum-varnames", schema.EnumerationNames.ToArray());
			}
		}
	}
}

After applying this document processor, there are no x-enum-varnames in the schema.

Expected behavior

Adding properties to ExtensionData works.

Additional context

This is happening because there is EnumerationVarNamesRaw property that is mapped to x-enum-varnames. And because it is defined, data from ExtensionData is not used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions