Skip to content

Add support for ffschemaext#208

Merged
peterbroadhurst merged 5 commits intohyperledger:mainfrom
chrisbygrave:ff-openapi-extensions
Mar 4, 2026
Merged

Add support for ffschemaext#208
peterbroadhurst merged 5 commits intohyperledger:mainfrom
chrisbygrave:ff-openapi-extensions

Conversation

@chrisbygrave
Copy link
Contributor

@chrisbygrave chrisbygrave commented Feb 17, 2026

This PR adds support for a gostruct tag ffschemaext that allows a comma-separated list of key/value pairs to be added as extensions to the schema generated into the OpenAPI document. Keys must be of the format x-<name>.

For example, the following structure:

type TestExtensions struct {
	MyString string `ffstruct:"mystruct" json:"mystring" ffschemaext:"x-key=value"`
}

Would generate a schema:

mystring:
  description: mystruct.mystring
  type: string
  x-key: value

Query string syntax (and escaping rules) can be used to add multiple extension to a single field:

type TestExtensions struct {
	MyString string `ffstruct:"mystruct" json:"mystring" ffschemaext:"x-key=value&x-key2=value2"`
}

- a go struct tag that enables extensions to be introduced to the generated OpenAPI documents

Signed-off-by: Chris Bygrave <chris.bygrave@kaleido.io>
@chrisbygrave chrisbygrave requested a review from a team as a code owner February 17, 2026 15:22
Copy link
Contributor

@EnriqueL8 EnriqueL8 left a comment

Choose a reason for hiding this comment

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

Looks good - a question and needs gofmt formatting

chrisbygrave and others added 2 commits February 17, 2026 16:49
Co-authored-by: Enrique Lacal <enrique.lacal@kaleido.io>
Signed-off-by: Chris Bygrave <chris.bygrave@kaleido.io>
Signed-off-by: Chris Bygrave <chris.bygrave@kaleido.io>
Copy link
Contributor

@EnriqueL8 EnriqueL8 left a comment

Choose a reason for hiding this comment

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

Looks good to me @chrisbygrave - thanks!

Copy link
Contributor

@peterbroadhurst peterbroadhurst left a comment

Choose a reason for hiding this comment

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

Couple of thoughts here @chrisbygrave

- ffextensions -> ffschemaext
- use query-like format with well-defined escaping strategy

Signed-off-by: Chris Bygrave <chris.bygrave@kaleido.io>
@chrisbygrave
Copy link
Contributor Author

Thanks for the steer @peterbroadhurst - I've updated the PR to support query syntax parsing, and added a couple of tests to catch encoding issues.

I've also switched out ffextensions for ffschemaext - it does indeed feel clearer.

Signed-off-by: Chris Bygrave <chris.bygrave@kaleido.io>
@chrisbygrave
Copy link
Contributor Author

Worth noting that if the same property is specified multiple times, the last value will win - I think that's cleaner behaviour than introducing some arbitrary join character in an attempt to consolidate multiple values down to one.

Copy link
Contributor

@peterbroadhurst peterbroadhurst left a comment

Choose a reason for hiding this comment

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

Thanks @chrisbygrave for going round the loop on the spelling and escaping semantics

@peterbroadhurst peterbroadhurst merged commit 10dbe1a into hyperledger:main Mar 4, 2026
5 checks passed
@peterbroadhurst peterbroadhurst changed the title Add support for ffextensions Add support for ffschemaext Mar 4, 2026
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.

3 participants