Various enhancements to html2 docsgen (#643)

This commit includes the following changes:

- Fix docs not generating parameter descriptions, add rust sample.
- Add example to doc output.
- Add basic scope reporting.
- Stringify the JSON "Example" objects for response schemas.
- Prettify JSON examples in response schemas.
- Parse and present multiline response descriptions.
- Add API error details to docsgen.
- Add read only markers to read only properties.
- Fix up style document indentation.
- Add support for `x-shared-errors`, an extension to define common error types that can be shared across a microservice framework.
This commit is contained in:
Benjamin Gill
2018-07-26 14:57:57 +01:00
committed by William Cheng
parent 1d72edddf6
commit 7624a1ff85
10 changed files with 1759 additions and 438 deletions

View File

@@ -17,12 +17,14 @@
package org.openapitools.codegen.languages;
import io.swagger.v3.core.util.Json;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import com.fasterxml.jackson.databind.JsonNode;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConfig;
@@ -175,6 +177,22 @@ public class StaticHtml2Generator extends DefaultCodegen implements CodegenConfi
additionalProperties.put("jsModuleName", jsModuleName);
preparHtmlForGlobalDescription(openAPI);
Map<String, Object> vendorExtensions = openAPI.getExtensions();
if (vendorExtensions != null) {
for(Map.Entry<String, Object> vendorExtension: vendorExtensions.entrySet()) {
// Vendor extensions could be Maps (objects). If we wanted to iterate through them in our template files
// without knowing the keys beforehand, the default `toString` method renders them unusable. Instead, we
// convert them to JSON strings now, which means we can easily use them later.
if (vendorExtension.getValue() instanceof Map) {
this.vendorExtensions().put(vendorExtension.getKey(), Json.mapper().convertValue(vendorExtension.getValue(), JsonNode.class));
} else {
this.vendorExtensions().put(vendorExtension.getKey(), vendorExtension.getValue());
}
}
}
openAPI.setExtensions(this.vendorExtensions);
}
@Override