swaggo / swag

Automatically generate RESTful API documentation with Swagger 2.0 for Go.
MIT License
10.58k stars 1.19k forks source link

Global override `any` type uses incorrect schema #1834

Closed ezequiel closed 3 months ago

ezequiel commented 3 months ago

Description

When specifying any as a global override in .swaggo, it seems to override with the object shema instead of the any schema

To Reproduce

.swaggo

replace json.RawMessage any

model.go

type Thing struct {
    data json.RawMessage `json:"data"`
}

Expected behavior

"model.Thing": {
    "type": "object",
    "properties": {
      "data": {}
    }
}

Actual behavior

"model.Thing": {
    "type": "object",
    "properties": {
      "data": {
        "type": "object"
      }
    }
}

Your swag version

e.g. v1.16.3

Your go version

e.g. v1.22.4

ezequiel commented 3 months ago

Issue seems to stem from:

https://github.com/swaggo/swag/blob/7204462ba422fd428d50e3ae7641e3c475a63183/operation.go#L845-L846

We can probably use &spec.Schema{} here instead?