Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
737d6b0
Adds top link section in endpoint docs, makes reponses h2
spacether Feb 13, 2023
768a8ba
Adds table of contents
spacether Feb 13, 2023
981225e
Moves TOC to h2
spacether Feb 13, 2023
25e1e42
Adds and uses headerSize parameter
spacether Feb 13, 2023
f72a296
Removes anchorContainsPeriod
spacether Feb 13, 2023
99d43f7
Adjusts request body header size when requestbody is refed
spacether Feb 13, 2023
1cfa20b
Updates request body header size for non refed request bodies
spacether Feb 13, 2023
4c671e1
Removes header from request body component module
spacether Feb 13, 2023
fd62805
Moves code sample to bottom, adds h2 section for authorization, adds …
spacether Feb 13, 2023
c46283a
Adds description and summary sections
spacether Feb 13, 2023
5024953
Uses headerSize in parameter docs
spacether Feb 13, 2023
7cc6043
Fixes headerSize in parameter_doc.hbs
spacether Feb 13, 2023
b133df3
Has header docs use headerSize
spacether Feb 13, 2023
630f223
Improves indentation in response bodies
spacether Feb 13, 2023
01167a5
Adjusts paramter schema depths
spacether Feb 13, 2023
8ffb5d5
Removes deep headerSize passing in paramter_doc
spacether Feb 13, 2023
941e12b
dedents schema module in component schema docs
spacether Feb 13, 2023
10f5960
Flows headerSize into schema docs
spacether Feb 13, 2023
8ace034
Removes discription when there re no arguments
spacether Feb 13, 2023
4e1297b
Removes auth section if there is no auth
spacether Feb 13, 2023
3d6da82
Uses join for parameter schema docs
spacether Feb 13, 2023
c1c70ab
Adds header for each parameter
spacether Feb 13, 2023
4f52adf
Removes redundant data addition
spacether Feb 14, 2023
b669d93
Header indentation updated in components
spacether Feb 14, 2023
6d7258e
Adds body and header sections to response
spacether Feb 14, 2023
5f34a4e
Uses headerSize in response_doc
spacether Feb 14, 2023
9da547d
Fully uses headerSize in response_doc
spacether Feb 14, 2023
6c47dbe
Uses camelCase name in headings for headers and content
spacether Feb 14, 2023
5547237
Adds response dscriptions to docs
spacether Feb 14, 2023
be01471
Uses headerSize in request body doc
spacether Feb 14, 2023
a6b2546
Adds request body description to docs
spacether Feb 14, 2023
1d838ff
Adds descriptions to responses and request bodies
spacether Feb 14, 2023
17c022f
Fixes links to ref responses
spacether Feb 14, 2023
6c6e984
Adds parameter and header descriptions
spacether Feb 14, 2023
8c2fdaf
Adds component schema descriptions
spacether Feb 14, 2023
c8208ba
Increases indentation depth in schema docs
spacether Feb 14, 2023
0eb0f86
Reduces composed indentation
spacether Feb 14, 2023
6b41cee
Adds indentation
spacether Feb 15, 2023
20a1a3b
All sub lists use numbering
spacether Feb 15, 2023
06bf45a
Removes empty lines from indented schema doc template
spacether Feb 15, 2023
00ddfaf
Fixes some tables
spacether Feb 15, 2023
4b931e6
Actually indents subschemas
spacether Feb 15, 2023
0ce0233
Indentation level corrected
spacether Feb 15, 2023
5b95e56
Adds new lines back into schema doc indent template
spacether Feb 15, 2023
c016257
Uses headerSize.length in schema_doc_indent
spacether Feb 15, 2023
34f2978
Removes trailing # from headings in indent
spacether Feb 15, 2023
a192c2f
Adds newline bfore oneOf anyOf allOf Nots
spacether Feb 15, 2023
e5d9aa8
Removes unneeded deeper indentation
spacether Feb 15, 2023
ca4f00d
Adds 1 level of depth to request body schema
spacether Feb 15, 2023
a985eef
Indents request body schema info under header schema class name
spacether Feb 15, 2023
c60609b
Improves endpoint response indentation
spacether Feb 15, 2023
439740e
Fixes request body links in endpoint docs
spacether Feb 16, 2023
2f700d4
Stops indenting schemas, lists them all at the same level
spacether Feb 16, 2023
9897a78
Inlines all schemas
spacether Feb 16, 2023
5b62dd5
Adds indentation under schema
spacether Feb 16, 2023
39303c4
Removes RequestBody prefix from request body description
spacether Feb 16, 2023
c765867
Removes prefixes from response data
spacether Feb 16, 2023
6e77906
Moves header summary higher, adds header details removes response pre…
spacether Feb 16, 2023
33270dd
Removes prefix from response headers when they are inline
spacether Feb 16, 2023
d9a4d74
Adds levels to header docs
spacether Feb 16, 2023
366f15d
Lists responses after response summary to keep header levels at h6 max
spacether Feb 16, 2023
957410c
Removes description prefix from header docs
spacether Feb 16, 2023
e22ef83
Updates parameter descriptions
spacether Feb 16, 2023
c6264af
Simplifies parameter and header docs
spacether Feb 16, 2023
8fcb2f8
Simplifies response doc
spacether Feb 17, 2023
8819fb6
Simplies request body doc template
spacether Feb 17, 2023
b3a4965
Simplifies schema doc
spacether Feb 17, 2023
b62626d
Adds schema writing of anchors with ids containing json path info
spacether Feb 18, 2023
0881f9d
Tweaks schema anchors
spacether Feb 18, 2023
f9d6cc8
Moves anchor above heading
spacether Feb 18, 2023
d163b43
Fixes property links
spacether Feb 18, 2023
256ad22
Fixes required an optional schema docs links
spacether Feb 19, 2023
c502015
Adds content type to schema request body section
spacether Feb 19, 2023
9d8d298
Adds newArray and add helpers
spacether Feb 20, 2023
49764c4
Adds identifierPieces to schema rendering
spacether Feb 21, 2023
4db20df
Uses identifierPieces
spacether Feb 21, 2023
884b495
Generates custom anchor
spacether Feb 21, 2023
6b4aeb5
Adds anchorPiece
spacether Feb 21, 2023
d224e6d
Uses anchorPiece in anchors
spacether Feb 21, 2023
65a23a2
Sample regen
spacether Feb 21, 2023
433a9de
Removes manual anchor
spacether Feb 21, 2023
da02d16
Uses _helper_header_from_identifier_pieces
spacether Feb 21, 2023
54e429b
Adds Items component schema example
spacether Feb 21, 2023
aea4f5a
Adds sample schemas with collisions
spacether Feb 21, 2023
0e095aa
Fixes doc colision in schema property docs
spacether Feb 22, 2023
a7a4364
Simplifies schema doc template
spacether Feb 22, 2023
045ef0d
Updates requestBody doc template
spacether Feb 22, 2023
b3079ae
Simplifies request body docs
spacether Feb 22, 2023
0501747
Omits self header prefix in schema and request body docs for inline s…
spacether Feb 22, 2023
e3b53ff
Adjusts when suffix is added to links
spacether Feb 22, 2023
8422b71
passes in needed identifierPieces into response headers
spacether Feb 22, 2023
96556d9
Updates header docs
spacether Feb 22, 2023
d249b59
Adds header content type to schema section in docs
spacether Feb 22, 2023
66d9754
Updates most of codegen response docs
spacether Feb 23, 2023
2bc75d2
Changes content to body
spacether Feb 23, 2023
78d3825
Fixes template warning by passing in includeSuffix
spacether Feb 23, 2023
8eaedc8
Parameter docs updated, parameter docs have needed params
spacether Feb 23, 2023
33ac0f7
Adds Schema prefix to component schema h1
spacether Feb 24, 2023
6a0ffaf
Adds Response prefix to response docs
spacether Feb 24, 2023
dda339d
Adds prefix to other components
spacether Feb 24, 2023
fc77c01
Adds headers prefix for response header docs
spacether Feb 24, 2023
adc8580
Adds path to operation docs
spacether Feb 24, 2023
db87955
Adds path anchor link
spacether Feb 24, 2023
f33b22f
Adds http method to operation docs
spacether Feb 24, 2023
727a4b0
Operation requestbody heading updated
spacether Feb 24, 2023
2e5ee5c
Removes template setting of var complexTypePrefix
spacether Feb 24, 2023
426930c
Fixes rending of required and optional input type and accessed types …
spacether Feb 24, 2023
91cb8ef
Simplifies dict req and optional input type accessed type template
spacether Feb 24, 2023
9909324
Fixes template access warning
spacether Feb 24, 2023
a6b0e3b
Updates response docs to handle no resonse body schema use case
spacether Feb 24, 2023
2360911
response body class updated when no content schemas are defined
spacether Feb 24, 2023
a71db7f
Fixes doc links for self reverences
spacether Feb 24, 2023
88c41b1
moved dict property schema link location in docs
spacether Feb 24, 2023
d4107b6
Adds link to additional properties class in schema docs
spacether Feb 24, 2023
cd99075
Adds example that shows response body links are working
spacether Feb 24, 2023
9b45606
Samples regen
spacether Feb 24, 2023
4cdfc32
Removes unused templates
spacether Feb 24, 2023
8828870
params updated
spacether Feb 25, 2023
c26aa96
sample regen
spacether Feb 25, 2023
40259b3
Fixes locale invocations
spacether Feb 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -2569,11 +2569,14 @@ protected CodegenKey getOperationId(Operation operation, String path, String htt
operationId = String.join(removeOperationIdPrefixDelimiter, Arrays.copyOfRange(components, component_number, components.length));
}
}
String camelCase = toModelName(operationId);
String anchorPiece = camelCase.toLowerCase(Locale.ROOT);
return new CodegenKey(
operationId,
isValid(operationId),
getOperationIdSnakeCase(operationId),
toModelName(operationId)
camelCase,
anchorPiece
);
}

