{"record":{"id":"459237ddd9e45415","repo":"projectdiscovery/nuclei","slug":"can-t-get-example-for-additional-properties-v","errorCode":null,"errorMessage":"can't get example for additional properties: %+v","messagePattern":"can't get example for additional properties: %\\+v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/input/formats/openapi/examples.go","lineNumber":267,"sourceCode":"\t\t\t\tif isRequired(schema, k) {\n\t\t\t\t\treturn nil, fmt.Errorf(\"can't get example for '%s': %+v\", k, err)\n\t\t\t\t}\n\t\t\t} else if err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"can't get example for '%s': %+v\", k, err)\n\t\t\t} else {\n\t\t\t\texample[k] = ex\n\t\t\t}\n\t\t}\n\n\t\tif schema.AdditionalProperties.Has != nil && schema.AdditionalProperties.Schema != nil {\n\t\t\taddl := schema.AdditionalProperties.Schema.Value\n\n\t\t\tif !excludeFromMode(addl) {\n\t\t\t\tex, err := openAPIExample(addl, cache)\n\t\t\t\tif err == ErrRecursive {\n\t\t\t\t\t// We just won't add this if it's recursive.\n\t\t\t\t} else if err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"can't get example for additional properties: %+v\", err)\n\t\t\t\t} else {\n\t\t\t\t\texample[\"additionalPropertyName\"] = ex\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn example, nil\n\t}\n\treturn nil, ErrNoExample\n}\n\n// generateExampleFromSchema creates an example structure from an OpenAPI 3 schema\n// object, which is an extended subset of JSON Schema.\n//\n// https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#schemaObject\nfunc generateExampleFromSchema(schema *openapi3.Schema) (interface{}, error) {\n\treturn openAPIExample(schema, make(map[*openapi3.Schema]*cachedSchema)) // TODO: Use caching\n}\n","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/pkg/input/formats/openapi/examples.go#L249-L285","documentation":"The object schema declares additionalProperties with a schema, and generating an example for that schema failed with a non-recursive error (ErrNoExample or a deeper wrapped failure). The additionalProperties entry would have been emitted under the placeholder key 'additionalPropertyName'; instead the whole object example generation fails.","triggerScenarios":"additionalProperties: { type: object, properties: { x: {} } } where the inner schema is untyped with no example; additionalProperties referencing a schema that itself contains ungeneratable properties.","commonSituations":"Map/dictionary-typed payloads (additionalProperties as the map value schema); strict specs that add additionalProperties: false plus a schema block; code-generated specs attaching complex free-form value schemas.","solutions":["Add an `example` or concrete `type` to the additionalProperties schema","Drop the schema under additionalProperties if map values are truly free-form (a bare additionalProperties: true is not generated and does not fail)","Fix the nested cause named in the %v portion of the message"],"exampleFix":"# before\nadditionalProperties:\n  type: object\n  properties:\n    v: {}   # untyped -> ErrNoExample\n\n# after\nadditionalProperties:\n  type: string\n  example: \"value\"","handlingStrategy":"fallback","validationCode":"// spec check: additionalProperties with schema must carry a type or example\nif ap := schema.AdditionalProperties; ap.Has != nil && ap.Schema != nil {\n    s := ap.Schema.Value\n    if s.Type == nil && s.Example == nil && s.Default == nil && len(s.Enum) == 0 {\n        return fmt.Errorf(\"additionalProperties schema has no derivable example\")\n    }\n}","typeGuard":null,"tryCatchPattern":"if _, err := generateExampleFromSchema(schema); err != nil {\n    if strings.Contains(err.Error(), \"can't get example for additional properties\") {\n        // omit the additionalProperties schema (free-form maps generate nothing) and retry\n    }\n}","preventionTips":["Give additionalProperties schemas a concrete type or example","Use additionalProperties: true for free-form maps instead of attaching complex schemas","Validate dict-typed payloads in spec linting"],"tags":["openapi","schema","example-generation","additional-properties"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}