refactor: optimize JSON parsing for core types#321
refactor: optimize JSON parsing for core types#321nahapetyan-serob wants to merge 3 commits intomainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors JSON marshaling and unmarshaling logic for several types, including SecurityRequirementsOptions, NamedSecuritySchemes, OAuth2SecurityScheme, StreamResponse, and Part. The changes replace anonymous types and generic maps with dedicated private wrapper structs to improve type safety and simplify validation. Feedback was provided regarding Part.UnmarshalJSON, noting that it should validate that exactly one content field is present to prevent potential nil interface assignments and ensure adherence to API specifications.
| type oauth2 struct { | ||
| Description string `json:"description,omitempty"` | ||
| Oauth2MetadataURL string `json:"oauth2MetadataUrl,omitempty"` | ||
| Flows oauthFlows `json:"flows"` |
There was a problem hiding this comment.
have we deliberately removed omitempty?
There was a problem hiding this comment.
yes, flows is a required filed in OAuth2SecurityScheme, so I kept the same for the wrapper as well.
Refactor custom JSON marshal/unmarshal logic across core.go and auth.go to use typed wrapper structs instead of type discriminator patterns.
Behavioral Change: Empty URLs are now skipped during part serialization instead of being serialized as empty strings.