Skip to content

"Additional properties false" added to every object in schema in UI when switching to OpenAPI 3.1 #2619

Description

@ntark

Describe the bug
After switching to OpenAPI 3.1 I am seeing "Additional properties false" added to every root/nested object in schema

OpenApi File To Reproduce

{
  "openapi": "3.1.1",
  "info": {
    "title": "API",
    "version": "1"
  },
  "paths": {
    "/": {
      "get": {
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BooleanModelResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "BooleanModel": {
        "type": "object",
        "properties": {
          "showBanner": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "BooleanModelResponse": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/BooleanModel"
          }
        },
        "additionalProperties": false
      }
    },
    "securitySchemes": {}
  },
  "security": [],
  "tags": []
}

Expected behavior
Additional properties false property not part of schema in UI

Image

Actual behavior
Additional properties false property part of schema in UI

Image

Additional context
Pasting provided sample swagger.json file into (I believe) official generator yields exact same behavior. ( Changing version to "openapi": "3.0.6" hides Additional proerties forbidden field).

Is there any way to prevent "additionalProperties": false from being added to generated swagger.json?
Or is that the correct and expected behavior?

Linked Issue

Activity

  1. ntark commented on Nov 19, 2025

    @ntark
    Author

    I looked through related code and it seems change (if any) should be made here:

    if (AdditionalPropertiesAllowed)
    {
    writer.WriteOptionalObject(
    OpenApiConstants.AdditionalProperties,
    AdditionalProperties,
    callback);
    }
    else
    {
    writer.WriteProperty(OpenApiConstants.AdditionalProperties, AdditionalPropertiesAllowed);
    }

    commenting line 483 fixes my issue.

    I believe there should be ability of passing / configuring a parameter so that writing of OpenApiConstants.AdditionalProperties can be skipped.

  2. ntark commented on Nov 22, 2025

    @ntark
    Author

    It seems doing that removes additionalProperties property from generated document:

            builder.Services.AddSwaggerGen(c =>
            {
                c.SchemaFilter<RemoveAdditionalPropertiesSchemaFilter>();
            });
    
        private class RemoveAdditionalPropertiesSchemaFilter : ISchemaFilter
        {
            public void Apply(IOpenApiSchema schema, SchemaFilterContext context)
            {
                if (schema is OpenApiSchema s)
                {
                    s.AdditionalPropertiesAllowed = true;
                }
            }
        }
    

    Produces:

    Image

    Can devs please comment on that solution?

  3. baywet commented on Dec 8, 2025

    @baywet
    Member

    Hi ntark
    Thank you for using the SDK and for reaching out.

    Thank you for your patience.

    I have authored the following PRs to address the issue:

    Let us know if you have any additional comments or questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions