Title: String component incorrectly typed as struct · Issue #519 · oapi-codegen/oapi-codegen · GitHub
Open Graph Title: String component incorrectly typed as struct · Issue #519 · oapi-codegen/oapi-codegen
X Title: String component incorrectly typed as struct · Issue #519 · oapi-codegen/oapi-codegen
Description: I have an openapi schema like this: openapi: 3.0.0 info: version: "0.0.1" title: Schema paths: "/": get: responses: "200": description: success content: application/json: schema: $ref: "#/components/schemas/B" components: schemas: A: typ...
Open Graph Description: I have an openapi schema like this: openapi: 3.0.0 info: version: "0.0.1" title: Schema paths: "/": get: responses: "200": description: success content: application/json: schema: $ref: "#/component...
X Description: I have an openapi schema like this: openapi: 3.0.0 info: version: "0.0.1" title: Schema paths: "/": get: responses: "200": description: success content: application/js...
Opengraph URL: https://github.com/oapi-codegen/oapi-codegen/issues/519
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"String component incorrectly typed as struct","articleBody":"I have an openapi schema like this:\r\n```yml\r\nopenapi: 3.0.0\r\ninfo:\r\n version: \"0.0.1\"\r\n title: Schema\r\npaths:\r\n \"/\":\r\n get:\r\n responses:\r\n \"200\":\r\n description: success\r\n content:\r\n application/json:\r\n schema:\r\n $ref: \"#/components/schemas/B\"\r\ncomponents:\r\n schemas:\r\n A:\r\n type: string\r\n enum: [\"foo\", \"bar\"]\r\n B:\r\n type: string\r\n allOf:\r\n - $ref: \"#/components/schemas/A\"\r\n enum: [\"baz\"]\r\n```\r\n\r\nI run the command \r\n```\r\noapi-codegen -generate types -o types.go ./schema.yml\r\n```\r\n\r\nAnd the result follows:\r\n```go\r\n// Package Schema provides primitives to interact with the openapi HTTP API.\r\n//\r\n// Code generated by github.com/deepmap/oapi-codegen version v1.8.2 DO NOT EDIT.\r\npackage Schema\r\n\r\n// Defines values for A.\r\nconst (\r\n\tABar A = \"bar\"\r\n\r\n\tAFoo A = \"foo\"\r\n)\r\n\r\n// A defines model for A.\r\ntype A string\r\n\r\n// B defines model for B.\r\ntype B struct {\r\n\t// Embedded struct due to allOf(#/components/schemas/A)\r\n\tA `yaml:\",inline\"`\r\n}\r\n\r\n```\r\n\r\nType B is incorrectly interpreted as a `struct` when it should be a `string`. Also, the constant `\"baz\"` is missing. I would expect Both `A` and `B` to be of type string.\r\n","author":{"url":"https://github.com/LucasDachman","@type":"Person","name":"LucasDachman"},"datePublished":"2022-02-07T23:17:35Z","url":"https://github.com/oapi-codegen/oapi-codegen/issues/519"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:fea6b4be-9ba4-10dd-e9be-b843c6a4bb8f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B42A:BAE7A:F75C81:1571B8F:6AFA3862 |
| html-safe-nonce | 000280eb751e2ebee0f72eaa66a0d0d1fc87e929d7967fd24894c85b0c392b81 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNDJBOkJBRTdBOkY3NUM4MToxNTcxQjhGOjZBRkEzODYyIiwidmlzaXRvcl9pZCI6IjY1OTkxODYxOTUxOTAyNjU5NTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 933d12f3e773760f29f9193b1529026543796153e15fc14aab45c89946868ece |
| hovercard-subject-tag | issue:1126606357 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/oapi-codegen/oapi-codegen/519/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ec58dbbe58db691d77f8ba746c7f7e38668fc3d8b68a3adf226a71643c925b5e/oapi-codegen/oapi-codegen/issues/519 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ec58dbbe58db691d77f8ba746c7f7e38668fc3d8b68a3adf226a71643c925b5e/oapi-codegen/oapi-codegen/issues/519 |
| og:image:alt | I have an openapi schema like this: openapi: 3.0.0 info: version: "0.0.1" title: Schema paths: "/": get: responses: "200": description: success content: application/json: schema: $ref: "#/component... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | LucasDachman |
| hostname | github.com |
| expected-hostname | github.com |
| None | 612d3e6ffd693e7ea8d9fcf452370995872baef31d825b1fedef704cd3d24ac7 |
| turbo-cache-control | no-preview |
| go-import | github.com/oapi-codegen/oapi-codegen git https://github.com/oapi-codegen/oapi-codegen.git |
| octolytics-dimension-user_id | 142752710 |
| octolytics-dimension-user_login | oapi-codegen |
| octolytics-dimension-repository_id | 173009358 |
| octolytics-dimension-repository_nwo | oapi-codegen/oapi-codegen |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 173009358 |
| octolytics-dimension-repository_network_root_nwo | oapi-codegen/oapi-codegen |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 072e34035c13c31543fba9f025cbbbda4210dae4 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width