Skip to content

[regression] nullabillity problems wih dictionaries since 6.3.0 #2436

@RouR

Description

@RouR

I have some class

public class Class1
{
	public class Class1Request
	{          
		public Dictionary<string, int> Data { get; set; }
	}
}

Also I have

//https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1502
    public class AdditionalParametersDocumentFilter : IDocumentFilter
    {
        public void Apply(OpenApiDocument openApiDoc, DocumentFilterContext context)
        {
            foreach (var schema in context.SchemaRepository.Schemas)
            {
                if (schema.Value.AdditionalProperties == null)
                {
                    schema.Value.AdditionalPropertiesAllowed = false;
                }
            }
        }
    }

Generated result

6.2.3

"Class1Request": {
	"type": "object",
	"properties": {
	  "idempotencyKey": {
		"$ref": "#/components/schemas/IdempotencyKey"
	  },
	  "userId": {
		"$ref": "#/components/schemas/UserId"
	  },
	  "data": {
		"type": "object",
		"additionalProperties": {
		  "type": "integer",
		  "format": "int32"
		},
		"nullable": true
	  }
	},
	"additionalProperties": false
},		
public System.Collections.Generic.IDictionary<string, int> Data { get; set; }

6.3.0 and 6.3.1

"Class1Request": {
	"type": "object",
	"properties": {          
	  "data": {
		"type": "object",
		"additionalProperties": {
		  "type": "integer",
		  "format": "int32",
		  "nullable": true
		},
		"nullable": true
	  }
	},
	"additionalProperties": false
},
	  
public System.Collections.Generic.IDictionary<string, int?> Data { get; set; }	

I guess it was broken in
#2166

Expected result

public System.Collections.Generic.IDictionary<string, int> Data { get; set; }

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