mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-06 10:35:25 +00:00
[html] Use ModelUtils to avoid NullPointerException (#1948)
This commit is contained in:
parent
c16354218a
commit
06824622bf
@ -194,7 +194,7 @@ public class StaticHtmlGenerator extends DefaultCodegen implements CodegenConfig
|
||||
Info info = openAPI.getInfo();
|
||||
info.setDescription(toHtml(info.getDescription()));
|
||||
info.setTitle(toHtml(info.getTitle()));
|
||||
Map<String, Schema> models = openAPI.getComponents().getSchemas();
|
||||
Map<String, Schema> models = ModelUtils.getSchemas(openAPI);
|
||||
for (Schema model : models.values()) {
|
||||
model.setDescription(toHtml(model.getDescription()));
|
||||
model.setTitle(toHtml(model.getTitle()));
|
||||
|
@ -17,10 +17,13 @@
|
||||
|
||||
package org.openapitools.codegen.html;
|
||||
|
||||
import io.swagger.parser.OpenAPIParser;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
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 io.swagger.v3.parser.core.models.ParseOptions;
|
||||
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
import org.openapitools.codegen.languages.StaticHtmlGenerator;
|
||||
@ -43,4 +46,14 @@ public class StaticHtmlGeneratorTest {
|
||||
Assert.assertNotNull(cm);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSpecWithoutSchema() throws Exception {
|
||||
final OpenAPI openAPI = new OpenAPIParser().readLocation("src/test/resources/3_0/ping.yaml", null, new ParseOptions()).getOpenAPI();
|
||||
|
||||
final StaticHtmlGenerator codegen = new StaticHtmlGenerator();
|
||||
codegen.preprocessOpenAPI(openAPI);
|
||||
|
||||
Assert.assertEquals(openAPI.getInfo().getTitle(), "ping test");
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user