Repository navigation
Conversation
812350e to
6b3be3c
Compare
54b5933 to
bd1e279
Compare
d5fbcf9 to
122744e
Compare
5ae3297 to
aa10b45
Compare
There was a problem hiding this comment.
Pull Request Overview
Adds a new ParseObject function to automatically convert Go types into OpenAPI schemas, updates documentation, and applies minor formatting in component validation.
- Introduce
ParseObject,parseObject, andapplyTaginparser.goto handle structs, pointers, maps, slices, primitives, and tags. - Document the new feature in
README.md. - Insert a blank line in
components.gofor consistent formatting.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| parser.go | Implement parsing logic to generate OpenAPI SchemaBuilder from Go types and tags. |
| components.go | Add blank line in validateSpec for readability. |
| README.md | Document ParseObject feature and supported tags. |
Comments suppressed due to low confidence (3)
README.md:31
- [nitpick] The README refers to
SchemaBuilder, but the code type appears asSchemaBulder; ensure naming is consistent between documentation and code.
* Added `ParseObject` function to create `SchemaBuilder` by parsing an object.
parser.go:34
- Consider adding unit tests for
ParseObject, covering various Go types (structs with tags, pointers, maps, slices, primitives) to verify correct schema generation and prevent regressions.
func ParseObject(obj any, components *Extendable[Components]) (*SchemaBulder, error) {
parser.go:209
- The arguments to
strings.HasPrefixare reversed; it should bestrings.HasPrefix(parts[0], "ref:")to correctly detect thereftag.
if strings.HasPrefix("ref:", parts[0]) {
9813279 to
fdeadc3
Compare
There was a problem hiding this comment.
Pull Request Overview
Introduce a new ParseObject function that converts Go types into OpenAPI schemas with full support for structs, pointers, maps, slices, primitives, and customizable tags.
- Add
ParseObjectand related helpers inparser.goto traverse Go types and build schema definitions. - Reserve and reference struct schemas in
components.Spec.Schemasto avoid circular references. - Update
README.mdto document the newParseObjectfunction. - Minor formatting adjustment in
components.go.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| parser.go | Implements ParseObject, parseObject, and tag handling to generate SchemaBuilder instances. |
| components.go | Added a blank line in validateSpec for formatting consistency. |
| README.md | Documented the usage of the new ParseObject function. |
Comments suppressed due to low confidence (1)
parser.go:47
- [nitpick] Consider adding unit tests for
ParseObjectto verify struct, pointer, map, slice parsing and various tag combinations.
func ParseObject(obj any, components *Extendable[Components], opts ...ParseOption) (*SchemaBulder, error) {
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new ParseObject function to automatically generate OpenAPI schema representations from Go types while also refactoring the SchemaBuilder naming throughout the codebase.
- Renamed SchemaBulder → SchemaBuilder in schema.go and related files.
- Added ParseObject functionality in parser.go to support automatic schema generation.
- Updated documentation and minor formatting changes in components.go, bool_or_schema.go, and README.md.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| schema.go | Renamed SchemaBulder to SchemaBuilder for consistency. |
| parser.go | Added ParseObject with logic to parse various Go types. |
| components.go | Minor formatting update. |
| bool_or_schema.go | Updated reference from SchemaBulder to SchemaBuilder. |
| README.md | Documentation updated to reflect the new ParseObject. |
Comments suppressed due to low confidence (1)
parser.go:248
- [nitpick] The early return on detecting a '-' tag in applyTag could be clarified with an inline comment detailing that the '-' indicates the field should be skipped. This would improve code readability for future maintainers.
if name == "-" { return parts[0] }
Introduce ParseObject function to parse Go types into OpenAPI schema representations, supporting structs, pointers, maps, slices, and primitives. Handle tags for customizing schema fields, references, and metadata. This enables automatic schema generation from Go types, improving integration with OpenAPI components and reducing manual schema definitions.
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a ParseObject function for converting Go types into OpenAPI schemas and renames/fixes the schema builder type.
- Rename
SchemaBuldertoSchemaBuilderand update all its methods. - Add
parser.gowithParseObjectlogic for structs, pointers, maps, slices, and primitives. - Update
bool_or_schema.goandREADME.mdto reflect the new builder and parsing feature.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| schema.go | Renamed SchemaBulder to SchemaBuilder and updated all builder methods to match. |
| parser.go | Added ParseObject (and helper parseObject) to generate schemas from Go types. |
| bool_or_schema.go | Updated NewBoolOrSchema case to accept *SchemaBuilder. |
| README.md | Documented the new ParseObject function in feature list. |
Comments suppressed due to low confidence (1)
parser.go:48
- Add unit tests for ParseObject covering structs, slices, maps, pointers, and primitives to ensure schema generation behaves as expected.
func ParseObject(obj any, components *Extendable[Components], opts ...ParseOption) (*SchemaBuilder, error) {
Introduce ParseObject function to parse Go types into OpenAPI schema
representations, supporting structs, pointers, maps, slices, and primitives.
Handle tags for customizing schema fields, references, and metadata. This
enables automatic schema generation from Go types, improving integration
with OpenAPI components and reducing manual schema definitions.