Skip to content

Conversation

BlakeTheAwesome
Copy link

@BlakeTheAwesome BlakeTheAwesome commented Sep 26, 2025

WIP

TODO:

  • Update openapi.Walk API to ensure it walks through new additionalOperations (and any other new nodes added)
  • For additionalOperations: update inlining/bundling test with so additionalOperations examples that include references and ensure they get bundled,inlined as expect.
  • Support new Tags structure and properties (including enum of currently known kinds in registry)
  • Support new Enhanced parameter handling including in: querystring location and relevant validation
  • Support new itemSchema field in mediaType and relevant validation and support in other APIs/methods
  • Support itemEncoding & prefixEncoding fields in mediaType and relevant validation and support in other APIs/methods
  • Support new oauth2MetadataUrl and deprecated fields in security schema object and relevant validation
  • Support defaultMapping field in discriminator and relevant validation
  • Support dataValue, serializedValue, and new deprecation of value and the relevant validation
  • Support name field in server object
  • Support $self field in OpenAPI object and the relevant validation and update reference resolution to use this as the target location when present instead of parents locaiton

@BlakeTheAwesome BlakeTheAwesome requested a review from a team as a code owner September 26, 2025 06:15
@TristanSpeakEasy TristanSpeakEasy self-requested a review September 29, 2025 00:27
Major int
Minor int
Patch int
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}
var _ fmt.Stringer = (*Version)(nil)

this just adds a compile time check that you implement the Stringer interface correctly with your String() method

return &PathItem{
Map: *sequencedmap.New[string, *Operation](),
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add whitespace

Suggested change
}
}

Comment on lines +22 to +30
- name: "admin"
summary: "Admin"
description: "Administrative operations"
parent: "users"
kind: "nav"
- name: "beta-features"
summary: "Beta"
description: "Experimental features"
kind: "badge"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably don't want to add these, as a bootstrapped document is meant to be less example and more a starting point for a real document. Adding the summary and kind to the users tag is good but I would avoid adding more tags for now (especially if they aren't being used).

assert.Equal(t, string(expectedBytes), string(actualYAML), "Bundled document should match expected output")
}

func TestBundle_AdditionalOperations_Success(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if possible I would try and add the additionalOperations test in to the original test above and update the expected doc etc, to make sure everything is working together.

Generally also with tests like this its better to be asserting the exact shape of the document like we do in the test above rather than all the assertions you have below to catch where we might be introducing unintended changes etc, but that is just another reason to integrate it into the test above (which will then also mean we have the inline tests also testing it)

assert.Equal(t, string(expectedBytes), string(actualYAML), "Inlined document should match expected output")
}

func TestInline_AdditionalOperations_Success(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments as the bundle test


o := validation.NewOptions(opts...)

openapi := validation.GetContextObject[OpenAPI](o)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was actually thinking we could maybe be a bit less strict about needing the OpenAPI object to be passed in here. Instead of panic we can just assume when we don't receive the OpenAPI we are working with a document of the latest version.

Was thinking through our future use cases for a linter and more robust validation in the future and we will prob want to double down on support people being able to call the Validate methods on each object manually even when they don't have a full document object yet.


// ValidateWithTags validates the Tag object in the context of all tags to check for parent relationships.
// This should be called during document-level validation where all tags are available.
func (t *Tag) ValidateWithTags(ctx context.Context, allTags []*Tag, opts ...validation.Option) []error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of having a different Validate function we probably want to take the OpenAPI object like we did in the paths Validate function and get the list of tags from that and then validate the tag against that list. Thoughts? We haven't really yet introduce alternate Validate funcs because they then won't be called automatically when you call Validate on the document.

// TagKind represents commonly used values for the Tag.Kind field.
// These values are registered in the OpenAPI Initiative's Tag Kind Registry
// at https://spec.openapis.org/registry/tag-kind/
type TagKind string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type TagKind string
type TagKind string
var _ fmt.Stringer = (*TagKind)(nil)

}
}

func WithUpgradeTargetVersion(version string) Option[UpgradeOptions] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one thing we will need to be aware of and probably proactive about, is that having this be optional will be a breaking change to Gram in that when it upgrades docs it will no longer just upgrade to 3.1.1 but all the way to 3.2.0 which may not yet be supported by MCP/AI yet.

So we just need to make sure once this is released we go and update Gram with the new version (before that team does) and make sure the Upgrade call uses this and set the version to 3.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants