Search code examples
elmopenapi-generator-cli

Using two different modules with the same name in elm


I use openapi-generator-cli to generate the elm code for REST apis that are described using OpenAPI.

Basically that worked well for me so far. But now I have to problem, that I want to access two microservices that are described in individual OpenAPI documents. The problem is, that openapi-generator generates an Api and Api.Data module for every REST API it generates interfaces for. I already checked the templates in openapi-generator, but these module names are fixed and cannot be changed.

So I wonder: is it possible somehow to use two packages in an elm project, that contain modules with the same names? Any other idea how I can use two separate APIs in one elm project?


Solution

  • You will need to rename the modules of one of the generated projects. I would recommend automating this renaming.

    This project solves a similar problem, so perhaps it can be useful inspiration.

    It might be easiest to just fork the generator and add an option for a module prefix (and potentially contribute it back, as it seems like a generally useful option; elm-graphql already has this).