Skip to content

feat(openapi): Allow setting info extensions in OApi specifications#1158

Merged
attila-lin merged 4 commits intopoem-web:masterfrom
amtelekom:openapi-info-extensions
Feb 26, 2026
Merged

feat(openapi): Allow setting info extensions in OApi specifications#1158
attila-lin merged 4 commits intopoem-web:masterfrom
amtelekom:openapi-info-extensions

Conversation

@amtelekom
Copy link
Contributor

@amtelekom amtelekom commented Jan 25, 2026

The OpenAPI Info object may be extended with additional fields, e.g. from the OApi 3.0.3 Spec:

4.7.2 Info Object

[...]
This object MAY be extended with Specification Extensions

This PR allows setting such extensions via poem-openapi:

use serde_json::Value as JsonVal;

OpenApiService::new(...)
    // other settings
    .info_extension("x-category", JsonVal::String("Example".to_string()))
    .info_extension("x-segment", JsonVal::Array(vec![
        JsonVal::String("B2B".to_string()),
        JsonVal::String("B2C".to_string())]));

results in the extensions being added in the JSON and YAML spec endpoints:

{
  "openapi": "3.0.0",
  "info": {
    // ...
    "x-category": "Example",
    "x-segment": [
      "B2B",
      "B2C"
    ]
  }
  // ...
}
openapi: 3.0.0
info:
  #...
  x-category: Example
  x-segment:
  - B2B
  - B2C
# ...

I guess this implements at least a small part #908

@attila-lin
Copy link
Collaborator

would you mind add some test case? thank you!

@amtelekom
Copy link
Contributor Author

Hi,

sorry, I was busy the last few days, but I've now added a test case that checks the extensions are correctly encoded into the spec

@attila-lin attila-lin merged commit 12db6a1 into poem-web:master Feb 26, 2026
10 checks passed
@attila-lin
Copy link
Collaborator

LGTM
Thank you.

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