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

Commit 9f635c3

Browse files
authored
v2 adds servers (#136)
* Adds servers template, replaces codegenservervariable with codegenschema * Adds servers init * Adds configuration server_info * Server key prefix converted to stirng * Consolidates path + pathItem generation * petstore regen * Updated data passed into operation test template * Fixes passing through the host property in endpoint calls, fixes some python tests * Adds needed pass line to simple schema generation in stub files * Removes extra new lines from server files * Fixes python tests * fixes server filenames in path item * Fixes server name generation on endpoint servers * Always passes in server_index * Adds test_path_servers * Separates out configuration classses, fixes python tests * Moves operation into non init python file, updates path to api gneration * Fixes tag_to_api generation * Adds path api generation * Adds api tag generation * Fixes 3 tests * Fixes python tests * Adds all server info to api configuration * Removes unused methods and properties * Adds test_operation_servers * Removes basePath, basePathWithoutHost, host, port * Removes unneeded java classes, simplifies readme endpoints generation * Removes parameter from bundle * Makes readme author section conditional, adds servers section, fixes endpoint path font weight * Adds code example back into readme * Fixes ref schema doc links * Adds root server docs * Removes pathEndpointDocTemplateFiles * Fixes parameter schema anchors in endpoint docs * Fixes schema refs in endpoints * Adds server info to operation docs * Adds pathItem servers to operation docs * Always adds Arguments and Servers sections to endpoint docs * Adds server info and defaults to endpoint docs * Removes responses prefix from endpoint docs * Adds working links for response classes * Fixes some java test syntax errors * Fixes more java test signature issues * Fixes more java test signature issues * Adds missing java templates back in * Removes callback test * Standardizes api file path generation * Fixes one java test * Generates api docs for each tag api * Fixes operationId endpoint order in api docs * Fixes readme link to api docs * Adds tag description to api docs * Fixes java test * Fixes java test * FIxes java test * Fixes testDateTimeFormParameterHasDefaultValue * Fixes testLeadingSlashIsAddedIfMissing * Docs regenerated * Regens sampless with fixed config imports * Fixes tests in unit test spec * Samples regenerated
1 parent 2ce652a commit 9f635c3

2,961 files changed

Lines changed: 179078 additions & 89965 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

modules/openapi-json-schema-generator/src/main/java/org/openapijsonschematools/codegen/CodegenConfig.java

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import com.samskivert.mustache.Mustache.Compiler;
2121
import io.swagger.v3.oas.models.OpenAPI;
2222
import io.swagger.v3.oas.models.Operation;
23+
import io.swagger.v3.oas.models.PathItem;
24+
import io.swagger.v3.oas.models.Paths;
2325
import io.swagger.v3.oas.models.headers.Header;
2426
import io.swagger.v3.oas.models.media.Schema;
2527
import io.swagger.v3.oas.models.parameters.Parameter;
@@ -30,20 +32,21 @@
3032
import io.swagger.v3.oas.models.servers.Server;
3133
import io.swagger.v3.oas.models.servers.ServerVariable;
3234
import org.openapijsonschematools.codegen.model.CodegenHeader;
35+
import org.openapijsonschematools.codegen.model.CodegenKey;
3336
import org.openapijsonschematools.codegen.model.CodegenOperation;
3437
import org.openapijsonschematools.codegen.model.CodegenParameter;
38+
import org.openapijsonschematools.codegen.model.CodegenPathItem;
3539
import org.openapijsonschematools.codegen.model.CodegenPatternInfo;
3640
import org.openapijsonschematools.codegen.model.CodegenRequestBody;
3741
import org.openapijsonschematools.codegen.model.CodegenResponse;
3842
import org.openapijsonschematools.codegen.model.CodegenSchema;
3943
import org.openapijsonschematools.codegen.model.CodegenSecurityRequirementValue;
4044
import org.openapijsonschematools.codegen.model.CodegenSecurityScheme;
4145
import org.openapijsonschematools.codegen.model.CodegenServer;
42-
import org.openapijsonschematools.codegen.model.CodegenServerVariable;
43-
import org.openapijsonschematools.codegen.model.OperationsMap;
4446
import org.openapijsonschematools.codegen.api.TemplatingEngineAdapter;
4547
import org.openapijsonschematools.codegen.meta.FeatureSet;
4648
import org.openapijsonschematools.codegen.meta.GeneratorMetadata;
49+
import org.openapijsonschematools.codegen.model.CodegenTag;
4750

4851
import java.io.File;
4952
import java.util.HashMap;
@@ -135,15 +138,23 @@ public interface CodegenConfig {
135138

136139
CodegenSchema fromSchema(Schema<?> schema, String sourceJsonPath, String currentJsonPath);
137140

138-
CodegenOperation fromOperation(String resourcePath, String httpMethod, Operation operation, List<Server> servers);
141+
CodegenTag fromTag(String name, String description);
142+
143+
CodegenOperation fromOperation(Operation operation, String jsonPath);
144+
145+
CodegenKey getKey(String key);
139146

140147
CodegenSecurityScheme fromSecurityScheme(SecurityScheme securityScheme, String jsonPath);
141148

142149
HashMap<String, CodegenSecurityRequirementValue> fromSecurityRequirement(SecurityRequirement securityScheme, String jsonPath);
143150

144-
List<CodegenServer> fromServers(List<Server> servers);
151+
TreeMap<CodegenKey, CodegenPathItem> fromPaths(Paths paths);
152+
153+
CodegenPathItem fromPathItem(PathItem pathItem, String jsonPath);
154+
155+
List<CodegenServer> fromServers(List<Server> servers, String jsonPath);
145156

146-
List<CodegenServerVariable> fromServerVariables(Map<String, ServerVariable> variables);
157+
HashMap<CodegenKey, CodegenSchema> fromServerVariables(Map<String, ServerVariable> variables, String jsonPath);
147158

148159
Map<String, String> typeMapping();
149160

@@ -157,24 +168,16 @@ public interface CodegenConfig {
157168

158169
Map<String, String> inlineSchemaNameDefault();
159170

160-
Map<String, String> apiTemplateFiles();
171+
HashMap<CodegenConstants.JSON_PATH_LOCATION_TYPE, HashMap<String, String>> jsonPathTemplateFiles();
161172

162-
Map<String, String> apiXToApiTemplateFiles();
163-
164-
Map<CodegenConstants.JSON_PATH_LOCATION_TYPE, Map<String, String>> jsonPathTemplateFiles();
165-
166-
Map<CodegenConstants.JSON_PATH_LOCATION_TYPE, Map<String, String>> jsonPathDocTemplateFiles();
173+
HashMap<CodegenConstants.JSON_PATH_LOCATION_TYPE, HashMap<String, String>> jsonPathDocTemplateFiles();
167174

168175
Set<String> pathEndpointTestTemplateFiles();
169176

170-
Set<String> pathEndpointDocTemplateFiles();
171-
172177
Map<String, String> apiTestTemplateFiles();
173178

174179
Map<String, String> modelTestTemplateFiles();
175180

176-
Map<String, String> apiDocTemplateFiles();
177-
178181
Set<String> languageSpecificPrimitives();
179182

180183
Map<String, String> reservedWordsMappings();
@@ -209,6 +212,10 @@ public interface CodegenConfig {
209212

210213
String toSecuritySchemeFilename(String baseName);
211214

215+
String toServerFilename(String baseName);
216+
217+
String getCamelCaseServer(String baseName);
218+
212219
String toModelImport(String refClass);
213220

214221
Map<String, String> toModelImportMap(String name);
@@ -225,8 +232,6 @@ public interface CodegenConfig {
225232

226233
TreeMap<String, CodegenSchema> postProcessModels(TreeMap<String, CodegenSchema> models);
227234

228-
OperationsMap postProcessOperationsWithModels(OperationsMap operations, TreeMap<String, CodegenSchema> schemas);
229-
230235
Map<String, Object> postProcessSupportingFileData(Map<String, Object> data);
231236

232237
void postProcessModelProperty(CodegenSchema model, CodegenSchema property);
@@ -236,12 +241,8 @@ public interface CodegenConfig {
236241

237242
String getDocsFilepath(String jsonPath);
238243

239-
String apiFilename(String templateName, String tag);
240-
241244
String apiTestFilename(String templateName, String tag);
242245

243-
String apiDocFilename(String templateName, String tag);
244-
245246
boolean isSkipOverwrite();
246247

247248
void setSkipOverwrite(boolean skipOverwrite);

modules/openapi-json-schema-generator/src/main/java/org/openapijsonschematools/codegen/CodegenConstants.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
public class CodegenConstants {
2424
/* System Properties */
2525
// NOTE: We may want to move these to a separate class to avoid confusion or modification.
26+
public static final String SERVERS = "servers";
2627
public static final String APIS = "apis";
2728
public static final String MODELS = "models";
2829
public static final String CONTENT = "content";
@@ -242,7 +243,7 @@ public class CodegenConstants {
242243

243244
public static enum PARAM_NAMING_TYPE {camelCase, PascalCase, snake_case, original}
244245

245-
public static enum JSON_PATH_LOCATION_TYPE {SCHEMA, REQUEST_BODY, PARAMETER, RESPONSE, HEADER, CONTENT, CONTENT_TYPE, HEADERS, PARAMETERS, RESPONSES, REQUEST_BODIES, SCHEMAS, PATHS, PATH, COMPONENTS, OPERATION, SECURITY_SCHEMES, SECURITY_SCHEME}
246+
public static enum JSON_PATH_LOCATION_TYPE {SCHEMA, REQUEST_BODY, PARAMETER, RESPONSE, HEADER, CONTENT, CONTENT_TYPE, HEADERS, PARAMETERS, RESPONSES, REQUEST_BODIES, SCHEMAS, PATHS, PATH, COMPONENTS, OPERATION, SECURITY_SCHEMES, SECURITY_SCHEME, SERVERS, SERVER, API_ROOT_FOLDER, API_PATH, API_TAG, API_PATHS, API_TAGS}
246247

247248
public static enum MODEL_PROPERTY_NAMING_TYPE {camelCase, PascalCase, snake_case, original}
248249

0 commit comments

Comments
 (0)