orval-labs/orval

MSW: Incorrect Import Generated for Enum in Mock Files

Closed this issue · 2 comments

Description:
There is an issue with generating correct imports for enums in the MSW (Mock Service Worker) files. The problem occurs when processing the following enum in the Swagger specification:

"Domain.Status.Enum": {
  "enum": [
    "Foo",
    "Bar"
  ],
  "type": "string"
}

Current Behavior:

The generated import in the mock file looks like this:

import { Domain.Status.Enum } from '.././model';

Expected Behavior:

The import should follow the correct naming convention:

import { DomainStatusEnum } from '.././model';

Suspected Cause:

This issue might be related to a previously fixed issue in PR #1456 (fix(msw): correctly add imports for enum references), which addressed a similar problem with enum imports. It is possible that the current bug is a variation or an edge case that wasn't covered by that fix.

Steps to Reproduce:

  1. Use the given Swagger spec that contains the Domain.Status.Enum.
  2. Generate the mocks (MSW) from the Swagger file.
  3. Check the generated imports in the MSW files.

Environment:

  • Version: 7.1.0

Additional Information:

Any guidance or fixes would be appreciated, and I'm happy to provide more details if necessary.

PR is welcome! @dteske25 can you check this out this report claims you may have broken something.

Sorry for the slow reply - I will take a look later tonight!