Expand Down Expand Up @@ -2634,11 +2637,14 @@ public CodegenOperation fromOperation(String path,
} else {
usedPath = path;
}
String camelCase = toModelName(path);
String anchorPiece = camelCase.toLowerCase(Locale.ROOT);
CodegenKey pathKey = new CodegenKey(
usedPath,
false, // false because paths have lots of invalid characters
toPathFilename(path),
toModelName(path)
camelCase,
anchorPiece
);
String sourceJsonPath = "#/paths/" + ModelUtils.encodeSlashes(pathKey.original) + "/" + httpMethod;

Expand Down Expand Up @@ -2809,12 +2815,14 @@ public CodegenOperation fromOperation(String path,
}
}
}

String camelCaseMethod = org.openapijsonschematools.codegen.utils.StringUtils.camelize(httpMethod);
String anchorPieceMethod = camelCase.toLowerCase(Locale.ROOT);
CodegenKey httpMethodKey = new CodegenKey(
httpMethod,
true,
org.openapijsonschematools.codegen.utils.StringUtils.underscore(httpMethod),
org.openapijsonschematools.codegen.utils.StringUtils.camelize(httpMethod)
camelCaseMethod,
anchorPieceMethod
);

// move "required" parameters in front of "optional" parameters
Expand Down Expand Up @@ -4522,6 +4530,7 @@ public CodegenKey getKey(String key, String expectedComponentType) {
boolean isValid = isValid(usedKey);
String snakeCaseName = null;
String camelCaseName = null;
String anchorPiece = null;
switch (expectedComponentType) {
case "schemas":
snakeCaseName = toModelFilename(usedKey);
Expand All @@ -4544,22 +4553,29 @@ public CodegenKey getKey(String key, String expectedComponentType) {
camelCaseName = getCamelCaseResponse(usedKey);
break;
}
if (camelCaseName != null) {
anchorPiece = camelCaseName.toLowerCase(Locale.ROOT);
}
return new CodegenKey(
usedKey,
isValid,
snakeCaseName,
camelCaseName
camelCaseName,
anchorPiece
);
}

public CodegenKey getKey(String key) {
String usedKey = handleSpecialCharacters(key);
boolean isValid = isValid(usedKey);
String camelCase = toModelName(usedKey);
String anchorPiece = camelCase.toLowerCase(Locale.ROOT);
return new CodegenKey(
usedKey,
isValid,
toModelFilename(usedKey),
toModelName(usedKey)
camelCase,
anchorPiece
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ private void generateModelDocumentation(List<File> files, Map<String, Object> mo
String docExtension = config.getDocExtension();
String suffix = docExtension != null ? docExtension : config.modelDocTemplateFiles().get(templateName);
String filename = config.modelDocFileFolder() + File.separator + config.toModelDocFilename(modelName) + suffix;
modelData.put("headerSize", "#");

File written = processTemplateToFile(modelData, templateName, filename, generateModelDocumentation, CodegenConstants.MODEL_DOCS);
if (written != null) {
Expand Down Expand Up @@ -572,16 +573,20 @@ void generatePaths(List<File> files, Map<String, List<CodegenOperation>> operati

}
}
// operation docs
for (String templateFile: config.pathEndpointDocTemplateFiles()) {
for (Map.Entry<String, CodegenTag> entry: co.tags.entrySet()) {
CodegenTag tag = entry.getValue();
Map<String, Object> endpointInfo = new HashMap<>();
List<CodegenOperation> operation = Arrays.asList(co);
endpointInfo.put("operation", operation);
endpointInfo.put("operation", co);
endpointInfo.put("packageName", packageName);
endpointInfo.put("apiPackage", config.apiPackage());
endpointInfo.put("basePath", basePath);
endpointInfo.put("tag", tag);
endpointInfo.put("headerSize", "#");
endpointInfo.put("complexTypePrefix", "../../../components/schema/");
endpointInfo.put("identifierPieces", Collections.unmodifiableList(new ArrayList<>()));
endpointInfo.put("identifierToHeadingQty", new HashMap<>());
outputFilename = filenameFromRoot(Arrays.asList("docs", config.apiPackage(), "tags", tag.moduleName, co.operationId.snakeCase + ".md"));
apiDocFiles.add(Arrays.asList(endpointInfo, templateFile, outputFilename));
}
Expand Down Expand Up @@ -800,6 +805,9 @@ private TreeMap<String, CodegenResponse> generateResponses(List<File> files) {
Map<String, Object> templateData = new HashMap<>();
templateData.put("packageName", config.packageName());
templateData.put("complexTypePrefix", "../../components/schema/");
templateData.put("headerSize", "#");
templateData.put("identifierPieces", Collections.unmodifiableList(new ArrayList<>()));
templateData.put("identifierToHeadingQty", new HashMap<>());
templateData.put("response", response);
try {
File written = processTemplateToFile(templateData, templateName, filename, generateResponseDocumentation, CodegenConstants.REQUEST_BODY_DOCS);
Expand All @@ -821,7 +829,6 @@ private void generateRequestBody(List<File> files, CodegenRequestBody requestBod
Map<String, Object> templateData = new HashMap<>();
templateData.put("packageName", config.packageName());
templateData.put("requestBody", requestBody);
templateData.put("docRoot", "../../");
Boolean generateRequestBodies = Boolean.TRUE;
Map<String, String> templateInfo = config.jsonPathTemplateFiles().get(CodegenConstants.JSON_PATH_LOCATION_TYPE.REQUEST_BODY);
if (templateInfo != null && !templateInfo.isEmpty()) {
Expand Down Expand Up @@ -852,7 +859,10 @@ private void generateRequestBody(List<File> files, CodegenRequestBody requestBod
return;
}
// doc generation
Boolean generateRequestBodyDocumentaion = Boolean.TRUE;
Boolean generateRequestBodyDocumentation = Boolean.TRUE;
templateData.put("headerSize", "#");
templateData.put("identifierPieces", Collections.unmodifiableList(new ArrayList<>()));
templateData.put("identifierToHeadingQty", new HashMap<>());
String componentName = jsonPath.substring(jsonPath.lastIndexOf("/") + 1);
for (Map.Entry<String, String> entry: config.requestBodyDocTemplateFiles().entrySet()) {
String templateName = entry.getKey();
Expand All @@ -862,7 +872,7 @@ private void generateRequestBody(List<File> files, CodegenRequestBody requestBod

templateData.put("complexTypePrefix", "../../components/schema/");
try {
File written = processTemplateToFile(templateData, templateName, filename, generateRequestBodyDocumentaion, CodegenConstants.REQUEST_BODY_DOCS);
File written = processTemplateToFile(templateData, templateName, filename, generateRequestBodyDocumentation, CodegenConstants.REQUEST_BODY_DOCS);
if (written != null) {
files.add(written);
if (config.isEnablePostProcessFile() && !dryRun) {
Expand Down Expand Up @@ -962,6 +972,9 @@ private TreeMap<String, CodegenParameter> generateParameters(List<File> files) {
Map<String, Object> templateData = new HashMap<>();
templateData.put("packageName", config.packageName());
templateData.put("parameter", parameter);
templateData.put("headerSize", "#");
templateData.put("identifierPieces", Collections.unmodifiableList(new ArrayList<>()));
templateData.put("identifierToHeadingQty", new HashMap<>());
templateData.put("complexTypePrefix", "../../components/schema/");

try {
Expand Down Expand Up @@ -1066,6 +1079,7 @@ private TreeMap<String, CodegenHeader> generateHeaders(List<File> files) {

generateHeader(files, header, sourceJsonPath);

// documentation
Boolean generateHeaderDocs = Boolean.TRUE;
for (Map.Entry<String, String> headerDocInfo : config.headerDocTemplateFiles().entrySet()) {
String templateName = headerDocInfo.getKey();
Expand All @@ -1075,8 +1089,12 @@ private TreeMap<String, CodegenHeader> generateHeaders(List<File> files) {
Map<String, Object> templateData = new HashMap<>();
templateData.put("packageName", config.packageName());
templateData.put("header", header);
templateData.put("headerSize", "#");
templateData.put("complexTypePrefix", "../../components/schema/");
templateData.put("docRoot", "../../");
templateData.put("identifierPieces", Collections.unmodifiableList(new ArrayList<>()));
templateData.put("identifierToHeadingQty", new HashMap<>());


try {
File written = processTemplateToFile(templateData, templateName, filename, generateHeaderDocs, CodegenConstants.HEADER_DOCS, fileFolder);
Expand Down Expand Up @@ -1161,6 +1179,8 @@ protected TreeMap<String, CodegenSchema> generateSchemas(List<File> files) {
generateModelTests(files, schemaData, componentName);

// to generate model documentation files
schemaData.put("identifierPieces", Collections.unmodifiableList(new ArrayList<>()));
schemaData.put("identifierToHeadingQty", new HashMap<>());
generateModelDocumentation(files, schemaData, componentName);

} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ public class CodegenKey {
public final boolean isValid;
public final String snakeCase;
public final String camelCase;
public final String anchorPiece;

public CodegenKey(String original, boolean isValid, String snakeCase, String camelCase) {
public CodegenKey(String original, boolean isValid, String snakeCase, String camelCase, String anchorPiece) {
this.original = original;
this.isValid = isValid;
this.snakeCase = snakeCase;
this.camelCase = camelCase;
this.anchorPiece = anchorPiece;
}

@Override
Expand All @@ -23,11 +25,12 @@ public boolean equals(Object o) {
return Objects.equals(original, that.original) &&
Objects.equals(isValid, that.isValid) &&
Objects.equals(snakeCase, that.snakeCase) &&
Objects.equals(camelCase, that.camelCase);
Objects.equals(camelCase, that.camelCase) &&
Objects.equals(anchorPiece, that.anchorPiece);
}

@Override
public int hashCode() {
return Objects.hash(original, isValid, snakeCase, camelCase);
return Objects.hash(original, isValid, snakeCase, camelCase, anchorPiece);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
public class CodegenOperation {
public final Boolean deprecated;
public final boolean hasErrorResponseObject; // if 4xx, 5xx responses have at least one error object defined
public final String summary, unescapedNotes, notes;
public final String summary, unescapedDescription, description;
public final CodegenKey httpMethod;
public final CodegenKey path;
public final LinkedHashSet<String> produces;
Expand All @@ -51,12 +51,12 @@ public class CodegenOperation {
public final Map<String, Object> vendorExtensions;
public final CodegenKey operationId;

public CodegenOperation(Boolean deprecated, boolean hasErrorResponseObject, String summary, String unescapedNotes, String notes, CodegenKey httpMethod, CodegenKey path, LinkedHashSet<String> produces, List<CodegenServer> servers, CodegenRequestBody requestBody, List<CodegenParameter> allParams, List<CodegenParameter> pathParams, List<CodegenParameter> queryParams, List<CodegenParameter> headerParams, List<CodegenParameter> cookieParams, boolean hasRequiredParamOrBody, boolean hasOptionalParamOrBody, List<CodegenSecurity> authMethods, Map<String, CodegenTag> tags, TreeMap<String, CodegenResponse> responses, TreeMap<Integer, CodegenResponse> statusCodeResponses, TreeMap<Integer, CodegenResponse> wildcardCodeResponses, TreeMap<String, CodegenResponse> nonDefaultResponses, CodegenResponse defaultResponse, List<CodegenCallback> callbacks, ExternalDocumentation externalDocs, Map<String, Object> vendorExtensions, CodegenKey operationId) {
public CodegenOperation(Boolean deprecated, boolean hasErrorResponseObject, String summary, String unescapedDescription, String description, CodegenKey httpMethod, CodegenKey path, LinkedHashSet<String> produces, List<CodegenServer> servers, CodegenRequestBody requestBody, List<CodegenParameter> allParams, List<CodegenParameter> pathParams, List<CodegenParameter> queryParams, List<CodegenParameter> headerParams, List<CodegenParameter> cookieParams, boolean hasRequiredParamOrBody, boolean hasOptionalParamOrBody, List<CodegenSecurity> authMethods, Map<String, CodegenTag> tags, TreeMap<String, CodegenResponse> responses, TreeMap<Integer, CodegenResponse> statusCodeResponses, TreeMap<Integer, CodegenResponse> wildcardCodeResponses, TreeMap<String, CodegenResponse> nonDefaultResponses, CodegenResponse defaultResponse, List<CodegenCallback> callbacks, ExternalDocumentation externalDocs, Map<String, Object> vendorExtensions, CodegenKey operationId) {
this.deprecated = deprecated;
this.hasErrorResponseObject = hasErrorResponseObject;
this.summary = summary;
this.unescapedNotes = unescapedNotes;
this.notes = notes;
this.unescapedDescription = unescapedDescription;
this.description = description;
this.httpMethod = httpMethod;
this.path = path;
this.produces = produces;
Expand Down Expand Up @@ -131,8 +131,8 @@ public String toString() {
sb.append(", operationId='").append(operationId).append('\'');
sb.append(", httpMethod='").append(httpMethod).append('\'');
sb.append(", summary='").append(summary).append('\'');
sb.append(", unescapedNotes='").append(unescapedNotes).append('\'');
sb.append(", notes='").append(notes).append('\'');
sb.append(", unescapedNotes='").append(unescapedDescription).append('\'');
sb.append(", notes='").append(description).append('\'');
sb.append(", defaultResponse='").append(defaultResponse).append('\'');
sb.append(", produces=").append(produces);
sb.append(", servers=").append(servers);
Expand Down Expand Up @@ -167,8 +167,8 @@ public boolean equals(Object o) {
Objects.equals(operationId, that.operationId) &&
Objects.equals(httpMethod, that.httpMethod) &&
Objects.equals(summary, that.summary) &&
Objects.equals(unescapedNotes, that.unescapedNotes) &&
Objects.equals(notes, that.notes) &&
Objects.equals(unescapedDescription, that.unescapedDescription) &&
Objects.equals(description, that.description) &&
Objects.equals(defaultResponse, that.defaultResponse) &&
Objects.equals(produces, that.produces) &&
Objects.equals(servers, that.servers) &&
Expand All @@ -195,7 +195,7 @@ public boolean equals(Object o) {
public int hashCode() {

return Objects.hash(deprecated, path, operationId, httpMethod,
summary, unescapedNotes, notes, defaultResponse,
summary, unescapedDescription, description, defaultResponse,
produces, servers, requestBody, allParams,
pathParams, queryParams, headerParams, cookieParams, hasRequiredParamOrBody, hasOptionalParamOrBody,
authMethods, tags, responses, callbacks, externalDocs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,41 @@ public CodegenResponse(CodegenKey jsonPathPiece, Map<String, CodegenHeader> head
this.componentModule = componentModule;
}

/**
* Used by templates to only render body details if there is a schema defined for a content type
* @return true if there is an inline header
*/
public boolean hasContentSchema() {
if (content == null) {
return false;
}
for (CodegenMediaType mediaType: content.values()) {
if (mediaType == null) {
continue;
}
if (mediaType.schema != null) {
return true;
}
}
return false;
}

/**
* Used by templates to only render header details if there is an inline header
* @return true if there is an inline header
*/
public boolean hasInlineHeader() {
if (headers == null) {
return false;
}
for (CodegenHeader header: headers.values()) {
if (header.refInfo == null) {
return true;
}
}
return false;
}

@Override
public int hashCode() {
return Objects.hash(jsonPathPiece, description,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.github.jknack.handlebars.io.TemplateSource;
import org.openapijsonschematools.codegen.api.AbstractTemplatingEngineAdapter;
import org.openapijsonschematools.codegen.api.TemplatingExecutor;
import org.openapijsonschematools.codegen.templating.handlebars.CustomHelpers;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -87,7 +88,7 @@ public TemplateSource sourceAt(String location) {
StringHelpers.register(handlebars);
handlebars.registerHelpers(ConditionalHelpers.class);
handlebars.registerHelpers(org.openapijsonschematools.codegen.templating.handlebars.StringHelpers.class);
handlebars.registerHelpers(org.openapijsonschematools.codegen.templating.handlebars.ContainsHelper.class);
handlebars.registerHelpers(CustomHelpers.class);
handlebars.setInfiniteLoops(infiniteLoops);
handlebars.setPrettyPrint(prettyPrint);
Template tmpl = handlebars.compile(templateFile);
Expand Down
Loading