{"record":{"id":"a867a62b7cd5910a","repo":"projectdiscovery/nuclei","slug":"can-t-get-example-for-s-v","errorCode":null,"errorMessage":"can't get example for '%s': %+v","messagePattern":"can't get example for '(.+?)': %\\+v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/input/formats/openapi/examples.go","lineNumber":250,"sourceCode":"\t\t\texample = append(example, ex)\n\n\t\t\tfor uint64(len(example)) < schema.MinItems {\n\t\t\t\texample = append(example, ex)\n\t\t\t}\n\t\t}\n\t\treturn example, nil\n\tcase schema.Type.Is(\"object\"), len(schema.Properties) > 0:\n\t\texample := map[string]interface{}{}\n\n\t\tfor k, v := range schema.Properties {\n\t\t\tif excludeFromMode(v.Value) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tex, err := openAPIExample(v.Value, cache)\n\t\t\tif err == ErrRecursive {\n\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 {","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/pkg/input/formats/openapi/examples.go#L232-L268","documentation":"During object example generation, the property named in the message returned ErrRecursive (the property's schema contains itself) AND that property is listed in the object's `required` array. Required properties cannot be skipped, so generation of the whole object example fails with the property name and the recursive-schema error.","triggerScenarios":"Tree-style schemas like Category { required: [parent], parent: $ref Category }; linked-list node schemas where next is required and self-referencing; comment threads with required children arrays referencing the same schema.","commonSituations":"Specs generated from ORM/domain models where back-references are mandatory; API tooling that marks every property required by default; graph APIs.","solutions":["Add an `example` to that required property's schema so the recursion check is never hit","If the property is not truly mandatory, remove it from the schema's required list (optional recursive properties are skipped gracefully)","Restructure the recursion: inline the first level or move the self-reference behind a non-required wrapper","Accept the gap: the operation relying on that body will not get a generated request"],"exampleFix":"# before (required self-reference)\nComment:\n  type: object\n  required: [body, replies]\n  properties:\n    body: { type: string }\n    replies:\n      type: array\n      items: { $ref: '#/components/schemas/Comment' }\n\n# after (optional recursion is skipped cleanly)\n  required: [body]\n  properties:\n    body: { type: string }\n    replies:\n      type: array\n      items: { $ref: '#/components/schemas/Comment' }\n      example: []","handlingStrategy":"validation","validationCode":"// spec lint: required properties must not be directly self-referencing without an example\nfor name, prop := range schema.Properties {\n    if isRequired(schema, name) && isSelfRef(prop.Value, schemaName) && prop.Value.Example == nil {\n        return fmt.Errorf(\"required property %s is recursive without an example\", name)\n    }\n}","typeGuard":null,"tryCatchPattern":"if _, err := generateExampleFromSchema(schema); err != nil {\n    if strings.Contains(err.Error(), \"can't get example for '\") && strings.Contains(err.Error(), \"Recursive\") {\n        // required self-reference: add an example in the spec or drop it from required\n    }\n}","preventionTips":["Avoid marking self-referencing properties as required in specs","Attach explicit examples to recursive schemas","Prefer inlining one level over self-$ref when you control the spec"],"tags":["openapi","schema","example-generation","recursion","required"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}