GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — JSON Schema const on direct schema properties is silently ignored · Issue #4 · oapi-codegen/oapi-codegen-exp Open DescriptionWhen a schema property uses the JSON Schema
This affects any OpenAPI 3.1+ spec. The reproducing example below uses 3.2 but the behaviour is identical with Reproducing Specopenapi: "3.2.0" components: schemas: ResourceNotFound: type: object required: [type, title, status] properties: type: type: string const: https://example.com/errors/resource-not-found title: type: string const: Resource Not Found status: type: integer const: 404 What is currently generatedtype ResourceNotFound struct { Type string `json:"type"` Title string `json:"title"` Status int `json:"status"` } The What should be generatedAt minimum, the constant values should be preserved as named Go constants and the fields should be initialised via something like const ( ResourceNotFoundType = "https://example.com/errors/resource-not-found" ResourceNotFoundTitle = "Resource Not Found" ResourceNotFoundStatus = 404 ) type ResourceNotFound struct { Type string `json:"type"` Title string `json:"title"` Status int `json:"status"` } func (s *ResourceNotFound) ApplyDefaults() { s.Type = ResourceNotFoundType s.Title = ResourceNotFoundTitle s.Status = ResourceNotFoundStatus } I have a rough idea about a fix for this and up for attempting if you are accepting contributions? Reacted by Jeremy Wharton ActivityMetadataMetadataAssigneesLabelsNo labels TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |