Skip to content

fix(asyncapi): promote nested pydantic to components/schemas - #2445

Merged
Lancetnik merged 2 commits into
ag2ai:mainfrom
legau:main
Aug 13, 2025
Merged

fix(asyncapi): promote nested pydantic to components/schemas#2445
Lancetnik merged 2 commits into
ag2ai:mainfrom
legau:main

Conversation

@legau

@legau legau commented Aug 12, 2025

Copy link
Copy Markdown
Contributor

Description

Promote nested Pydantic model definitions from message payloads (including oneOf cases) into components/schemas and replace inline schemas with $ref references. This resolves incorrect “inplace” embedding of nested models in generated AsyncAPI 3.0 documents.

Not sure if it is a good implementation, however tests are passing

Fixes #2443

Type of change

  • Bug fix (a non-breaking change that resolves an issue)

Checklist

  • My code adheres to the style guidelines of this project (just lint shows no errors)
  • I have conducted a self-review of my own code
  • I have made the necessary changes to the documentation
  • My changes do not generate any new warnings
  • I have added tests to validate the effectiveness of my fix or the functionality of my new feature
  • Both new and existing unit tests pass successfully on my local environment by running just test-coverage
  • I have ensured that static analysis tests are passing by running just static-analysis
  • I have included code examples to illustrate the modifications

@legau
legau requested a review from Lancetnik as a code owner August 12, 2025 16:20
@CLAassistant

CLAassistant commented Aug 12, 2025

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Comment thread tests/asyncapi/base/v3_0_0/publisher.py Outdated

assert schema["channels"] == {}, schema["channels"]

def test_nested_models_in_one_of_should_be_in_schemas(self) -> None:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The current problem is not publisher-specific. As well it is not specific for 3.0.0 AsyncAPI version

It should exists for subscribers as well for (or with descriminator probably)

@subscibrer
async def handler(body: Model1 | Model2): ... 

So, can you please add tests and fix for 3.0.0 and 2.6.0 versions both? And place them somewhere near test_pydantic_model_mixed_regular. Alse, please add a link to the original Issue as a test docstring

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This should be good

@Lancetnik
Lancetnik added this pull request to the merge queue Aug 13, 2025
Merged via the queue into ag2ai:main with commit bc6b1c0 Aug 13, 2025
28 of 29 checks passed
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.

bug: Nested Pydantic model are not included in AsyncAPI components/schemas (inplaced instead)

3 participants