[{"data":1,"prerenderedAt":1576},["ShallowReactive",2],{"libs":3,"navigation-laravel-openapi-generator":115,"\u002Flaravel-openapi-generator\u002Fdocumenting-endpoints\u002Fsampling":296,"\u002Flaravel-openapi-generator\u002Fdocumenting-endpoints\u002Fsampling-surround":1571},[4,45,69,95],{"id":5,"color":6,"compatibility":7,"extension":20,"icon":21,"links":22,"meta":27,"name":28,"order":29,"package":30,"related":31,"stem":34,"tagline":35,"__hash__":36,"slug":37,"repository":38,"branch":39,"path":40,"collection":41,"entry":42,"home":43,"version":44},"laravel_json_api_meta\u002Fdocs\u002Fsite\u002Flib.yml","violet",[8,13,16],{"version":9,"php":10,"laravel":11,"status":12},"3.x","^8.3","^12.46 || ^13.0","active",{"version":14,"php":10,"laravel":11,"status":15},"2.x","eol",{"version":17,"php":18,"laravel":19,"status":15},"1.x","^8.1","^10.0 || ^11.0 || ^12.0 || ^13.0","yml","i-lucide-braces",[23],{"label":24,"to":25,"icon":26},"JSON:API 1.1","https:\u002F\u002Fjsonapi.org\u002Fformat\u002F","i-lucide-book-marked",{},"Laravel JSON:API",10,"ark4ne\u002Flaravel-json-api",[32,33],"laravel-api-revisions","laravel-openapi-generator","docs\u002Fsite\u002Flib","JSON:API 1.1 resources for Laravel, with typed values, validated includes and fieldsets, and API revisions.","ILGoVp9rzKYDQc18VV8kkXy3EQOQ8rv87JblFKXYDrU","laravel-json-api","Ark4ne\u002Flaravel-json-api","master","docs\u002Fsite","laravel_json_api","\u002Flaravel-json-api\u002Fgetting-started\u002Fintroduction","\u002Flaravel-json-api","v3.0.0",{"id":46,"color":47,"compatibility":48,"extension":20,"icon":50,"links":51,"meta":56,"name":57,"order":58,"package":59,"related":60,"stem":34,"tagline":61,"__hash__":62,"slug":32,"repository":63,"branch":64,"path":40,"collection":65,"entry":66,"home":67,"version":68},"laravel_api_revisions_meta\u002Fdocs\u002Fsite\u002Flib.yml","amber",[49],{"version":17,"php":10,"laravel":11,"status":12},"i-lucide-git-branch",[52],{"label":53,"to":54,"icon":55},"Agent skill","https:\u002F\u002Fgithub.com\u002FArk4ne\u002Flaravel-api-revisions\u002Ftree\u002Fmain\u002Fskills\u002Flaravel-api-revisions","i-lucide-bot",{},"Laravel API Revisions",20,"ark4ne\u002Flaravel-api-revisions",[37,33],"Typed schemas for Laravel resources and form requests, evolved through dated API revisions, Stripe-style.","w24MBVK4_XliIZ8nVcfnuT9OgR-m-Ytxz31Pxua_mLM","Ark4ne\u002Flaravel-api-revisions","main","laravel_api_revisions","\u002Flaravel-api-revisions\u002Fgetting-started\u002Fintroduction","\u002Flaravel-api-revisions","v1.0.0",{"id":70,"color":71,"compatibility":72,"extension":20,"icon":77,"links":78,"meta":82,"name":83,"order":84,"package":85,"related":86,"stem":34,"tagline":88,"__hash__":89,"slug":33,"repository":90,"branch":39,"path":40,"collection":91,"entry":92,"home":93,"version":94},"laravel_openapi_generator_meta\u002Fdocs\u002Fsite\u002Flib.yml","emerald",[73,75],{"version":17,"php":10,"laravel":74,"status":12},"^13.0",{"version":76,"php":18,"laravel":19,"status":15},"0.6","i-lucide-file-json",[79],{"label":80,"to":81,"icon":26},"OpenAPI Specification","https:\u002F\u002Fspec.openapis.org\u002Foas\u002Flatest.html",{},"Laravel OpenAPI Generator",30,"ark4ne\u002Flaravel-openapi-generator",[87,37,32],"openapi-writer","Generates OpenAPI 3.0, 3.1 and 3.2 documents from a Laravel application, its routes, form requests and resources.","DTt0SVqegMImLmWmwL8LCW5lxRCWFYcnBFOaquLpVwc","Ark4ne\u002Flaravel-openapi-generator","laravel_openapi_generator","\u002Flaravel-openapi-generator\u002Fgetting-started\u002Fintroduction","\u002Flaravel-openapi-generator","v1.2.0",{"id":96,"color":97,"compatibility":98,"extension":20,"icon":101,"links":102,"meta":104,"name":105,"order":106,"package":107,"related":108,"stem":34,"tagline":109,"__hash__":110,"slug":87,"repository":111,"branch":64,"path":40,"collection":112,"entry":113,"home":114,"version":68},"openapi_writer_meta\u002Fdocs\u002Fsite\u002Flib.yml","sky",[99],{"version":17,"php":100,"status":12},"^8.2","i-lucide-file-pen-line",[103],{"label":80,"to":81,"icon":26},{},"OpenAPI Writer",40,"ark4ne\u002Fopenapi-writer",[33],"Framework-agnostic, fluent and immutable PHP builder for OpenAPI 3.0, 3.1 and 3.2 documents, written as JSON or YAML and validated.","JFQcdQ9GEChOkfRKibLjoxZOfnt6HYNsayX2melOzMk","Ark4ne\u002Fopenapi-writer","openapi_writer","\u002Fopenapi-writer\u002Fgetting-started\u002Fintroduction","\u002Fopenapi-writer",[116,135,169,191,213,243,258,284],{"title":117,"since":118,"experimental":119,"icon":120,"path":121,"stem":122,"children":123,"page":119},"Getting started",null,false,"i-lucide-rocket","\u002Flaravel-openapi-generator\u002Fgetting-started","laravel-openapi-generator\u002F1.getting-started",[124,127,131],{"title":125,"path":92,"stem":126,"since":118,"experimental":119},"Introduction","laravel-openapi-generator\u002F1.getting-started\u002F1.introduction",{"title":128,"path":129,"stem":130,"since":118,"experimental":119},"Installation","\u002Flaravel-openapi-generator\u002Fgetting-started\u002Finstallation","laravel-openapi-generator\u002F1.getting-started\u002F2.installation",{"title":132,"path":133,"stem":134,"since":118,"experimental":119},"Quick start","\u002Flaravel-openapi-generator\u002Fgetting-started\u002Fquick-start","laravel-openapi-generator\u002F1.getting-started\u002F3.quick-start",{"title":136,"since":118,"experimental":119,"icon":137,"path":138,"stem":139,"children":140,"page":119},"Documenting endpoints","i-lucide-route","\u002Flaravel-openapi-generator\u002Fdocumenting-endpoints","laravel-openapi-generator\u002F2.documenting-endpoints",[141,145,149,153,157,161,165],{"title":142,"path":143,"stem":144,"since":118,"experimental":119},"How it works","\u002Flaravel-openapi-generator\u002Fdocumenting-endpoints\u002Fhow-it-works","laravel-openapi-generator\u002F2.documenting-endpoints\u002F1.how-it-works",{"title":146,"path":147,"stem":148,"since":118,"experimental":119},"Routes & operations","\u002Flaravel-openapi-generator\u002Fdocumenting-endpoints\u002Froutes-and-operations","laravel-openapi-generator\u002F2.documenting-endpoints\u002F2.routes-and-operations",{"title":150,"path":151,"stem":152,"since":118,"experimental":119},"Requests","\u002Flaravel-openapi-generator\u002Fdocumenting-endpoints\u002Frequests","laravel-openapi-generator\u002F2.documenting-endpoints\u002F3.requests",{"title":154,"path":155,"stem":156,"since":118,"experimental":119},"Responses","\u002Flaravel-openapi-generator\u002Fdocumenting-endpoints\u002Fresponses","laravel-openapi-generator\u002F2.documenting-endpoints\u002F4.responses",{"title":158,"path":159,"stem":160,"since":118,"experimental":119},"Sampling","\u002Flaravel-openapi-generator\u002Fdocumenting-endpoints\u002Fsampling","laravel-openapi-generator\u002F2.documenting-endpoints\u002F5.sampling",{"title":162,"path":163,"stem":164,"since":118,"experimental":119},"Security & errors","\u002Flaravel-openapi-generator\u002Fdocumenting-endpoints\u002Fsecurity-and-errors","laravel-openapi-generator\u002F2.documenting-endpoints\u002F6.security-and-errors",{"title":166,"path":167,"stem":168,"since":118,"experimental":119},"Webhooks & callbacks","\u002Flaravel-openapi-generator\u002Fdocumenting-endpoints\u002Fwebhooks-and-callbacks","laravel-openapi-generator\u002F2.documenting-endpoints\u002F7.webhooks-and-callbacks",{"title":170,"since":118,"experimental":119,"icon":171,"path":172,"stem":173,"children":174,"page":119},"Documents","i-lucide-files","\u002Flaravel-openapi-generator\u002Fdocuments","laravel-openapi-generator\u002F3.documents",[175,179,183,187],{"title":176,"path":177,"stem":178,"since":118,"experimental":119},"Configuring a document","\u002Flaravel-openapi-generator\u002Fdocuments\u002Fconfiguring-a-document","laravel-openapi-generator\u002F3.documents\u002F1.configuring-a-document",{"title":180,"path":181,"stem":182,"since":118,"experimental":119},"Several documents","\u002Flaravel-openapi-generator\u002Fdocuments\u002Fseveral-documents","laravel-openapi-generator\u002F3.documents\u002F2.several-documents",{"title":184,"path":185,"stem":186,"since":118,"experimental":119},"Output","\u002Flaravel-openapi-generator\u002Fdocuments\u002Foutput","laravel-openapi-generator\u002F3.documents\u002F3.output",{"title":188,"path":189,"stem":190,"since":118,"experimental":119},"Translations","\u002Flaravel-openapi-generator\u002Fdocuments\u002Ftranslations","laravel-openapi-generator\u002F3.documents\u002F4.translations",{"title":192,"since":118,"experimental":119,"icon":193,"path":194,"stem":195,"children":196,"page":119},"Workflow","i-lucide-terminal","\u002Flaravel-openapi-generator\u002Fworkflow","laravel-openapi-generator\u002F4.workflow",[197,201,205,209],{"title":198,"path":199,"stem":200,"since":118,"experimental":119},"Diagnostics","\u002Flaravel-openapi-generator\u002Fworkflow\u002Fdiagnostics","laravel-openapi-generator\u002F4.workflow\u002F1.diagnostics",{"title":202,"path":203,"stem":204,"since":118,"experimental":119},"Continuous integration","\u002Flaravel-openapi-generator\u002Fworkflow\u002Fcontinuous-integration","laravel-openapi-generator\u002F4.workflow\u002F2.continuous-integration",{"title":206,"path":207,"stem":208,"since":118,"experimental":119},"Troubleshooting","\u002Flaravel-openapi-generator\u002Fworkflow\u002Ftroubleshooting","laravel-openapi-generator\u002F4.workflow\u002F3.troubleshooting",{"title":210,"path":211,"stem":212,"since":118,"experimental":119},"Agent skills","\u002Flaravel-openapi-generator\u002Fworkflow\u002Fagent-skills","laravel-openapi-generator\u002F4.workflow\u002F4.agent-skills",{"title":214,"since":118,"experimental":119,"icon":215,"path":216,"stem":217,"children":218,"page":119},"Extending","i-lucide-puzzle","\u002Flaravel-openapi-generator\u002Fextending","laravel-openapi-generator\u002F5.extending",[219,223,227,231,235,239],{"title":220,"path":221,"stem":222,"since":118,"experimental":119},"Overview","\u002Flaravel-openapi-generator\u002Fextending\u002Foverview","laravel-openapi-generator\u002F5.extending\u002F1.overview",{"title":224,"path":225,"stem":226,"since":118,"experimental":119},"Rule mappers","\u002Flaravel-openapi-generator\u002Fextending\u002Frule-mappers","laravel-openapi-generator\u002F5.extending\u002F2.rule-mappers",{"title":228,"path":229,"stem":230,"since":118,"experimental":119},"Request & response extractors","\u002Flaravel-openapi-generator\u002Fextending\u002Frequest-and-response-extractors","laravel-openapi-generator\u002F5.extending\u002F3.request-and-response-extractors",{"title":232,"path":233,"stem":234,"since":118,"experimental":119},"Operations & strategies","\u002Flaravel-openapi-generator\u002Fextending\u002Foperations-and-strategies","laravel-openapi-generator\u002F5.extending\u002F4.operations-and-strategies",{"title":236,"path":237,"stem":238,"since":118,"experimental":119},"Samplers","\u002Flaravel-openapi-generator\u002Fextending\u002Fsamplers","laravel-openapi-generator\u002F5.extending\u002F5.samplers",{"title":240,"path":241,"stem":242,"since":118,"experimental":119},"Passes & middlewares","\u002Flaravel-openapi-generator\u002Fextending\u002Fpasses-and-middlewares","laravel-openapi-generator\u002F5.extending\u002F6.passes-and-middlewares",{"title":244,"since":118,"experimental":119,"icon":245,"path":246,"stem":247,"children":248,"page":119},"Integrations","i-lucide-plug","\u002Flaravel-openapi-generator\u002Fintegrations","laravel-openapi-generator\u002F6.integrations",[249,253],{"title":250,"path":251,"stem":252,"since":118,"experimental":119},"JSON:API","\u002Flaravel-openapi-generator\u002Fintegrations\u002Fjson-api","laravel-openapi-generator\u002F6.integrations\u002F1.json-api",{"title":254,"path":255,"stem":256,"since":257,"experimental":119},"API revisions","\u002Flaravel-openapi-generator\u002Fintegrations\u002Fapi-revisions","laravel-openapi-generator\u002F6.integrations\u002F2.api-revisions","1.2",{"title":259,"since":118,"experimental":119,"icon":260,"path":261,"stem":262,"children":263,"page":119},"Reference","i-lucide-library","\u002Flaravel-openapi-generator\u002Freference","laravel-openapi-generator\u002F7.reference",[264,268,272,276,280],{"title":265,"path":266,"stem":267,"since":118,"experimental":119},"Configuration","\u002Flaravel-openapi-generator\u002Freference\u002Fconfiguration","laravel-openapi-generator\u002F7.reference\u002F1.configuration",{"title":269,"path":270,"stem":271,"since":118,"experimental":119},"Attributes","\u002Flaravel-openapi-generator\u002Freference\u002Fattributes","laravel-openapi-generator\u002F7.reference\u002F2.attributes",{"title":273,"path":274,"stem":275,"since":118,"experimental":119},"Commands","\u002Flaravel-openapi-generator\u002Freference\u002Fcommands","laravel-openapi-generator\u002F7.reference\u002F3.commands",{"title":277,"path":278,"stem":279,"since":118,"experimental":119},"Validation rules","\u002Flaravel-openapi-generator\u002Freference\u002Fvalidation-rules","laravel-openapi-generator\u002F7.reference\u002F4.validation-rules",{"title":281,"path":282,"stem":283,"since":118,"experimental":119},"PHPDoc types","\u002Flaravel-openapi-generator\u002Freference\u002Fphpdoc-types","laravel-openapi-generator\u002F7.reference\u002F5.phpdoc-types",{"title":285,"path":286,"children":287},"Releases","\u002Flaravel-openapi-generator\u002Freleases",[288,292],{"title":289,"path":290,"stem":291,"since":118,"experimental":119},"Upgrade guide","\u002Flaravel-openapi-generator\u002Fupgrade","laravel-openapi-generator\u002FUPGRADE",{"title":293,"path":294,"stem":295,"since":118,"experimental":119},"Changelog","\u002Flaravel-openapi-generator\u002Fchangelog","laravel-openapi-generator\u002FCHANGELOG",{"id":297,"title":158,"body":298,"description":1565,"experimental":119,"extension":1566,"links":118,"meta":1567,"navigation":1004,"path":159,"rawbody":1568,"seo":1569,"since":118,"stem":160,"__hash__":1570},"laravel_openapi_generator\u002Flaravel-openapi-generator\u002F2.documenting-endpoints\u002F5.sampling.md",{"type":299,"value":300,"toc":1556},"minimark",[301,318,323,326,366,417,442,446,512,525,699,717,721,726,758,927,933,944,948,969,1039,1048,1052,1058,1279,1306,1310,1456,1525,1529,1535,1543,1552],[302,303,304,305,309,310,314,315,317],"p",{},"A resource is not parsed: it is ",[306,307,308],"strong",{},"run",". The generator builds a sample of what the resource receives (usually a\nmodel), calls ",[311,312,313],"code",{},"toArray()"," on it, and describes the result. What ",[311,316,313],{}," returns is therefore exactly what the\ndocument says, conditions included.",[319,320,322],"h2",{"id":321},"what-a-resource-receives","What a resource receives",[302,324,325],{},"The generator finds the model of a resource, in this order:",[327,328,329,333,339,345,355],"ol",{},[330,331,332],"li",{},"the type of the constructor parameter of the resource;",[330,334,335,338],{},[311,336,337],{},"@extends JsonResource\u003CBook>",", or the model given to a base resource with its own template;",[330,340,341,344],{},[311,342,343],{},"@mixin Book",";",[330,346,347,350,351,354],{},[311,348,349],{},"#[UseResource]"," or ",[311,352,353],{},"#[UseResourceCollection]"," on a model;",[330,356,357,358,361,362,365],{},"the naming convention: ",[311,359,360],{},"App\\Http\\Resources\\BookResource"," → ",[311,363,364],{},"App\\Models\\Book",".",[367,368,374],"pre",{"className":369,"code":370,"filename":371,"language":372,"meta":373,"style":373},"language-php shiki shiki-themes material-theme-lighter github-light github-dark","\u002F**\n * @mixin Book\n *\u002F\nfinal class BookResource extends JsonResource\n","app\u002FHttp\u002FResources\u002FBookResource.php","php","",[311,375,376,385,391,397],{"__ignoreMap":373},[377,378,381],"span",{"class":379,"line":380},"line",1,[377,382,384],{"class":383},"sutJx","\u002F**\n",[377,386,388],{"class":379,"line":387},2,[377,389,390],{"class":383}," * @mixin Book\n",[377,392,394],{"class":379,"line":393},3,[377,395,396],{"class":383}," *\u002F\n",[377,398,400,404,407,411,414],{"class":379,"line":399},4,[377,401,403],{"class":402},"sbsja","final",[377,405,406],{"class":402}," class",[377,408,410],{"class":409},"sbgvK"," BookResource",[377,412,413],{"class":402}," extends",[377,415,416],{"class":409}," JsonResource\n",[302,418,419,420,423,424,423,427,430,431,361,434,437,438,441],{},"A collection finds its resource by ",[311,421,422],{},"#[Collects]",", ",[311,425,426],{},"$collects",[311,428,429],{},"@extends ResourceCollection\u003CBookResource>"," or\nLaravel's convention (",[311,432,433],{},"BookCollection",[311,435,436],{},"Book",", then ",[311,439,440],{},"BookResource",").",[319,443,445],{"id":444},"how-a-sample-is-made","How a sample is made",[447,448,449,462],"table",{},[450,451,452],"thead",{},[453,454,455,459],"tr",{},[456,457,458],"th",{},"The model has",[456,460,461],{},"The sample is",[463,464,465,488,500],"tbody",{},[453,466,467,478],{},[468,469,470,471,423,474,477],"td",{},"A factory (",[311,472,473],{},"HasFactory",[311,475,476],{},"#[UseFactory]",")",[468,479,480,483,484,487],{},[311,481,482],{},"create()"," inside a transaction rolled back at the end of the generation, or ",[311,485,486],{},"make()"," when no transaction is open",[453,489,490,493],{},[468,491,492],{},"No factory",[468,494,495,496,499],{},"a model filled with fake values typed by its ",[311,497,498],{},"@property"," tags, its casts and the columns of its table",[453,501,502,509],{},[468,503,504,505,508],{},"A ",[311,506,507],{},"#[ResourceFactory]"," on the resource",[468,510,511],{},"what that factory returns",[302,513,514,515,517,518,423,521,524],{},"The types of the values come from the ",[311,516,498],{}," tags, then the casts (which win on the type), then the nullability of\nthe columns when a database answers. A cast whose JSON depends on the value (",[311,519,520],{},"array",[311,522,523],{},"json",", custom casts) declares\nnothing: the sampled value is read.",[367,526,529],{"className":369,"code":527,"filename":528,"language":372,"meta":373,"style":373},"\u002F**\n * @property int $id\n * @property string $title\n * @property \\Illuminate\\Support\\Carbon|null $published_at\n *\u002F\nfinal class Book extends Model\n{\n    protected function casts(): array\n    {\n        return ['published_at' => 'datetime'];\n    }\n}\n","app\u002FModels\u002FBook.php",[311,530,531,535,549,561,597,602,617,624,648,654,687,693],{"__ignoreMap":373},[377,532,533],{"class":379,"line":380},[377,534,384],{"class":383},[377,536,537,540,543,546],{"class":379,"line":387},[377,538,539],{"class":383}," * ",[377,541,498],{"class":542},"sp_-d",[377,544,545],{"class":542}," int",[377,547,548],{"class":383}," $id\n",[377,550,551,553,555,558],{"class":379,"line":393},[377,552,539],{"class":383},[377,554,498],{"class":542},[377,556,557],{"class":542}," string",[377,559,560],{"class":383}," $title\n",[377,562,563,565,567,571,575,578,581,583,587,591,594],{"class":379,"line":399},[377,564,539],{"class":383},[377,566,498],{"class":542},[377,568,570],{"class":569},"slwOJ"," \\",[377,572,574],{"class":573},"sfi6f","Illuminate",[377,576,577],{"class":569},"\\",[377,579,580],{"class":573},"Support",[377,582,577],{"class":569},[377,584,586],{"class":585},"sCdfi","Carbon",[377,588,590],{"class":589},"sdyVB","|",[377,592,593],{"class":542},"null",[377,595,596],{"class":383}," $published_at\n",[377,598,600],{"class":379,"line":599},5,[377,601,396],{"class":383},[377,603,605,607,609,612,614],{"class":379,"line":604},6,[377,606,403],{"class":402},[377,608,406],{"class":402},[377,610,611],{"class":409}," Book",[377,613,413],{"class":402},[377,615,616],{"class":409}," Model\n",[377,618,620],{"class":379,"line":619},7,[377,621,623],{"class":622},"sP7_E","{\n",[377,625,627,630,633,637,640,644],{"class":379,"line":626},8,[377,628,629],{"class":402},"    protected",[377,631,632],{"class":402}," function",[377,634,636],{"class":635},"sGLFI"," casts",[377,638,639],{"class":622},"()",[377,641,643],{"class":642},"smGrS",":",[377,645,647],{"class":646},"sw1J6"," array\n",[377,649,651],{"class":379,"line":650},9,[377,652,653],{"class":622},"    {\n",[377,655,656,660,663,667,671,673,676,679,682,684],{"class":379,"line":29},[377,657,659],{"class":658},"sVHd0","        return",[377,661,662],{"class":622}," [",[377,664,666],{"class":665},"sjJ54","'",[377,668,670],{"class":669},"s_sjI","published_at",[377,672,666],{"class":665},[377,674,675],{"class":642}," =>",[377,677,678],{"class":665}," '",[377,680,681],{"class":669},"datetime",[377,683,666],{"class":665},[377,685,686],{"class":622},"];\n",[377,688,690],{"class":379,"line":689},11,[377,691,692],{"class":622},"    }\n",[377,694,696],{"class":379,"line":695},12,[377,697,698],{"class":622},"}\n",[700,701,702],"note",{},[302,703,704,705,708,709,712,713,716],{},"The database is never changed. Factories run inside a transaction opened on the default connection when its driver is\nin ",[311,706,707],{},"sampling.connections",", rolled back at the end of the generation, even when it fails. Models of another connection,\nor of a driver not listed, are made, never saved. Set ",[311,710,711],{},"sampling.transactions"," to ",[311,714,715],{},"false"," to never write.",[319,718,720],{"id":719},"required-and-optional-properties","Required and optional properties",[302,722,723,725],{},[311,724,313],{}," runs twice: on the sample, then on the sample with its relations loaded.",[727,728,729,735,746],"ul",{},[330,730,731,732,365],{},"A key returned by both runs is ",[306,733,734],{},"required",[330,736,737,738,741,742,745],{},"A key returned by the second run only (",[311,739,740],{},"whenLoaded()",") is ",[306,743,744],{},"optional",", and described.",[330,747,748,749,423,752,755,756,365],{},"A key computed with ",[311,750,751],{},"when()",[311,753,754],{},"mergeWhen()"," and the other conditional helpers is ",[306,757,744],{},[367,759,761],{"className":369,"code":760,"language":372,"meta":373,"style":373},"return [\n    \u002F\u002F required\n    'id' => $this->id,\n    \u002F\u002F required\n    'title' => $this->title,\n    \u002F\u002F optional, an Author component\n    'author' => new AuthorResource($this->whenLoaded('author')),\n    \u002F\u002F optional\n    'secret' => $this->when($request->user()?->isAdmin(), $this->secret),\n];\n",[311,762,763,771,776,801,805,824,829,869,874,923],{"__ignoreMap":373},[377,764,765,768],{"class":379,"line":380},[377,766,767],{"class":658},"return",[377,769,770],{"class":622}," [\n",[377,772,773],{"class":379,"line":387},[377,774,775],{"class":383},"    \u002F\u002F required\n",[377,777,778,781,784,786,788,792,795,798],{"class":379,"line":393},[377,779,780],{"class":665},"    '",[377,782,783],{"class":669},"id",[377,785,666],{"class":665},[377,787,675],{"class":642},[377,789,791],{"class":790},"s39Yj"," $this",[377,793,794],{"class":642},"->",[377,796,783],{"class":797},"su5hD",[377,799,800],{"class":622},",\n",[377,802,803],{"class":379,"line":399},[377,804,775],{"class":383},[377,806,807,809,812,814,816,818,820,822],{"class":379,"line":599},[377,808,780],{"class":665},[377,810,811],{"class":669},"title",[377,813,666],{"class":665},[377,815,675],{"class":642},[377,817,791],{"class":790},[377,819,794],{"class":642},[377,821,811],{"class":797},[377,823,800],{"class":622},[377,825,826],{"class":379,"line":604},[377,827,828],{"class":383},"    \u002F\u002F optional, an Author component\n",[377,830,831,833,836,838,840,843,847,850,853,855,858,860,862,864,866],{"class":379,"line":619},[377,832,780],{"class":665},[377,834,835],{"class":669},"author",[377,837,666],{"class":665},[377,839,675],{"class":642},[377,841,842],{"class":646}," new",[377,844,846],{"class":845},"sZMiF"," AuthorResource",[377,848,849],{"class":622},"(",[377,851,852],{"class":790},"$this",[377,854,794],{"class":642},[377,856,857],{"class":635},"whenLoaded",[377,859,849],{"class":622},[377,861,666],{"class":665},[377,863,835],{"class":669},[377,865,666],{"class":665},[377,867,868],{"class":622},")),\n",[377,870,871],{"class":379,"line":626},[377,872,873],{"class":383},"    \u002F\u002F optional\n",[377,875,876,878,881,883,885,887,889,892,895,898,900,903,905,908,911,914,916,918,920],{"class":379,"line":650},[377,877,780],{"class":665},[377,879,880],{"class":669},"secret",[377,882,666],{"class":665},[377,884,675],{"class":642},[377,886,791],{"class":790},[377,888,794],{"class":642},[377,890,891],{"class":635},"when",[377,893,894],{"class":622},"($",[377,896,897],{"class":797},"request",[377,899,794],{"class":642},[377,901,902],{"class":635},"user",[377,904,639],{"class":622},[377,906,907],{"class":642},"?->",[377,909,910],{"class":635},"isAdmin",[377,912,913],{"class":622},"(),",[377,915,791],{"class":790},[377,917,794],{"class":642},[377,919,880],{"class":797},[377,921,922],{"class":622},"),\n",[377,924,925],{"class":379,"line":29},[377,926,686],{"class":622},[302,928,929,930,365],{},"A nested resource is described like a returned one and becomes its own component, referenced by ",[311,931,932],{},"$ref",[302,934,935,936,939,940,943],{},"A second sample tells the values that never change from one sample to the other, such as ",[311,937,938],{},"'type' => 'cat'",": they are the\ndiscriminators of a ",[311,941,942],{},"CatResource|DogResource"," union.",[319,945,947],{"id":946},"components","Components",[302,949,950,951,954,955,958,959,961,962,964,965,968],{},"Each resource is a component of ",[311,952,953],{},"components.schemas",", named after its class without ",[311,956,957],{},"Resource"," (",[311,960,440],{}," →\n",[311,963,436],{},"). ",[311,966,967],{},"#[SchemaName]"," names it, on a resource or a backed enum:",[367,970,972],{"className":369,"code":971,"language":372,"meta":373,"style":373},"use Ark4ne\\OpenApi\\Attributes\\SchemaName;\n\n#[SchemaName('PublicBook')]\nfinal class BookResource extends JsonResource\n",[311,973,974,1000,1006,1027],{"__ignoreMap":373},[377,975,976,979,983,985,988,990,992,994,997],{"class":379,"line":380},[377,977,978],{"class":646},"use",[377,980,982],{"class":981},"s_hVV"," Ark4ne",[377,984,577],{"class":790},[377,986,987],{"class":981},"OpenApi",[377,989,577],{"class":790},[377,991,269],{"class":981},[377,993,577],{"class":790},[377,995,996],{"class":981},"SchemaName",[377,998,999],{"class":622},";\n",[377,1001,1002],{"class":379,"line":387},[377,1003,1005],{"emptyLinePlaceholder":1004},true,"\n",[377,1007,1008,1011,1013,1015,1017,1020,1022,1024],{"class":379,"line":393},[377,1009,1010],{"class":797},"#[",[377,1012,996],{"class":981},[377,1014,849],{"class":622},[377,1016,666],{"class":665},[377,1018,1019],{"class":669},"PublicBook",[377,1021,666],{"class":665},[377,1023,477],{"class":622},[377,1025,1026],{"class":797},"]\n",[377,1028,1029,1031,1033,1035,1037],{"class":379,"line":399},[377,1030,403],{"class":402},[377,1032,406],{"class":402},[377,1034,410],{"class":409},[377,1036,413],{"class":402},[377,1038,416],{"class":409},[302,1040,1041,1042,712,1045,1047],{},"Set ",[311,1043,1044],{},"use_references",[311,1046,715],{}," in a document to write every schema inline instead.",[319,1049,1051],{"id":1050},"resources-that-do-not-receive-a-model","Resources that do not receive a model",[302,1053,1054,1055,1057],{},"A resource built from a DTO, an array or anything that is not a model needs ",[311,1056,507],{}," to tell how its sample\nis built:",[367,1059,1062],{"className":369,"code":1060,"filename":1061,"language":372,"meta":373,"style":373},"use Ark4ne\\OpenApi\\Attributes\\ResourceFactory;\n\n#[ResourceFactory(\n    QuoteFactory::class,\n    method: 'sample',\n    parameters: ['currency' => 'EUR'],\n)]\nfinal class QuoteResource extends JsonResource\n{\n    public function toArray(Request $request): array\n    {\n        return [\n            'amount' => $this->resource->amount,\n            'currency' => $this->resource->currency,\n        ];\n    }\n}\n","app\u002FHttp\u002FResources\u002FQuoteResource.php",[311,1063,1064,1085,1089,1098,1111,1127,1155,1161,1174,1178,1204,1208,1214,1240,1263,1269,1274],{"__ignoreMap":373},[377,1065,1066,1068,1070,1072,1074,1076,1078,1080,1083],{"class":379,"line":380},[377,1067,978],{"class":646},[377,1069,982],{"class":981},[377,1071,577],{"class":790},[377,1073,987],{"class":981},[377,1075,577],{"class":790},[377,1077,269],{"class":981},[377,1079,577],{"class":790},[377,1081,1082],{"class":981},"ResourceFactory",[377,1084,999],{"class":622},[377,1086,1087],{"class":379,"line":387},[377,1088,1005],{"emptyLinePlaceholder":1004},[377,1090,1091,1093,1095],{"class":379,"line":393},[377,1092,1010],{"class":797},[377,1094,1082],{"class":981},[377,1096,1097],{"class":622},"(\n",[377,1099,1100,1103,1106,1109],{"class":379,"line":399},[377,1101,1102],{"class":845},"    QuoteFactory",[377,1104,1105],{"class":642},"::",[377,1107,1108],{"class":646},"class",[377,1110,800],{"class":622},[377,1112,1113,1116,1118,1120,1123,1125],{"class":379,"line":599},[377,1114,1115],{"class":409},"    method",[377,1117,643],{"class":622},[377,1119,678],{"class":665},[377,1121,1122],{"class":669},"sample",[377,1124,666],{"class":665},[377,1126,800],{"class":622},[377,1128,1129,1132,1134,1136,1138,1141,1143,1145,1147,1150,1152],{"class":379,"line":604},[377,1130,1131],{"class":409},"    parameters",[377,1133,643],{"class":622},[377,1135,662],{"class":622},[377,1137,666],{"class":665},[377,1139,1140],{"class":669},"currency",[377,1142,666],{"class":665},[377,1144,675],{"class":642},[377,1146,678],{"class":665},[377,1148,1149],{"class":669},"EUR",[377,1151,666],{"class":665},[377,1153,1154],{"class":622},"],\n",[377,1156,1157,1159],{"class":379,"line":619},[377,1158,477],{"class":622},[377,1160,1026],{"class":797},[377,1162,1163,1165,1167,1170,1172],{"class":379,"line":626},[377,1164,403],{"class":402},[377,1166,406],{"class":402},[377,1168,1169],{"class":409}," QuoteResource",[377,1171,413],{"class":402},[377,1173,416],{"class":409},[377,1175,1176],{"class":379,"line":650},[377,1177,623],{"class":622},[377,1179,1180,1183,1185,1188,1190,1193,1196,1198,1200,1202],{"class":379,"line":29},[377,1181,1182],{"class":402},"    public",[377,1184,632],{"class":402},[377,1186,1187],{"class":635}," toArray",[377,1189,849],{"class":622},[377,1191,1192],{"class":845},"Request",[377,1194,1195],{"class":622}," $",[377,1197,897],{"class":797},[377,1199,477],{"class":622},[377,1201,643],{"class":642},[377,1203,647],{"class":646},[377,1205,1206],{"class":379,"line":689},[377,1207,653],{"class":622},[377,1209,1210,1212],{"class":379,"line":695},[377,1211,659],{"class":658},[377,1213,770],{"class":622},[377,1215,1217,1220,1223,1225,1227,1229,1231,1234,1236,1238],{"class":379,"line":1216},13,[377,1218,1219],{"class":665},"            '",[377,1221,1222],{"class":669},"amount",[377,1224,666],{"class":665},[377,1226,675],{"class":642},[377,1228,791],{"class":790},[377,1230,794],{"class":642},[377,1232,1233],{"class":797},"resource",[377,1235,794],{"class":642},[377,1237,1222],{"class":797},[377,1239,800],{"class":622},[377,1241,1243,1245,1247,1249,1251,1253,1255,1257,1259,1261],{"class":379,"line":1242},14,[377,1244,1219],{"class":665},[377,1246,1140],{"class":669},[377,1248,666],{"class":665},[377,1250,675],{"class":642},[377,1252,791],{"class":790},[377,1254,794],{"class":642},[377,1256,1233],{"class":797},[377,1258,794],{"class":642},[377,1260,1140],{"class":797},[377,1262,800],{"class":622},[377,1264,1266],{"class":379,"line":1265},15,[377,1267,1268],{"class":622},"        ];\n",[377,1270,1272],{"class":379,"line":1271},16,[377,1273,692],{"class":622},[377,1275,1277],{"class":379,"line":1276},17,[377,1278,698],{"class":622},[302,1280,1281,1284,1285,1287,1288,1291,1292,1295,1296,1299,1300,1302,1303,1305],{},[311,1282,1283],{},"factory"," is a model factory class (its ",[311,1286,486],{}," receives ",[311,1289,1290],{},"parameters","), or any class whose ",[311,1293,1294],{},"method"," (or ",[311,1297,1298],{},"__invoke","\nwithout ",[311,1301,1294],{},") receives ",[311,1304,1290],{}," by name. The class is built through the container.",[319,1307,1309],{"id":1308},"settings","Settings",[367,1311,1314],{"className":369,"code":1312,"filename":1313,"language":372,"meta":373,"style":373},"'sampling' => [\n    'transactions' => true,\n    'connections' => ['mariadb', 'mysql', 'pgsql', 'sqlite', 'sqlsrv'],\n    'collection_size' => 2,\n    'seed' => 1,\n    'examples' => true,\n],\n","config\u002Fopenapi.php",[311,1315,1316,1329,1345,1404,1421,1437,1452],{"__ignoreMap":373},[377,1317,1318,1320,1323,1325,1327],{"class":379,"line":380},[377,1319,666],{"class":665},[377,1321,1322],{"class":669},"sampling",[377,1324,666],{"class":665},[377,1326,675],{"class":642},[377,1328,770],{"class":622},[377,1330,1331,1333,1336,1338,1340,1343],{"class":379,"line":387},[377,1332,780],{"class":665},[377,1334,1335],{"class":669},"transactions",[377,1337,666],{"class":665},[377,1339,675],{"class":642},[377,1341,1342],{"class":790}," true",[377,1344,800],{"class":622},[377,1346,1347,1349,1352,1354,1356,1358,1360,1363,1365,1368,1370,1373,1375,1377,1379,1382,1384,1386,1388,1391,1393,1395,1397,1400,1402],{"class":379,"line":393},[377,1348,780],{"class":665},[377,1350,1351],{"class":669},"connections",[377,1353,666],{"class":665},[377,1355,675],{"class":642},[377,1357,662],{"class":622},[377,1359,666],{"class":665},[377,1361,1362],{"class":669},"mariadb",[377,1364,666],{"class":665},[377,1366,1367],{"class":622},",",[377,1369,678],{"class":665},[377,1371,1372],{"class":669},"mysql",[377,1374,666],{"class":665},[377,1376,1367],{"class":622},[377,1378,678],{"class":665},[377,1380,1381],{"class":669},"pgsql",[377,1383,666],{"class":665},[377,1385,1367],{"class":622},[377,1387,678],{"class":665},[377,1389,1390],{"class":669},"sqlite",[377,1392,666],{"class":665},[377,1394,1367],{"class":622},[377,1396,678],{"class":665},[377,1398,1399],{"class":669},"sqlsrv",[377,1401,666],{"class":665},[377,1403,1154],{"class":622},[377,1405,1406,1408,1411,1413,1415,1419],{"class":379,"line":399},[377,1407,780],{"class":665},[377,1409,1410],{"class":669},"collection_size",[377,1412,666],{"class":665},[377,1414,675],{"class":642},[377,1416,1418],{"class":1417},"srdBf"," 2",[377,1420,800],{"class":622},[377,1422,1423,1425,1428,1430,1432,1435],{"class":379,"line":599},[377,1424,780],{"class":665},[377,1426,1427],{"class":669},"seed",[377,1429,666],{"class":665},[377,1431,675],{"class":642},[377,1433,1434],{"class":1417}," 1",[377,1436,800],{"class":622},[377,1438,1439,1441,1444,1446,1448,1450],{"class":379,"line":604},[377,1440,780],{"class":665},[377,1442,1443],{"class":669},"examples",[377,1445,666],{"class":665},[377,1447,675],{"class":642},[377,1449,1342],{"class":790},[377,1451,800],{"class":622},[377,1453,1454],{"class":379,"line":619},[377,1455,1154],{"class":622},[447,1457,1458,1468],{},[450,1459,1460],{},[453,1461,1462,1465],{},[456,1463,1464],{},"Key",[456,1466,1467],{},"Effect",[463,1469,1470,1482,1491,1500,1509],{},[453,1471,1472,1476],{},[468,1473,1474],{},[311,1475,1335],{},[468,1477,1478,1479,1481],{},"create the factory models inside a rolled back transaction; ",[311,1480,715],{},": only make them",[453,1483,1484,1488],{},[468,1485,1486],{},[311,1487,1351],{},[468,1489,1490],{},"the drivers a transaction is opened for",[453,1492,1493,1497],{},[468,1494,1495],{},[311,1496,1410],{},[468,1498,1499],{},"the number of items of a sampled collection",[453,1501,1502,1506],{},[468,1503,1504],{},[311,1505,1427],{},[468,1507,1508],{},"the seed of the fake values: two runs give the same document",[453,1510,1511,1515],{},[468,1512,1513],{},[311,1514,1443],{},[468,1516,1517,1518,1521,1522,1524],{},"write the sampled scalars as ",[311,1519,1520],{},"example","; ",[311,1523,715],{}," leaves them out",[319,1526,1528],{"id":1527},"when-a-resource-fails","When a resource fails",[302,1530,1531,1532,1534],{},"When ",[311,1533,313],{}," throws on a sample, the resource is described with what could be read, and a warning tells why:",[367,1536,1541],{"className":1537,"code":1539,"language":1540,"meta":373},[1538],"language-text","  GET \u002Fapi\u002Fbooks\u002F{book}\n    warning response: cannot run App\\Http\\Resources\\BookResource::toArray(): Call to a member function format() on null\n","text",[311,1542,1539],{"__ignoreMap":373},[302,1544,1545,1546,1548,1549,1551],{},"Give the model a factory, ",[311,1547,498],{}," tags or casts, or give the resource a ",[311,1550,507],{},". A failing run with\nrelations keeps the schema of the plain run.",[1553,1554,1555],"style",{},"html pre.shiki code .sutJx, html code.shiki .sutJx{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#6A737D;--shiki-default-font-style:inherit;--shiki-dark:#6A737D;--shiki-dark-font-style:inherit}html pre.shiki code .sbsja, html code.shiki .sbsja{--shiki-light:#9C3EDA;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sbgvK, html code.shiki .sbgvK{--shiki-light:#E2931D;--shiki-default:#6F42C1;--shiki-dark:#B392F0}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sp_-d, html code.shiki .sp_-d{--shiki-light:#F76D47;--shiki-light-font-style:italic;--shiki-default:#D73A49;--shiki-default-font-style:inherit;--shiki-dark:#F97583;--shiki-dark-font-style:inherit}html pre.shiki code .slwOJ, html code.shiki .slwOJ{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#005CC5;--shiki-default-font-style:inherit;--shiki-dark:#79B8FF;--shiki-dark-font-style:inherit}html pre.shiki code .sfi6f, html code.shiki .sfi6f{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#005CC5;--shiki-default-font-style:inherit;--shiki-dark:#79B8FF;--shiki-dark-font-style:inherit}html pre.shiki code .sCdfi, html code.shiki .sCdfi{--shiki-light:#E2931D;--shiki-light-font-style:italic;--shiki-default:#005CC5;--shiki-default-font-style:inherit;--shiki-dark:#79B8FF;--shiki-dark-font-style:inherit}html pre.shiki code .sdyVB, html code.shiki .sdyVB{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#6A737D;--shiki-default-font-style:inherit;--shiki-dark:#6A737D;--shiki-dark-font-style:inherit}html pre.shiki code .sP7_E, html code.shiki .sP7_E{--shiki-light:#39ADB5;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sGLFI, html code.shiki .sGLFI{--shiki-light:#6182B8;--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .smGrS, html code.shiki .smGrS{--shiki-light:#39ADB5;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sw1J6, html code.shiki .sw1J6{--shiki-light:#F76D47;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sVHd0, html code.shiki .sVHd0{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#D73A49;--shiki-default-font-style:inherit;--shiki-dark:#F97583;--shiki-dark-font-style:inherit}html pre.shiki code .sjJ54, html code.shiki .sjJ54{--shiki-light:#39ADB5;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .s_sjI, html code.shiki .s_sjI{--shiki-light:#91B859;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .s39Yj, html code.shiki .s39Yj{--shiki-light:#39ADB5;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .su5hD, html code.shiki .su5hD{--shiki-light:#90A4AE;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sZMiF, html code.shiki .sZMiF{--shiki-light:#E2931D;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .s_hVV, html code.shiki .s_hVV{--shiki-light:#90A4AE;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .srdBf, html code.shiki .srdBf{--shiki-light:#F76D47;--shiki-default:#005CC5;--shiki-dark:#79B8FF}",{"title":373,"searchDepth":393,"depth":393,"links":1557},[1558,1559,1560,1561,1562,1563,1564],{"id":321,"depth":387,"text":322},{"id":444,"depth":387,"text":445},{"id":719,"depth":387,"text":720},{"id":946,"depth":387,"text":947},{"id":1050,"depth":387,"text":1051},{"id":1308,"depth":387,"text":1309},{"id":1527,"depth":387,"text":1528},"How resources are described by running them on sampled models, and how to help when a resource fails.","md",{},"---\ntitle: Sampling\ndescription: How resources are described by running them on sampled models, and how to help when a resource fails.\n---\n\nA resource is not parsed: it is **run**. The generator builds a sample of what the resource receives (usually a\nmodel), calls `toArray()` on it, and describes the result. What `toArray()` returns is therefore exactly what the\ndocument says, conditions included.\n\n## What a resource receives\n\nThe generator finds the model of a resource, in this order:\n\n1. the type of the constructor parameter of the resource;\n2. `@extends JsonResource\u003CBook>`, or the model given to a base resource with its own template;\n3. `@mixin Book`;\n4. `#[UseResource]` or `#[UseResourceCollection]` on a model;\n5. the naming convention: `App\\Http\\Resources\\BookResource` → `App\\Models\\Book`.\n\n```php [app\u002FHttp\u002FResources\u002FBookResource.php]\n\u002F**\n * @mixin Book\n *\u002F\nfinal class BookResource extends JsonResource\n```\n\nA collection finds its resource by `#[Collects]`, `$collects`, `@extends ResourceCollection\u003CBookResource>` or\nLaravel's convention (`BookCollection` → `Book`, then `BookResource`).\n\n## How a sample is made\n\n| The model has | The sample is |\n| --- | --- |\n| A factory (`HasFactory`, `#[UseFactory]`) | `create()` inside a transaction rolled back at the end of the generation, or `make()` when no transaction is open |\n| No factory | a model filled with fake values typed by its `@property` tags, its casts and the columns of its table |\n| A `#[ResourceFactory]` on the resource | what that factory returns |\n\nThe types of the values come from the `@property` tags, then the casts (which win on the type), then the nullability of\nthe columns when a database answers. A cast whose JSON depends on the value (`array`, `json`, custom casts) declares\nnothing: the sampled value is read.\n\n```php [app\u002FModels\u002FBook.php]\n\u002F**\n * @property int $id\n * @property string $title\n * @property \\Illuminate\\Support\\Carbon|null $published_at\n *\u002F\nfinal class Book extends Model\n{\n    protected function casts(): array\n    {\n        return ['published_at' => 'datetime'];\n    }\n}\n```\n\n::note\nThe database is never changed. Factories run inside a transaction opened on the default connection when its driver is\nin `sampling.connections`, rolled back at the end of the generation, even when it fails. Models of another connection,\nor of a driver not listed, are made, never saved. Set `sampling.transactions` to `false` to never write.\n::\n\n## Required and optional properties\n\n`toArray()` runs twice: on the sample, then on the sample with its relations loaded.\n\n- A key returned by both runs is **required**.\n- A key returned by the second run only (`whenLoaded()`) is **optional**, and described.\n- A key computed with `when()`, `mergeWhen()` and the other conditional helpers is **optional**.\n\n```php\nreturn [\n    \u002F\u002F required\n    'id' => $this->id,\n    \u002F\u002F required\n    'title' => $this->title,\n    \u002F\u002F optional, an Author component\n    'author' => new AuthorResource($this->whenLoaded('author')),\n    \u002F\u002F optional\n    'secret' => $this->when($request->user()?->isAdmin(), $this->secret),\n];\n```\n\nA nested resource is described like a returned one and becomes its own component, referenced by `$ref`.\n\nA second sample tells the values that never change from one sample to the other, such as `'type' => 'cat'`: they are the\ndiscriminators of a `CatResource|DogResource` union.\n\n## Components\n\nEach resource is a component of `components.schemas`, named after its class without `Resource` (`BookResource` →\n`Book`). `#[SchemaName]` names it, on a resource or a backed enum:\n\n```php\nuse Ark4ne\\OpenApi\\Attributes\\SchemaName;\n\n#[SchemaName('PublicBook')]\nfinal class BookResource extends JsonResource\n```\n\nSet `use_references` to `false` in a document to write every schema inline instead.\n\n## Resources that do not receive a model\n\nA resource built from a DTO, an array or anything that is not a model needs `#[ResourceFactory]` to tell how its sample\nis built:\n\n```php [app\u002FHttp\u002FResources\u002FQuoteResource.php]\nuse Ark4ne\\OpenApi\\Attributes\\ResourceFactory;\n\n#[ResourceFactory(\n    QuoteFactory::class,\n    method: 'sample',\n    parameters: ['currency' => 'EUR'],\n)]\nfinal class QuoteResource extends JsonResource\n{\n    public function toArray(Request $request): array\n    {\n        return [\n            'amount' => $this->resource->amount,\n            'currency' => $this->resource->currency,\n        ];\n    }\n}\n```\n\n`factory` is a model factory class (its `make()` receives `parameters`), or any class whose `method` (or `__invoke`\nwithout `method`) receives `parameters` by name. The class is built through the container.\n\n## Settings\n\n```php [config\u002Fopenapi.php]\n'sampling' => [\n    'transactions' => true,\n    'connections' => ['mariadb', 'mysql', 'pgsql', 'sqlite', 'sqlsrv'],\n    'collection_size' => 2,\n    'seed' => 1,\n    'examples' => true,\n],\n```\n\n| Key | Effect |\n| --- | --- |\n| `transactions` | create the factory models inside a rolled back transaction; `false`: only make them |\n| `connections` | the drivers a transaction is opened for |\n| `collection_size` | the number of items of a sampled collection |\n| `seed` | the seed of the fake values: two runs give the same document |\n| `examples` | write the sampled scalars as `example`; `false` leaves them out |\n\n## When a resource fails\n\nWhen `toArray()` throws on a sample, the resource is described with what could be read, and a warning tells why:\n\n```text\n  GET \u002Fapi\u002Fbooks\u002F{book}\n    warning response: cannot run App\\Http\\Resources\\BookResource::toArray(): Call to a member function format() on null\n```\n\nGive the model a factory, `@property` tags or casts, or give the resource a `#[ResourceFactory]`. A failing run with\nrelations keeps the schema of the plain run.\n",{"title":158,"description":1565},"DGjXXa68GIcBpLCim44kpXq_SAHUCHLEAUr8wJ2pVxo",[1572,1574],{"title":154,"path":155,"stem":156,"description":1573,"children":-1},"Document the responses of an action from its return type, and declare what the return type cannot tell.",{"title":162,"path":163,"stem":164,"description":1575,"children":-1},"Security requirements from the middlewares, and the error responses the generator adds to each operation.",1795438899735]