Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: Unexpected reference depth oapi-codegen#1348#1950

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
moemoequte wants to merge6 commits intooapi-codegen:main
base:main
Choose a base branch
Loading
frommoemoequte:main

Conversation

moemoequte
Copy link

Here is myapi.json file

{  "swagger": "2.0",  "info": {    "title": "",    "version": ""  },  "host": "example.com",  "basePath": "/example",  "schemes": [    "http",    "https"  ],  "consumes": [    "application/json"  ],  "produces": [    "application/json"  ],  "paths": {    "/info/search": {      "post": {        "summary": "",        "description": "",        "operationId": "InfoSearchHandler",        "responses": {          "200": {            "description": "A successful response.",            "schema": {              "$ref": "#/definitions/InfoSearchResp"            }          }        },        "parameters": [          {            "name": "body",            "in": "body",            "required": true,            "schema": {              "$ref": "#/definitions/InfoSearchReq"            }          }        ],        "tags": [          "info"        ]      }    }  },  "definitions": {    "AuthorizeResourceReq": {      "type": "object",      "properties": {        "action": {          "type": "integer",          "format": "int32"        },        "request_side": {          "type": "string"        }      },      "title": "AuthorizeResourceReq",      "required": [        "action",        "request_side"      ]    },    "AuthorizeResourceResp": {      "type": "object",      "properties": {        "code": {          "type": "integer",          "format": "int32"        },        "message": {          "type": "string"        }      },      "title": "AuthorizeResourceResp",      "required": [        "code",        "message"      ]    },    "InfoIDReq": {      "type": "object",      "properties": {        "user_id": {          "type": "string"        },        "phone": {          "type": "string"        }      },      "title": "InfoIDReq"    },    "InfoIDResp": {      "type": "object",      "properties": {        "code": {          "type": "integer",          "format": "int32"        },        "message": {          "type": "string"        },        "result": {          "$ref": "#/definitions/InfoIDResult"        }      },      "title": "InfoIDResp",      "required": [        "code",        "message",        "result"      ]    },    "InfoIDResult": {      "type": "object",      "properties": {        "user_id": {          "type": "string"        },        "username": {          "type": "string"        },        "nickname": {          "type": "string"        },        "name": {          "type": "string"        },        "phone": {          "type": "string"        },        "email": {          "type": "string"        }      },      "title": "InfoIDResult",      "required": [        "user_id",        "username"      ]    },    "InfoListReq": {      "type": "object",      "properties": {        "page": {          "type": "integer",          "format": "int32",          "default": "1"        },        "size": {          "type": "integer",          "format": "int32",          "default": "20"        },        "name": {          "type": "string"        },        "identity": {          "type": "string"        },        "phone": {          "type": "string"        }      },      "title": "InfoListReq",      "required": [        "page",        "size",        "name",        "identity",        "phone"      ]    },    "InfoListResp": {      "type": "object",      "properties": {        "code": {          "type": "integer",          "format": "int32"        },        "message": {          "type": "string"        },        "size": {          "type": "integer",          "format": "int32"        },        "total": {          "type": "integer",          "format": "int32"        },        "page": {          "type": "integer",          "format": "int32"        },        "result": {          "type": "array",          "items": {            "$ref": "#/definitions/InfoListResult"          }        }      },      "title": "InfoListResp",      "required": [        "code",        "message",        "size",        "total",        "page",        "result"      ]    },    "InfoListResult": {      "type": "object",      "properties": {        "user_id": {          "type": "string"        },        "username": {          "type": "string"        },        "nickname": {          "type": "string"        },        "name": {          "type": "string"        },        "identity": {          "type": "string"        },        "gender": {          "type": "integer",          "format": "int32"        },        "age": {          "type": "integer",          "format": "int32"        },        "is_active": {          "type": "boolean",          "format": "boolean"        },        "date_joined": {          "type": "string"        },        "last_login": {          "type": "string"        },        "phone": {          "type": "string"        },        "email": {          "type": "string"        },        "birthday": {          "type": "string"        },        "item": {          "type": "array",          "items": {            "$ref": "#/definitions/InfoListResultItem"          }        }      },      "title": "InfoListResult",      "required": [        "user_id",        "username",        "nickname",        "name",        "identity",        "gender",        "age",        "is_active",        "date_joined",        "last_login",        "birthday",        "item"      ]    },    "InfoListResultItem": {      "type": "object",      "properties": {        "item_id": {          "type": "string"        },        "item_code": {          "type": "string"        },        "item_value": {          "type": "string"        },        "start_date": {          "type": "string"        },        "end_date": {          "type": "string"        }      },      "title": "InfoListResultItem",      "required": [        "item_id",        "item_code",        "item_value"      ]    },    "InfoQueryResp": {      "type": "object",      "properties": {        "code": {          "type": "integer",          "format": "int32"        },        "message": {          "type": "string"        },        "result": {          "$ref": "#/definitions/InfoQueryResult"        }      },      "title": "InfoQueryResp",      "required": [        "code",        "message",        "result"      ]    },    "InfoQueryResult": {      "type": "object",      "properties": {        "user_id": {          "type": "string"        },        "username": {          "type": "string"        },        "nickname": {          "type": "string"        },        "gender": {          "type": "string"        },        "birthday": {          "type": "string"        },        "age": {          "type": "integer",          "format": "int32"        },        "phone": {          "type": "string"        },        "email": {          "type": "string"        },        "role": {          "type": "string"        },        "name": {          "type": "string"        },        "role_end_date": {          "type": "string"        },        "is_staff": {          "type": "boolean",          "format": "boolean"        },        "is_superuser": {          "type": "boolean",          "format": "boolean"        },        "huawei_openid": {          "type": "string"        },        "wechat_unionid": {          "type": "string"        },        "wechat_app_openid": {          "type": "string"        },        "head_image": {          "type": "string"        },        "huawei_health": {          "type": "integer",          "format": "int32",          "default": "0"        },        "item": {          "type": "array",          "items": {            "$ref": "#/definitions/InfoQueryResultItem"          }        }      },      "title": "InfoQueryResult",      "required": [        "user_id",        "nickname",        "gender",        "birthday",        "age",        "phone",        "email",        "role",        "is_staff",        "is_superuser",        "wechat_app_openid",        "huawei_health",        "item"      ]    },    "InfoQueryResultItem": {      "type": "object",      "properties": {        "item_id": {          "type": "string"        },        "item_code": {          "type": "string"        },        "item_value": {          "type": "string"        },        "start_date": {          "type": "string"        },        "end_date": {          "type": "string"        }      },      "title": "InfoQueryResultItem",      "required": [        "item_id",        "item_code",        "item_value"      ]    },    "InfoRenewReq": {      "type": "object",      "properties": {        "user_id": {          "type": "string"        },        "name": {          "type": "string"        },        "phone": {          "type": "string"        },        "email": {          "type": "string"        },        "is_active": {          "type": "boolean",          "format": "boolean"        }      },      "title": "InfoRenewReq",      "required": [        "user_id",        "name",        "phone",        "email",        "is_active"      ]    },    "InfoRenewResp": {      "type": "object",      "properties": {        "code": {          "type": "integer",          "format": "int32"        },        "message": {          "type": "string"        }      },      "title": "InfoRenewResp",      "required": [        "code",        "message"      ]    },    "InfoSearchReq": {      "type": "object",      "properties": {        "search": {          "type": "string"        }      },      "title": "InfoSearchReq",      "required": [        "search"      ]    },    "InfoSearchResp": {      "type": "object",      "properties": {        "code": {          "type": "integer",          "format": "int32"        },        "message": {          "type": "string"        },        "result": {          "type": "array",          "items": {            "$ref": "#/definitions/InfoSearchResult"          }        }      },      "title": "InfoSearchResp",      "required": [        "code",        "message",        "result"      ]    },    "InfoSearchResult": {      "type": "object",      "properties": {        "user_id": {          "type": "string"        },        "username": {          "type": "string"        },        "nickname": {          "type": "string"        },        "name": {          "type": "string"        },        "phone": {          "type": "string"        },        "email": {          "type": "string"        }      },      "title": "InfoSearchResult",      "required": [        "user_id",        "username"      ]    },    "InfoServicesReq": {      "type": "object",      "properties": {        "user_id": {          "type": "array",          "items": {            "type": "string"          }        },        "phone": {          "type": "array",          "items": {            "type": "string"          }        }      },      "title": "InfoServicesReq"    },    "InfoServicesResp": {      "type": "object",      "properties": {        "code": {          "type": "integer",          "format": "int32"        },        "message": {          "type": "string"        },        "result": {          "type": "array",          "items": {            "$ref": "#/definitions/InfoServicesResult"          }        }      },      "title": "InfoServicesResp",      "required": [        "code",        "message",        "result"      ]    },    "InfoServicesResult": {      "type": "object",      "properties": {        "user_id": {          "type": "string"        },        "username": {          "type": "string"        },        "name": {          "type": "string"        },        "gender": {          "type": "integer",          "format": "int32"        },        "age": {          "type": "integer",          "format": "int32"        },        "phone": {          "type": "string"        },        "email": {          "type": "string"        },        "birthday": {          "type": "string"        },        "source": {          "type": "string"        },        "role": {          "type": "string"        },        "role_end_date": {          "type": "string"        }      },      "title": "InfoServicesResult",      "required": [        "user_id",        "username",        "name",        "gender",        "age",        "birthday",        "source",        "role"      ]    },    "InfoUpdateReq": {      "type": "object",      "properties": {        "nickname": {          "type": "string"        },        "head_image": {          "type": "string"        },        "item": {          "type": "array",          "items": {            "$ref": "#/definitions/InfoQueryResultItem"          }        }      },      "title": "InfoUpdateReq",      "required": [        "item"      ]    },    "InfoUpdateResp": {      "type": "object",      "properties": {        "code": {          "type": "integer",          "format": "int32"        },        "message": {          "type": "string"        }      },      "title": "InfoUpdateResp",      "required": [        "code",        "message"      ]    },    "UpdateUsernameReq": {      "type": "object",      "properties": {        "username": {          "type": "string"        }      },      "title": "UpdateUsernameReq",      "required": [        "username"      ]    },    "UpdateUsernameResp": {      "type": "object",      "properties": {        "code": {          "type": "integer",          "format": "int32"        },        "message": {          "type": "string"        }      },      "title": "UpdateUsernameResp",      "required": [        "code",        "message"      ]    }  },  "securityDefinitions": {    "apiKey": {      "type": "apiKey",      "description": "Enter JWT Bearer token **_only_**",      "name": "Authorization",      "in": "header"    }  }}

