[BUG][Default][Java][Spring][Typescript-Angular][...?] Different behavior resolving Enum schema referred from sub directories between Linux and Windows generator
Bug Report Checklist
- [x] Have you provided a full/minimal spec to reproduce the issue?
- [x] Have you validated the input using an OpenAPI validator (example)? impossible due $refs, but generator generates OK
- [ ] Have you tested with the latest master to confirm the issue still exists?
- [x] Have you searched for related issues/PRs?
- [x] What's the actual output vs expected output?
Description
Enum schemas are generated with additional Prefix which comes from subdirectory name, if object is referred from different files.
openapi-generator version
7.0.0 - 7.3.0 (+ older probably)
OpenAPI declaration file content or url
./api.yaml
openapi: 3.0.3
info:
title: Example of issue with resolving enum names between Windows and Linux generation
description: potato
version: 1.0.0
paths:
/hello-world:
get:
summary: whatever
operationId: whateverGet
responses:
'200':
description: ok
content:
application/json:
schema:
$ref: '#/components/schemas/ResponseModel'
components:
schemas:
ResponseModel:
properties:
someEnumField:
$ref: './shared/shared.yaml#/components/schemas/SomeEnum'
./schemas/some-enum.yaml
type: string
enum:
- one
- two
./shared/shared.yaml
title: shared models between apis
components:
schemas:
SomeEnum:
$ref: '../schemas/some-enum.yaml'
Generation Details
Issue looks global - happens on Spring Server stubs generation, Java Client, TypeScript Angular client... I've didn't tested other generators. This ticket only shows example from spring generator.
Also I've spent multiple hours to find similar issue or reason from generator codebase. My assumption and guess is that there's difference sanitizing symbol name because of different path separator in OSes.
Generator output (command below). Left Windows 10, right Debian

File difference

Yaml file regenerated from source (src/resources/openapi.yaml)

Log differences (nothing important here imho)

Issue also appears using maven plugin.
Steps to reproduce
- Recreate those three yaml files like in section above
- Run on Windows (command from git-bash, doesn't matter):
➜ ./jdk-21.0.2/bin/java -jar /Tools/openapi/openapi-generator-cli-7.3.0.jar generate -i api.yaml -g spring
Related issues/PRs
Didn't found.
Suggest a fix
Align behavior in Windows to Linux output.