Open sh4nks opened 1 year ago
@sh4nks could you please provide complete plugin configuration from pom.xml, that you are using?
@sh4nks could you please provide complete plugin configuration from pom.xml, that you are using?
Sure:
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<configuration>
<schemaMappings>
Test=my.external.test.package.model.Test,
TestToSave=my.external.test.package.model.TestToSave
</schemaMappings>
<verbose>false</verbose>
<configOptions>
<providedIn>root</providedIn>
<enumPropertyNaming>UPPERCASE</enumPropertyNaming>
<enforceGenericModuleWithProviders>true</enforceGenericModuleWithProviders>
</configOptions>
</configuration>
</plugin>
btw, the same problem exists when using the typescript-angular generator - the GET methods are being generated just fine and the POST methods body has the any
type instead of the TestToSave
type.
when adding a property it kinda works but doesn't feel right:
TestToSave:
description: "external TestToSave object"
properties:
none:
type: string
void saveTest(@NotNull @Valid my.external.test.package.model.TestToSave myExternalTestPackageModelTestToSave) throws TestUiException;
I am experiencing a similar issue when using the typescript-angular generator. For example, in my model definition I have the following two components:
components:
schema:
CombinedTest:
description: "combined Test + TestToSave"
type: object
properties:
belongsHere:
type: string
tests:
type: array
items:
$ref: "#/components/schemas/Test"
testsToSave:
type: array
items:
$ref: "#/components/schemas/TestToSave"
Test:
description: "external Test object"
TestToSave:
description: "external TestToSave object"
properties:
dummyproperty:
type: string
will be generated into:
import { Test } from '@my/test_package/lib/gen/model/test';
import { TestToSave } from '@my/test_package/lib/gen/model/testToSave';
export interface Zusammenfassung {
belongsHere?: string;
tests?: Array<any>; // should be Array<Test>
testsToSave?: Array<TestToSave>; // is OK
}
the maven configuration:
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<configuration>
<schemaMappings>
Test=@my/test_package/lib/gen/model/test,
TestToSave=@my/test_package/lib/gen/model/testToSave
</schemaMappings>
<importMappings>
Test=@my/test_package/lib/gen/model/test,
TestToSave=@my/test_package/lib/gen/model/testToSave
</importMappings>
<verbose>true</verbose>
<configOptions>
<enumPropertyNaming>UPPERCASE</enumPropertyNaming>
</configOptions>
</configuration>
</plugin>
Getting the same issue while trying to define the requestBody schema as array. Any advises to workaround the behaviour?
@vicmosin I have worked around the issue by adding a "dummy" property:
TestToSave:
description: "external TestToSave object"
properties:
dummyproperty: # <-- this here
type: string
After adding this, the schema is correctly mapped...
Same issue here with Spring WebFlux generator.
I have a mapping from MyType to MyExternalType
I have a simple type like this
MyType:
type: string
description: My type
maxLength: 200
pattern: |-
[A-zÀ-ú0-9_\-/:%'@]*
I am mapping it to a custom external class but the generator generates Mono
However, when this type is used somewhere else than in request body, it works perfectly.
Hey!
Bug Report Checklist
Description
I can't get the schemaMapping to work with a POST request where I reference a object from an external package via schemaMapping. It works flawlessly for returning objects though. See my provided examples.
openapi-generator version
6.2.1
OpenAPI declaration file content or url
Generation Details
My schemaMappings maven configuration:
As you can see the
saveTest(@NotNull Object body)
method isn't correctly mapped tomy.external.test.package.api.model.TestToSave
, even though I have set it in the schema mappings. The weird thing is, that the schema mapping works correctly with theloadTest()
method.Thanks!