Here is my cfg.yaml

# yaml-language-server: $schema=https://raw.githubusercontent.com/oapi-codegen/oapi-codegen/HEAD/configuration-schema.jsonpackage: commonoutput: ../app/internal/common/client.gen.gogenerate:  models: true  client: true

I execute

oapi-codegen -config cfg.yaml api.json

Here is my Error log

error generating code: error creating operation definitions: error describing global parameters for POST//info/search: error generating type for param (body): error turning reference (#/definitions/InfoSearchReq) into a Go type: unexpected reference depth: 3 for ref: #/definitions/InfoSearchReq local: true

If I merge the fix branch, the problem solve

jamietannaand others added6 commitsDecember 18, 2023 17:00
In my opinion, this check doesn't seem to be providing much value, andwe've got a few folks requesting this be disabled.Instead of gating this behind a feature flag, we'll just remove it.Closesoapi-codegen#1348.
@jamietanna
Copy link
Member

@moemoequte this spec you're using is OpenAPI 2.0 (aka Swagger) which isn't supported byoapi-codegen

Can you retry after converting from OpenAPI 2.0 to 3.0? Thanks

@jamietannajamietanna marked this pull request as draftApril 14, 2025 06:20
@jamietannajamietanna changed the base branch frommain tofeature/remove-reference-depth-checkApril 14, 2025 06:20
@jamietannajamietanna changed the base branch fromfeature/remove-reference-depth-check tomainApril 14, 2025 06:21
@iamkhalidbashir
Copy link

having same error with openapi 3.0

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@moemoequte@jamietanna@iamkhalidbashir

[8]ページ先頭

©2009-2025 Movatter.jp