mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 19:08:52 +00:00
ModelUtils: isMap only if additionalProperties is a Schema (#410)
Fix for issue #409
This commit is contained in:
parent
8e648e4d95
commit
a02b313b89
@ -304,7 +304,7 @@ public class ModelUtils {
|
|||||||
if (schema instanceof MapSchema) {
|
if (schema instanceof MapSchema) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (schema.getAdditionalProperties() != null) {
|
if (schema.getAdditionalProperties() instanceof Schema) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||||
|
* Copyright 2018 SmartBear Software
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.openapitools.codegen.html;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.models.media.IntegerSchema;
|
||||||
|
import io.swagger.v3.oas.models.media.ObjectSchema;
|
||||||
|
import io.swagger.v3.oas.models.media.Schema;
|
||||||
|
import io.swagger.v3.oas.models.media.StringSchema;
|
||||||
|
|
||||||
|
import org.openapitools.codegen.CodegenModel;
|
||||||
|
import org.openapitools.codegen.languages.StaticHtmlGenerator;
|
||||||
|
import org.testng.Assert;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
public class StaticHtmlGeneratorTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAdditionalPropertiesFalse() {
|
||||||
|
final StaticHtmlGenerator codegen = new StaticHtmlGenerator();
|
||||||
|
|
||||||
|
Schema schema = new ObjectSchema()
|
||||||
|
.additionalProperties(false)
|
||||||
|
.addProperties("id", new IntegerSchema())
|
||||||
|
.addProperties("name", new StringSchema());
|
||||||
|
CodegenModel cm = codegen.fromModel("test", schema, Collections.emptyMap());
|
||||||
|
Assert.assertNotNull(cm);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user