Forum Discussion

Bhushan-Chandra's avatar
Bhushan-Chandra
Occasional Contributor
2 months ago

How to refer to models from different packages in auto generated class? Like Pageable

How to refer to models from different packages in same method in auto generated controller? Like "getAllProducts" uses "Pageable" from "org.springframework.data.domain.Pageable" and "Product from "com.pepsico.och.inventory.domain.product.Product" package.

1 Reply

  • brandonsherrick's avatar
    brandonsherrick
    Occasional Visitor

    Hello there,

    In your Swagger annotations, explicitly reference the fully qualified class names of the models you need to use. 

    Here, Pageable and Product are imported directly from their respective packages (org.springframework.data.domain and com.pepsico.och.inventory.domain.product).

    Ensure that Swagger annotations like @ApiParam or @ApiResponse use the fully qualified class names in their definitions.

    When using Swagger Codegen to generate client or server code, ensure your Swagger specification (swagger.yaml or swagger.json) correctly defines models and references them. You can use $ref to refer to models defined elsewhere in your Swagger definition file.