Created by: bodograumann
Fixes #3602 (closed):
When enabling generateAliasAsModel
, schemes which are aliases for maps or arrays are generated as models by all templates. Those models where previously not imported and used for the relevant body parameters though.
I have not added any tests, but for my own use case the change works and the one sample where the generateAliasAsModel
option is activated also shows the change in effect.
Example
Considering the following OpenAPI definition.
openapi: 3.0.2
info:
title: Map Alias Example
version: 0.1.0
description: Use a data scheme which is only an alias for a map.
paths:
'/users/{userId}/roles':
patch:
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/UserRoleUpdateRequest'
required: true
parameters:
-
name: userId
schema:
type: string
in: path
required: true
responses:
'200':
description: Update successfull.
operationId: updateUserRoles
components:
schemas:
UserRoleUpdateRequest:
type: object
additionalProperties:
type: boolean
example:
admin: true
user: false
Usually it would generate typescript-inversify code:
public updateUserRoles(
userId: string,
requestBody: { [key: string]: boolean },
observe?: "body",
headers?: Headers
): Promise<any>;
Instead it should generate:
public updateUserRoles(
userId: string,
userRoleUpdateRequest: UserRoleUpdateRequest,
observe?: "body",
headers?: Headers
): Promise<any>;