microsoft / kiota

OpenAPI based HTTP Client code generator
https://aka.ms/kiota/docs
MIT License
2.49k stars 177 forks source link

Required values for #refs not respected #4536

Closed azan-n closed 3 months ago

azan-n commented 3 months ago

Based on this stackoverflow post, I have tried different variations to get values in a requestBody to be marked as required but they do not work. In comparison, using openapi-generator with the typescript-fetch generator and the openapi-typescript library works (sometimes).

I like the approach kiota has taken for building a fetch wrapper and I am leaning strongly toward using it. Here are the variations that I have tried using:

1

{
  "allOf": [
    {
      "$ref": "#/components/schemas/Schema"
    },
    {
      "required": [
        "propertyName"
      ],
      "type": "object"
    }
  ]
}

2

{
  "allOf": [{"$ref": "#/components/schemas/Schema"}],
  "required": ["propertyName"],
}

3

{
  "allOf": [
    {
      "$ref": "#/components/schemas/Schema"
    },
    {
      "required": [
        "propertyName"
      ],
      "type": "object",
      "properties": {
        "propertyName": {...}
      }
    }
  ]
}

4

{
  "$ref": "#/components/schemas/Schema"},
  "required": ["propertyName"],
}
variant openapi-ts kiota openapi-generator
1 🟥
2 🟥 🟥
3 🟥
4 🟥 🟥 🟥

Please advise on how I should proceed. I'm more than willing to submit a PR to make this work.

baywet commented 3 months ago

Hi @azan-n Thanks for using kiota and for the detailed analysis. This discussion is already happening at #3911 so I'm going to go ahead and close this issue as duplicate. Please share your views on that thread :)