Skip to content

Fix missed response schema cases, add backup_name#47

Open
wazawoo wants to merge 16 commits into
denislituev:masterfrom
wazawoo:master
Open

Fix missed response schema cases, add backup_name#47
wazawoo wants to merge 16 commits into
denislituev:masterfrom
wazawoo:master

Conversation

@wazawoo

@wazawoo wazawoo commented Feb 27, 2026

Copy link
Copy Markdown

I ran the cli on an API spec and it didn't generate anything. This spec had responses but no request bodies or other schemas. Also, the operations didn't have operation_ids.

I still wanted to generate models from these, so I made a couple changes:

  • Fix models from inline responses not getting added to inline_models
  • Add backup_name to uniquely specify operations with no operation_id

I can add tests and/or split into different PRs, but first I wanted to see of you were interested in either of these changes.

@denislituev

Copy link
Copy Markdown
Owner

Hello @wazawoo. Thank you for your contribution, I will check this PR.

I’d like to clarify the “it didn’t generate anything” part.
Even if the spec only contains inline response schemas and no request bodies or operation_ids, the generator should still produce models from response schemas.

If literally no output was generated, that would indicate a bug.

No need to split this for now.
I’ll review the changes and test them first.

@wazawoo

wazawoo commented Feb 28, 2026

Copy link
Copy Markdown
Author

@denislituev sounds good, thanks!

I added a test that I believe would fail before this PR (because the inline responses weren't added to inline_models)

@wazawoo

wazawoo commented Mar 2, 2026

Copy link
Copy Markdown
Author

I also noticed that objects in arrays in responses are not parsed. Started looking into it.

For example:

{
    "paths": {
        "example_path": {
            "get": {
                "summary": "...",
                "responses": {
                    "200": {
                        "description": "...",
                        "headers": {},
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": {
                                        "type": "object",
                                        "properties": {
                                            "exampleField": {
                                                "type": "string"
                                            },
                                            "anotherExampleField": {
                                                "type": "string"
                                            }
                                        }
                                    }
                                },
                                "example": []
                            }
                        }
                    }
                },
                "tags": [],
                "description": "..."
            },
            "parameters": []
        }
    }
}

@wazawoo

wazawoo commented Mar 5, 2026

Copy link
Copy Markdown
Author

Added more tests and fixed formatting issues. I don't love the long and verbose names I've given for the response objects.

I have one more case that's broken with the spec im using as input: A response object, with a parameter with an array of objects.

{
...
 "schema": {
    "type": "object",
    "properties": {
        "exampleProperty": {
            "type": "string"
        },
        "objectArray": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "propA": {
                        "type": "string"
                    },
                    "propB": {
                        "type": "string"
                    }
                }
            }
        }
    }
},
...
}

I think in general something might be missing with handling nested objects and arrays of objects. Not sure I'm approaching the fix in the cleanest way though.

@wazawoo wazawoo changed the title [DRAFT] Fix missed inline responses, add backup_name Fix missed response schema cases, add backup_name Mar 5, 2026
@wazawoo wazawoo marked this pull request as ready for review March 5, 2026 23:32
Comment thread src/parser.rs Outdated
if let ReferenceOr::Item(response) = response_ref {
for (content_type, media_type) in &response.content {
if let Some(schema) = &media_type.schema {
let operation_name =

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Minor suggestion: The operation_name logic is duplicated on lines 191 and 232. Consider extracting it to the top of process_operation to avoid repetition.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks! Resolved here: 5bf7ccd

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