Skip to content

Fix object types with array type (e.g. ["object", "null"]) being inferred as undefined#3652

Merged
ardatan merged 3 commits intomasterfrom
copilot/fix-object-types-inference
Mar 20, 2026
Merged

Fix object types with array type (e.g. ["object", "null"]) being inferred as undefined#3652
ardatan merged 3 commits intomasterfrom
copilot/fix-object-types-inference

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 19, 2026

  • Fix FixMissingTypeObject to not override schemas that already have a type field (e.g. type: ["object", "null"])
  • Fix FixMissingAdditionalProperties to also handle schemas with array type containing "object" (e.g. type: ["object", "null"])
  • Add a test OAS fixture with type: ["object", "null"] schema
  • Add a TypeScript type test validating the fix
  • Add changeset describing the bug fix
Original prompt

This section details on the original issue you should resolve

<issue_title>Object types being inferred as undefined</issue_title>
<issue_description>Describe the bug

My openapi spec has an object type but on my fets client is showing only undefined.

To Reproduce Steps to reproduce the behavior:

Generate an openapi with this item and instantiate a fets client:

//...
"id_doc_front_file": {
    "type": [
      "object",
      "null"
    ],
    "properties": {
      "url": {
        "type": "string",
        "format": "uri",
        "example": "https://example.com/document.pdf"
      },
      "name": {
        "type": "string",
        "example": "File name.jpg"
      },
      "size": {
        "type": "number",
        "example": 123456
      }
    },
    "required": [
      "url",
      "name",
      "size"
    ]
  }
//... 

Expected behavior

It should be inferred as an object with three keys: url, name and size.

But is inferring as undefined:

CleanShot 2024-08-10 at 23 27 39

Environment:

  • OS: Macos Sonoma
  • Openapi Version: 3.1.0
  • NodeJS: 20.9.0
    </issue_description>

Comments on the Issue (you are @copilot in this section)

@ardatan Are you sure if it is valid to have both `object` and `null` in `type` as an array because there is always `properties` there?

📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

…ject\", \"null\"])

Co-authored-by: ardatan <20847995+ardatan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix object types being inferred as undefined Fix object types with array type (e.g. ["object", "null"]) being inferred as undefined Mar 19, 2026
Copilot AI requested a review from ardatan March 19, 2026 21:34
Co-authored-by: ardatan <20847995+ardatan@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

💻 Website Preview

The latest changes are available as preview in: https://5b9cff59.fets.pages.dev

@github-actions
Copy link
Copy Markdown
Contributor

✅ Benchmark Results

     ✓ no_errors{server:node-http,mode:no-schema}
     ✓ expected_result{server:node-http,mode:no-schema}
     ✓ no_errors{server:node-http,mode:json-schema}
     ✓ expected_result{server:node-http,mode:json-schema}
     ✓ no_errors{server:uWebSockets,mode:no-schema}
     ✓ expected_result{server:uWebSockets,mode:no-schema}
     ✓ no_errors{server:uWebSockets,mode:json-schema}
     ✓ expected_result{server:uWebSockets,mode:json-schema}

     checks......................................: 100.00% ✓ 855566      ✗ 0     
     data_received...............................: 78 MB   647 kB/s
     data_sent...................................: 54 MB   453 kB/s
     http_req_blocked............................: avg=1.54µs   min=901ns    med=1.47µs   max=280.02µs p(90)=1.93µs   p(95)=2.09µs  
     http_req_connecting.........................: avg=1ns      min=0s       med=0s       max=124.47µs p(90)=0s       p(95)=0s      
     http_req_duration...........................: avg=197.72µs min=136.62µs med=188.24µs max=17.36ms  p(90)=214.36µs p(95)=223.19µs
       { expected_response:true }................: avg=197.72µs min=136.62µs med=188.24µs max=17.36ms  p(90)=214.36µs p(95)=223.19µs
     ✓ { server:node-http,mode:json-schema }.....: avg=210.31µs min=153.27µs med=199.63µs max=12.84ms  p(90)=223.1µs  p(95)=231.4µs 
     ✓ { server:node-http,mode:no-schema }.......: avg=203.89µs min=140.31µs med=191.7µs  max=17.36ms  p(90)=218.11µs p(95)=228.55µs
     ✓ { server:uWebSockets,mode:json-schema }...: avg=192.59µs min=142.11µs med=184.9µs  max=11.59ms  p(90)=206.96µs p(95)=214.17µs
     ✓ { server:uWebSockets,mode:no-schema }.....: avg=185.53µs min=136.62µs med=177.6µs  max=11.91ms  p(90)=199.41µs p(95)=206.88µs
     http_req_failed.............................: 0.00%   ✓ 0           ✗ 427783
     http_req_receiving..........................: avg=24.91µs  min=13.24µs  med=23.77µs  max=12.37ms  p(90)=29.02µs  p(95)=31.62µs 
     http_req_sending............................: avg=9.2µs    min=5.43µs   med=9.24µs   max=1.46ms   p(90)=12.27µs  p(95)=13.53µs 
     http_req_tls_handshaking....................: avg=0s       min=0s       med=0s       max=0s       p(90)=0s       p(95)=0s      
     http_req_waiting............................: avg=163.6µs  min=107.83µs med=155.2µs  max=17.28ms  p(90)=178.55µs p(95)=186.52µs
     http_reqs...................................: 427783  3564.818976/s
     iteration_duration..........................: avg=275.51µs min=196.12µs med=265.13µs max=17.52ms  p(90)=295.29µs p(95)=306.58µs
     iterations..................................: 427783  3564.818976/s
     vus.........................................: 1       min=1         max=1   
     vus_max.....................................: 2       min=2         max=2   

@ardatan ardatan marked this pull request as ready for review March 19, 2026 21:58
@ardatan ardatan merged commit 4c0976b into master Mar 20, 2026
18 checks passed
@ardatan ardatan deleted the copilot/fix-object-types-inference branch March 20, 2026 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Object types being inferred as undefined

2 participants