Title: OAS3.1.0 const naming is long and different than other types · Issue #2596 · oapi-codegen/oapi-codegen · GitHub
Open Graph Title: OAS3.1.0 const naming is long and different than other types · Issue #2596 · oapi-codegen/oapi-codegen
X Title: OAS3.1.0 const naming is long and different than other types · Issue #2596 · oapi-codegen/oapi-codegen
Description: I have a simple oas3 file v3.1.0 with both const and regular objects. Here is my config cfg-schemas.yaml: package: api generate: models: true output: go/api/schemas.go output-options: skip-prune: true name-normalizer: ToCamelCaseWithInit...
Open Graph Description: I have a simple oas3 file v3.1.0 with both const and regular objects. Here is my config cfg-schemas.yaml: package: api generate: models: true output: go/api/schemas.go output-options: skip-prune: t...
X Description: I have a simple oas3 file v3.1.0 with both const and regular objects. Here is my config cfg-schemas.yaml: package: api generate: models: true output: go/api/schemas.go output-options: skip-prune: t...
Opengraph URL: https://github.com/oapi-codegen/oapi-codegen/issues/2596
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"OAS3.1.0 const naming is long and different than other types","articleBody":"I have a simple oas3 file v3.1.0 with both const and regular objects. Here is my config `cfg-schemas.yaml`:\n\n```yaml\npackage: api\ngenerate:\n models: true\noutput: go/api/schemas.go\noutput-options:\n skip-prune: true\n name-normalizer: ToCamelCaseWithInitialisms\n yaml-tags: true\n```\n\nAnd my schemas input file (simplified) `schemas.yaml`:\n\n```yaml\nopenapi: \"3.1.0\"\ncomponents:\n schemas:\n SomeConst:\n type: string\n const: \"someconststringinput/fields/aes256\"\n OtherConst:\n type: string\n const: \"otherconststringinput/subdata/ed25519\" \n Metadata:\n type: object\n properties:\n name:\n type: string\n description: name of the input\n description:\n type: string\n description: description of the input\n digest:\n type: string\n description: SHA256 digest of the input\n```\n\nAnd then I run:\n\n```\noapi-codegen -config ./cfg-schemas.yaml ./schemas.yaml\n```\n\nThe output I get is the following:\n\n```go\n// Package api provides primitives to interact with the openapi HTTP API.\n//\n// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.8.0 DO NOT EDIT.\npackage api\n\n// Defines values for OtherConst.\nconst (\n OtherconststringinputSubdataEd25519 OtherConst = \"otherconststringinput/subdata/ed25519\"\n)\n\n// Valid indicates whether the value is a known member of the OtherConst enum.\nfunc (e OtherConst) Valid() bool {\n switch e {\n case OtherconststringinputSubdataEd25519:\n return true\n default:\n return false\n }\n}\n\n// Defines values for SomeConst.\nconst (\n SomeconststringinputFieldsAes256 SomeConst = \"someconststringinput/fields/aes256\"\n)\n\n// Valid indicates whether the value is a known member of the SomeConst enum.\nfunc (e SomeConst) Valid() bool {\n switch e {\n case SomeconststringinputFieldsAes256:\n return true\n default:\n return false\n }\n}\n\n// Metadata defines model for Metadata.\ntype Metadata struct {\n // Description description of the input\n Description *string `json:\"description,omitempty\" yaml:\"description,omitempty\"`\n\n // Digest SHA256 digest of the input\n Digest *string `json:\"digest,omitempty\" yaml:\"digest,omitempty\"`\n\n // Name name of the input\n Name *string `json:\"name,omitempty\" yaml:\"name,omitempty\"`\n}\n\n// OtherConst defines model for OtherConst.\ntype OtherConst string\n\n// SomeConst defines model for SomeConst.\ntype SomeConst string\n```\n\nNotice that my `Metadata` component becomes `type Metadata struct`, while my peer `SomeConst` constant become `type SomeConst string` which can be access via the painfully named `SomeconststringinputFieldsAes256 SomeConst = \"someconststringinput/fields/aes256\"`.\n\nSince this is a constant, I don't care much to create a `type SomeConst` which is just a `string`, and then have a single object with a long name `SomeconststringinputFieldsAes256` (looks like derived from the const value?) for it. I really am just looking for the simple:\n\n```go\nconst SomeConst = \"someconststringinput/fields/aes256\"\n```\n\nI hope this describes the issue well?","author":{"url":"https://github.com/deitch","@type":"Person","name":"deitch"},"datePublished":"2026-09-29T16:17:05Z","url":"https://github.com/oapi-codegen/oapi-codegen/issues/2596"}
| 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:867463b9-82c8-4164-3ca2-9b62b9953ae2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E85C:13BDBD:1C689:25135:6AF9BAC0 |
| html-safe-nonce | be75284b2ef631affe43ef0523da167f9754c57ecf99d244ca7e8d486b872cde |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFODVDOjEzQkRCRDoxQzY4OToyNTEzNTo2QUY5QkFDMCIsInZpc2l0b3JfaWQiOiIzMDU5OTgwNDYxNDkzODI4Mjg4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | a2bf55cddb8fad2cd23e2333a95d695dafb32a4e3b8ac965fd227adbce43db18 |
| hovercard-subject-tag | issue:5633587324 |
| 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/2596/issue_layout |
| twitter:image | https://opengraph.githubassets.com/96682b846b6ed610b86932f95b804da17fa0abae88f5f8a9472ae11caa4ff86a/oapi-codegen/oapi-codegen/issues/2596 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/96682b846b6ed610b86932f95b804da17fa0abae88f5f8a9472ae11caa4ff86a/oapi-codegen/oapi-codegen/issues/2596 |
| og:image:alt | I have a simple oas3 file v3.1.0 with both const and regular objects. Here is my config cfg-schemas.yaml: package: api generate: models: true output: go/api/schemas.go output-options: skip-prune: t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | deitch |
| 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