diff --git a/src/helpers/CommonModelToMetaModel.ts b/src/helpers/CommonModelToMetaModel.ts index 235aa351ce..6e4118d6e4 100644 --- a/src/helpers/CommonModelToMetaModel.ts +++ b/src/helpers/CommonModelToMetaModel.ts @@ -359,9 +359,19 @@ export function convertToAnyModel( if (!Array.isArray(jsonSchemaModel.type) || !isAnyType) { return undefined; } + let originalInput = jsonSchemaModel.originalInput; + if (typeof jsonSchemaModel.originalInput !== 'object') { + originalInput = { + value: jsonSchemaModel.originalInput, + ...(jsonSchemaModel.originalInput?.description !== undefined && { + description: jsonSchemaModel.originalInput.description + }) + }; + } + return new AnyModel( name, - jsonSchemaModel.originalInput, + originalInput, getMetaModelOptions(jsonSchemaModel, options) ); } @@ -519,9 +529,17 @@ export function convertToDictionaryModel( getOriginalInputFromAdditionalAndPatterns(jsonSchemaModel); const keyModel = new StringModel(name, originalInput, {}); const valueModel = convertAdditionalAndPatterns(context); + + const input = { + originalInput, + ...(jsonSchemaModel.originalInput?.description !== undefined && { + description: jsonSchemaModel.originalInput.description + }) + }; + return new DictionaryModel( name, - originalInput, + input, getMetaModelOptions(jsonSchemaModel, options), keyModel, valueModel, diff --git a/test/generators/go/presets/DescriptionPreset.spec.ts b/test/generators/go/presets/DescriptionPreset.spec.ts index a3eedfc674..dc96d7fa36 100644 --- a/test/generators/go/presets/DescriptionPreset.spec.ts +++ b/test/generators/go/presets/DescriptionPreset.spec.ts @@ -17,6 +17,12 @@ const doc = { additionalProperties: false, $id: 'NestedTest', properties: { stringProp: { type: 'string', description: 'string prop' } } + }, + anyProp: { + type: 'object', + $id: 'AnyTest', + properties: {}, + description: 'AnyTest description' } } }; diff --git a/test/generators/go/presets/__snapshots__/DescriptionPreset.spec.ts.snap b/test/generators/go/presets/__snapshots__/DescriptionPreset.spec.ts.snap index fcfee51a1c..c81b525b55 100644 --- a/test/generators/go/presets/__snapshots__/DescriptionPreset.spec.ts.snap +++ b/test/generators/go/presets/__snapshots__/DescriptionPreset.spec.ts.snap @@ -7,6 +7,8 @@ type Test struct { // Description NumberProp float64 ObjectProp *NestedTest + // AnyTest description + AnyProp map[string]interface{} }" `; diff --git a/test/generators/java/presets/DescriptionPreset.spec.ts b/test/generators/java/presets/DescriptionPreset.spec.ts index 4c86c30ad5..de3674ec7c 100644 --- a/test/generators/java/presets/DescriptionPreset.spec.ts +++ b/test/generators/java/presets/DescriptionPreset.spec.ts @@ -20,6 +20,12 @@ describe('JAVA_DESCRIPTION_PRESET', () => { type: 'string', description: 'Description for prop', examples: ['exampleValue'] + }, + anyProp: { + type: 'object', + $id: 'AnyTest', + properties: {}, + description: 'AnyTest description' } } }; diff --git a/test/generators/java/presets/__snapshots__/DescriptionPreset.spec.ts.snap b/test/generators/java/presets/__snapshots__/DescriptionPreset.spec.ts.snap index 9d39a26e70..eb2042c09d 100644 --- a/test/generators/java/presets/__snapshots__/DescriptionPreset.spec.ts.snap +++ b/test/generators/java/presets/__snapshots__/DescriptionPreset.spec.ts.snap @@ -66,6 +66,7 @@ exports[`JAVA_DESCRIPTION_PRESET should render description and examples for clas */ public class Clazz { private String prop; + private Map anyProp; private Map additionalProperties; /** @@ -75,6 +76,12 @@ public class Clazz { public String getProp() { return this.prop; } public void setProp(String prop) { this.prop = prop; } + /** + * AnyTest description + */ + public Map getAnyProp() { return this.anyProp; } + public void setAnyProp(Map anyProp) { this.anyProp = anyProp; } + public Map getAdditionalProperties() { return this.additionalProperties; } public void setAdditionalProperties(Map additionalProperties) { this.additionalProperties = additionalProperties; } }" diff --git a/test/generators/kotlin/presets/DescriptionPreset.spec.ts b/test/generators/kotlin/presets/DescriptionPreset.spec.ts index 68ef1d2524..7be318ebc9 100644 --- a/test/generators/kotlin/presets/DescriptionPreset.spec.ts +++ b/test/generators/kotlin/presets/DescriptionPreset.spec.ts @@ -20,6 +20,12 @@ describe('KOTLIN_DESCRIPTION_PRESET', () => { type: 'string', description: 'Description for prop', examples: ['exampleValue'] + }, + anyProp: { + type: 'object', + $id: 'AnyTest', + properties: {}, + description: 'AnyTest description' } } }; diff --git a/test/generators/kotlin/presets/__snapshots__/DescriptionPreset.spec.ts.snap b/test/generators/kotlin/presets/__snapshots__/DescriptionPreset.spec.ts.snap index 22bbeb3e4c..9f3742e350 100644 --- a/test/generators/kotlin/presets/__snapshots__/DescriptionPreset.spec.ts.snap +++ b/test/generators/kotlin/presets/__snapshots__/DescriptionPreset.spec.ts.snap @@ -5,6 +5,7 @@ exports[`KOTLIN_DESCRIPTION_PRESET should render description and examples for cl * Description for class * * @property prop Description for prop + * @property anyProp AnyTest description * @property additionalProperties * * Examples: @@ -12,6 +13,7 @@ exports[`KOTLIN_DESCRIPTION_PRESET should render description and examples for cl */ data class Clazz( val prop: String? = null, + val anyProp: Map? = null, val additionalProperties: Map? = null, )" `; diff --git a/test/generators/php/presets/DescriptionPreset.spec.ts b/test/generators/php/presets/DescriptionPreset.spec.ts index c1036262b6..97f903be0e 100644 --- a/test/generators/php/presets/DescriptionPreset.spec.ts +++ b/test/generators/php/presets/DescriptionPreset.spec.ts @@ -22,6 +22,12 @@ describe('PHP_DESCRIPTION_PRESET', () => { type: 'string', description: 'Description for prop', examples: ['exampleValue'] + }, + anyProp: { + type: 'object', + $id: 'AnyTest', + properties: {}, + description: 'AnyTest description' } } }; diff --git a/test/generators/php/presets/__snapshots__/DescriptionPreset.spec.ts.snap b/test/generators/php/presets/__snapshots__/DescriptionPreset.spec.ts.snap index 13b4aee0aa..7d72e3fc6a 100644 --- a/test/generators/php/presets/__snapshots__/DescriptionPreset.spec.ts.snap +++ b/test/generators/php/presets/__snapshots__/DescriptionPreset.spec.ts.snap @@ -7,11 +7,15 @@ exports[`PHP_DESCRIPTION_PRESET should render description and examples for class final class Clazz { private ?string $prop; + private mixed $anyProp; private mixed $additionalProperties; public function getProp(): ?string { return $this->prop; } public function setProp(?string $prop): void { $this->prop = $prop; } + public function getAnyProp(): mixed { return $this->anyProp; } + public function setAnyProp(mixed $anyProp): void { $this->anyProp = $anyProp; } + public function getAdditionalProperties(): mixed { return $this->additionalProperties; } public function setAdditionalProperties(mixed $additionalProperties): void { $this->additionalProperties = $additionalProperties; } } diff --git a/test/generators/scala/presets/DescriptionPreset.spec.ts b/test/generators/scala/presets/DescriptionPreset.spec.ts index 6d78deabf0..291b022f38 100644 --- a/test/generators/scala/presets/DescriptionPreset.spec.ts +++ b/test/generators/scala/presets/DescriptionPreset.spec.ts @@ -20,6 +20,12 @@ describe('SCALA_DESCRIPTION_PRESET', () => { type: 'string', description: 'Description for prop', examples: ['exampleValue'] + }, + anyProp: { + type: 'object', + $id: 'AnyTest', + properties: {}, + description: 'AnyTest description' } } }; diff --git a/test/generators/scala/presets/__snapshots__/DescriptionPreset.spec.ts.snap b/test/generators/scala/presets/__snapshots__/DescriptionPreset.spec.ts.snap index 9ed63ab635..449c44b881 100644 --- a/test/generators/scala/presets/__snapshots__/DescriptionPreset.spec.ts.snap +++ b/test/generators/scala/presets/__snapshots__/DescriptionPreset.spec.ts.snap @@ -5,6 +5,7 @@ exports[`SCALA_DESCRIPTION_PRESET should render description and examples for cla * Description for class * * @property prop Description for prop + * @property anyProp AnyTest description * @property additionalProperties * * Examples: @@ -12,6 +13,7 @@ exports[`SCALA_DESCRIPTION_PRESET should render description and examples for cla */ case class Clazz( prop: Option[String], + anyProp: Option[Map[String, Any]], additionalProperties: Option[Map[String, Any]], )" `; diff --git a/test/generators/typescript/preset/DescriptionPreset.spec.ts b/test/generators/typescript/preset/DescriptionPreset.spec.ts index 7a2048a91c..30a1d4110a 100644 --- a/test/generators/typescript/preset/DescriptionPreset.spec.ts +++ b/test/generators/typescript/preset/DescriptionPreset.spec.ts @@ -18,6 +18,12 @@ const doc = { $id: 'NestedTest', properties: { stringProp: { type: 'string' } }, examples: ['Example 1', 'Example 2'] + }, + anyProp: { + type: 'object', + $id: 'AnyTest', + properties: {}, + description: 'AnyTest description' } } }; diff --git a/test/generators/typescript/preset/__snapshots__/DescriptionPreset.spec.ts.snap b/test/generators/typescript/preset/__snapshots__/DescriptionPreset.spec.ts.snap index 6d1ad289d4..50c53946f0 100644 --- a/test/generators/typescript/preset/__snapshots__/DescriptionPreset.spec.ts.snap +++ b/test/generators/typescript/preset/__snapshots__/DescriptionPreset.spec.ts.snap @@ -8,17 +8,20 @@ class Test { private _stringProp: string; private _numberProp?: number; private _objectProp?: NestedTest; + private _anyProp?: Map; private _additionalProperties?: Map; constructor(input: { stringProp: string, numberProp?: number, objectProp?: NestedTest, + anyProp?: Map, additionalProperties?: Map, }) { this._stringProp = input.stringProp; this._numberProp = input.numberProp; this._objectProp = input.objectProp; + this._anyProp = input.anyProp; this._additionalProperties = input.additionalProperties; } @@ -38,6 +41,12 @@ class Test { get objectProp(): NestedTest | undefined { return this._objectProp; } set objectProp(objectProp: NestedTest | undefined) { this._objectProp = objectProp; } + /** + * AnyTest description + */ + get anyProp(): Map | undefined { return this._anyProp; } + set anyProp(anyProp: Map | undefined) { this._anyProp = anyProp; } + get additionalProperties(): Map | undefined { return this._additionalProperties; } set additionalProperties(additionalProperties: Map | undefined) { this._additionalProperties = additionalProperties; } }" diff --git a/test/processors/__snapshots__/AsyncAPIInputProcessor.spec.ts.snap b/test/processors/__snapshots__/AsyncAPIInputProcessor.spec.ts.snap index b450afeaee..3da4faa3ec 100644 --- a/test/processors/__snapshots__/AsyncAPIInputProcessor.spec.ts.snap +++ b/test/processors/__snapshots__/AsyncAPIInputProcessor.spec.ts.snap @@ -52,7 +52,9 @@ Object { "options": Object { "isNullable": true, }, - "originalInput": true, + "originalInput": Object { + "value": true, + }, }, }, "propertyName": "additionalProperties", @@ -149,7 +151,9 @@ Object { "options": Object { "isNullable": true, }, - "originalInput": true, + "originalInput": Object { + "value": true, + }, }, }, "propertyName": "additionalProperties", @@ -4265,7 +4269,9 @@ InputMetaModel { "options": Object { "isNullable": true, }, - "originalInput": true, + "originalInput": Object { + "value": true, + }, }, }, "propertyName": "additionalProperties", @@ -4438,7 +4444,9 @@ InputMetaModel { "options": Object { "isNullable": true, }, - "originalInput": true, + "originalInput": Object { + "value": true, + }, }, }, "propertyName": "additionalProperties", @@ -4611,7 +4619,9 @@ InputMetaModel { "options": Object { "isNullable": true, }, - "originalInput": true, + "originalInput": Object { + "value": true, + }, }, }, "propertyName": "additionalProperties",