orval icon indicating copy to clipboard operation
orval copied to clipboard

bug: readonly fields missing from mutation function input types

Open ezequiel opened this issue 1 year ago • 0 comments

What are the steps to reproduce this issue?

Minimal swagger.json

{
  "swagger": "2.0",
  "info": {
    "title": "My API",
    "version": "1.0"
  },
  "paths": {
    "/thing/update": {
      "post": {
        "operationId": "UpdateThing",
        "parameters": [
          {
            "name": "models.Thing",
            "in": "body",
            "required": true,
            "schema": {
              "type": "object",
              "$ref": "#/definitions/models.Thing"
            }
          }
        ],
        "responses": {
          "200": {
            "description": ""
          }
        }
      }
    }
  },
  "definitions": {
    "models.ThingDescription": {
      "type": "object",
      "properties": {
        "text": {
          "type": "string"
        }
      }
    },
    "models.Thing": {
      "type": "object",
      "properties": {
        "ThingDescriptions": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/models.ThingDescription"
          },
          "readOnly": true
        }
      }
    }
  }
}

What happens?

When calling the generated updateThing() function, the input body (modelsThing) is empty:

Screenshot 2024-02-25 at 2 58 28 AM

It looks like NonReadonly<T> is producing the incorrect type, thus breaking the types here

What were you expecting to happen?

modelsThing should have the correct type, not {}

What versions are you using?

Package Version: 6.25.0

ezequiel avatar Feb 25 '24 11:02 ezequiel