Skip to content

Don't prepend title based property names, use Titles for full model type names #559

Closed
@rtaycher

Description

@rtaycher

Is your feature request related to a problem? Please describe.
Ideally an openapi description would get us nice not too long types without a lot of futzing with overriding type names via class_overrides.

If you add a title/subtitle to an objects body it seems to append it to the path based name making names very long and often redundant
and you have to fix it via class_overrides (or if you control the openapi description by moving everything into components which dont cause long names)

An example to clarify

paths:
  /bob:
    get:
      operationId: get_bob_method
      requestBody:
        content: 
          application/json:
            schema:
              title: Get Bob Body
              type: object
              properties:
                ArrayProp:
                  type: array
                  items:
                    title: Bob Body Item
                    type: object
                    properties:
                      MyProp:
                        type: string
      responses:
        200:
          description: "Response"
          content:
            application/json:
              schema:
                title: The Robert Report
                type: object
                properties:
                  ArrayProp:
                    type: array
                    items:
                      title: Robert Response Item
                      type: object
                      properties:
                        MyPropR:
                          type: string       

results in GetBobMethodGetBobBody / GetBobMethodGetBobBodyBobBodyItem for the json_body and
GetBobMethodTheRobertReport / GetBobMethodTheRobertReportRobertResponseItem for the response type instead of GetBobBody, BobBodyItem, and TheRobertReport/RobertResponseItem

Trying out the alternative openapi-generator-cli it returns GetBobBody, BobBodyItem, and TheRobertReport/RobertResponseItem.

While this is not mandated anywhere I think its much more sensible.

Usually with a title you will have named the full type/subtype and not need to prepend it with the method name/outer type.

Describe the solution you'd like
We should keep appending to a name when using default property names/item but start from scratch every time we hit a title.

Currently the only way to fix things is to rename via class_overrides or if you have control of the openapi description move everything into components(since types from component only use the component name and not the full path name)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions