mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 11:23:58 +00:00
merged
This commit is contained in:
commit
fd928a3d16
@ -730,11 +730,11 @@ public class DefaultCodegen {
|
||||
for(String key: operation.getConsumes()) {
|
||||
Map<String, String> mediaType = new HashMap<String, String>();
|
||||
mediaType.put("mediaType", key);
|
||||
count += 1;
|
||||
if (count < operation.getConsumes().size())
|
||||
mediaType.put("hasMore", "true");
|
||||
else
|
||||
mediaType.put("hasMore", null);
|
||||
count += 1;
|
||||
c.add(mediaType);
|
||||
}
|
||||
op.consumes = c;
|
||||
|
@ -167,6 +167,9 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
operation.put("classVarName", config.toApiVarName(tag));
|
||||
operation.put("importPath", config.toApiImport(tag));
|
||||
|
||||
processMimeTypes(swagger.getConsumes(), operation, "consumes");
|
||||
processMimeTypes(swagger.getProduces(), operation, "produces");
|
||||
|
||||
allOperations.add(new HashMap<String, Object>(operation));
|
||||
for (int i = 0; i < allOperations.size(); i++) {
|
||||
Map<String, Object> oo = (Map<String, Object>) allOperations.get(i);
|
||||
@ -292,6 +295,28 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
return files;
|
||||
}
|
||||
|
||||
private void processMimeTypes(List<String> mimeTypeList, Map<String, Object> operation, String source) {
|
||||
if(mimeTypeList != null && mimeTypeList.size() > 0) {
|
||||
List<Map<String, String>> c = new ArrayList<Map<String, String>>();
|
||||
int count = 0;
|
||||
for(String key: mimeTypeList) {
|
||||
Map<String, String> mediaType = new HashMap<String, String>();
|
||||
mediaType.put("mediaType", key);
|
||||
count += 1;
|
||||
if (count < mimeTypeList.size()) {
|
||||
mediaType.put("hasMore", "true");
|
||||
}
|
||||
else {
|
||||
mediaType.put("hasMore", null);
|
||||
}
|
||||
c.add(mediaType);
|
||||
}
|
||||
operation.put(source, c);
|
||||
String flagFieldName = "has" + source.substring(0, 1).toUpperCase() + source.substring(1);
|
||||
operation.put(flagFieldName, true);
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, List<CodegenOperation>> processPaths(Map<String, Path> paths) {
|
||||
Map<String, List<CodegenOperation>> ops = new HashMap<String, List<CodegenOperation>>();
|
||||
|
||||
|
@ -21,6 +21,8 @@ import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.*;
|
||||
|
||||
@Path("/{{baseName}}")
|
||||
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
|
||||
{{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
|
||||
@com.wordnik.swagger.annotations.Api(value = "/{{baseName}}", description = "the {{baseName}} API")
|
||||
{{#operations}}
|
||||
public class {{classname}} {
|
||||
|
Loading…
Reference in New Issue
Block a user