Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

v2 individual endpoint docs #96

Merged
merged 34 commits into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
4202c80
Moves path generation out of the python client into default layers
spacether Nov 25, 2022
74ab5b9
Fixes java call sites
spacether Nov 25, 2022
8f2b398
petstore regenerated
spacether Nov 25, 2022
bf8a73f
Removes paths with old names
spacether Nov 25, 2022
ca770df
Removes old autogen tests
spacether Nov 25, 2022
411ad16
Fixes deprecated method usage, removes unused imports
spacether Nov 25, 2022
515a19b
Samples regenerated
spacether Nov 25, 2022
9bffae2
templates renamed
spacether Nov 25, 2022
3b1c968
Adds pathEndpointTemplateFiles and uses it
spacether Nov 25, 2022
bed262c
Adds general code to generate path request bodies and parameters
spacether Nov 26, 2022
17b901f
Adds pathEndpointResponseTemplateFiles + pathEndpointResponseHeaderTe…
spacether Nov 26, 2022
e6f9b49
Further refactoring, adds pathEndpointTestTemplateFiles
spacether Nov 26, 2022
ee43209
Finishes generateEndpoints refactor
spacether Nov 26, 2022
bb17e2e
Petstore sample regenerated
spacether Nov 26, 2022
fd5dbd1
Adds java code to generate endpoint docs
spacether Nov 26, 2022
f4be830
petstore regenerated, per endpoint docs exist
spacether Nov 26, 2022
e92b01e
api docs updated
spacether Nov 26, 2022
385e907
FIxes link to endpoint files
spacether Nov 26, 2022
da120bb
Moves endpoind docs into the tags folder
spacether Nov 27, 2022
00bd2f2
Creates and uses CodegenTag to store api module and classname info
spacether Nov 27, 2022
f7234ed
Endpoint docs generated in correct location, tag and tags used in tem…
spacether Nov 27, 2022
1521897
Removes operationId prefix from endpoint_doc anchors in template
spacether Nov 27, 2022
54474f2
Petstore regen
spacether Nov 27, 2022
034a8ff
Fixes anchor links, adds anchorContainsPeriod=true
spacether Nov 27, 2022
a99c237
Updates links in endpoiint files
spacether Nov 28, 2022
473f997
Endpoint doc links updated
spacether Nov 28, 2022
a5e2543
Fixes API link
spacether Nov 28, 2022
2b91c0a
Fixes api_doc links
spacether Nov 28, 2022
3c185ce
Fixes host and exception info in endpoint docs
spacether Nov 28, 2022
6d01643
Updates readme endpoints
spacether Nov 28, 2022
d731289
Adds request bodies
spacether Nov 28, 2022
5e13983
Samples regenerated
spacether Nov 28, 2022
1c2857d
Fixes docs dor request bodies, omitted when not present
spacether Nov 28, 2022
4526498
Fixes java tsts
spacether Nov 28, 2022
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 @@ -128,6 +128,8 @@ public interface CodegenConfig {

String getOutputDir();

String packagePath();

void setOutputDir(String dir);

CodegenModel fromModel(String name, Schema schema);
Expand Down Expand Up @@ -156,12 +158,28 @@ public interface CodegenConfig {

Map<String, String> apiTemplateFiles();

Map<String, String> apiXToApiTemplateFiles();

Map<String, String> modelTemplateFiles();

Map<String, String> requestBodyTemplateFiles();

Map<String, String> requestBodyDocTemplateFiles();

Map<String, String> pathEndpointTemplateFiles();

Set<String> pathEndpointTestTemplateFiles();

Set<String> pathEndpointDocTemplateFiles();

Map<String, String> pathEndpointRequestBodyTemplateFiles();

Set<String> pathEndpointParameterTemplateFiles();

Map<String, String> pathEndpointResponseTemplateFiles();

Set<String> pathEndpointResponseHeaderTemplateFiles();

Map<String, String> apiTestTemplateFiles();

Map<String, String> modelTestTemplateFiles();
Expand Down Expand Up @@ -202,6 +220,10 @@ public interface CodegenConfig {

String toRequestBodyDocFilename(String componentName);

String toPathFileName(String path);

String toParameterFileName(String baseName);

String toModelImport(String refClass);

Map<String, String> toModelImportMap(String name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package org.openapitools.codegen;

import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.tags.Tag;

import java.util.*;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -50,7 +49,7 @@ public class CodegenOperation {
public List<CodegenParameter> requiredParams = new ArrayList<CodegenParameter>();
public List<CodegenParameter> optionalParams = new ArrayList<CodegenParameter>();
public List<CodegenSecurity> authMethods;
public List<Tag> tags;
public Map<String, CodegenTag> tags;
public List<CodegenResponse> responses = new ArrayList<CodegenResponse>();
public CodegenResponse defaultResponse = null;
public List<CodegenCallback> callbacks = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.openapitools.codegen;
import io.swagger.v3.oas.models.tags.Tag;

public class CodegenTag extends Tag {
private String moduleName = null;
private String className = null;

public String getModuleName() {
return this.moduleName;
}

public void setModuleName(String moduleName) {
this.moduleName = moduleName;
}

public String getClassName() {
return this.className;
}

public void setClassName(String className) {
this.className = className;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.samskivert.mustache.Mustache.Compiler;
import com.samskivert.mustache.Mustache.Lambda;

import io.swagger.v3.oas.models.tags.Tag;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.text.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -179,9 +180,17 @@ apiTemplateFiles are for API outputs only (controllers/handlers).
API templates may be written multiple times; APIs are grouped by tag and the file is written once per tag group.
*/
protected Map<String, String> apiTemplateFiles = new HashMap<>();
protected Map<String, String> apiXToApiTemplateFiles = new HashMap<>();
protected Map<String, String> modelTemplateFiles = new HashMap<>();
protected Map<String, String> requestBodyTemplateFiles = new HashMap<>();
protected Map<String, String> requestBodyDocTemplateFiles = new HashMap();
protected Map<String, String> pathEndpointTemplateFiles = new HashMap();
protected Set<String> pathEndpointDocTemplateFiles = new HashSet<>();
protected Set<String> pathEndpointTestTemplateFiles = new HashSet<>();
protected Map<String, String> pathEndpointRequestBodyTemplateFiles = new HashMap<>();
protected Set<String> pathEndpointParameterTemplateFiles = new HashSet<>();
protected Map<String, String> pathEndpointResponseTemplateFiles = new HashMap<>();
protected Set<String> pathEndpointResponseHeaderTemplateFiles = new HashSet<>();
protected Map<String, String> apiTestTemplateFiles = new HashMap<>();
protected Map<String, String> modelTestTemplateFiles = new HashMap<>();
protected Map<String, String> apiDocTemplateFiles = new HashMap<>();
Expand Down Expand Up @@ -539,6 +548,10 @@ public String packageName() {
return packageName;
}

public String packagePath() {
return packageName.replace('.', File.separatorChar);
}

/**
* Index all CodegenModels by model name.
*
Expand Down Expand Up @@ -1187,6 +1200,9 @@ public Map<String, String> apiTemplateFiles() {
return apiTemplateFiles;
}

@Override
public Map<String, String> apiXToApiTemplateFiles() { return apiXToApiTemplateFiles; }

@Override
public Map<String, String> modelTemplateFiles() {
return modelTemplateFiles;
Expand All @@ -1198,6 +1214,27 @@ public Map<String, String> modelTemplateFiles() {
@Override
public Map<String, String> requestBodyDocTemplateFiles() { return requestBodyDocTemplateFiles; }

@Override
public Map<String, String> pathEndpointTemplateFiles() { return pathEndpointTemplateFiles; }

@Override
public Set<String> pathEndpointDocTemplateFiles() { return pathEndpointDocTemplateFiles; }

@Override
public Set<String> pathEndpointTestTemplateFiles() { return pathEndpointTestTemplateFiles; }

@Override
public Map<String, String> pathEndpointRequestBodyTemplateFiles() { return pathEndpointRequestBodyTemplateFiles; }

@Override
public Set<String> pathEndpointParameterTemplateFiles() { return pathEndpointParameterTemplateFiles; }

@Override
public Map<String, String> pathEndpointResponseTemplateFiles() { return pathEndpointResponseTemplateFiles; }

@Override
public Set<String> pathEndpointResponseHeaderTemplateFiles() { return pathEndpointResponseHeaderTemplateFiles; }

public String toRequestBodyFilename(String componentName) {
return toModuleFilename(componentName);
}
Expand Down Expand Up @@ -1477,6 +1514,14 @@ public String toModuleFilename(String name) {
return camelize(name);
}

public String toPathFileName(String name) {
return toModuleFilename(name);
}

@Override
public String toParameterFileName(String basename) {
return toModuleFilename(basename);
}

/**
* Return the capitalized file name of the model test
Expand Down Expand Up @@ -4189,6 +4234,27 @@ public CodegenOperation fromOperation(String path,
op.servers = fromServers(servers);
}

// tags
List<String> operationtTagNames = operation.getTags();
Map<String, CodegenTag> codegenTags = new HashMap<>();
if (operationtTagNames != null) {
for (String tagName: operation.getTags()) {
CodegenTag codegenTag = new CodegenTag();
codegenTag.setName(tagName);
codegenTag.setModuleName(toApiFilename(tagName));
codegenTag.setClassName(toApiName(tagName));
codegenTags.put(tagName, codegenTag);
}
} else {
String tagName = "default";
CodegenTag codegenTag = new CodegenTag();
codegenTag.setName(tagName);
codegenTag.setModuleName(toApiFilename(tagName));
codegenTag.setClassName(toApiName(tagName));
codegenTags.put(tagName, codegenTag);
}
op.tags = codegenTags;

// store the original operationId for plug-in
op.operationIdOriginal = operation.getOperationId();

Expand Down
Loading