Skip to content

Commit 54645dd

Browse files
author
andrewwilsonnew
committed
first pass
1 parent 11c5611 commit 54645dd

1 file changed

Lines changed: 18 additions & 29 deletions

File tree

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinMiskServerCodegen.java

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
/*
2-
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* https://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
171
package org.openapitools.codegen.languages;
182

193
import lombok.Setter;
@@ -57,8 +41,7 @@ public class KotlinMiskServerCodegen extends AbstractKotlinCodegen implements Be
5741
protected String rootPackage = "org.openapitools.server.api";
5842
protected String apiVersion = "1.0.0-SNAPSHOT";
5943

60-
@Setter
61-
protected String moduleClassName = "OpenApiModule";
44+
@Setter protected String moduleClassName = "OpenApiModule";
6245

6346
@Override
6447
public CodegenType getTag() {
@@ -199,30 +182,36 @@ public boolean getUseBeanValidation() {
199182
}
200183

201184
private String mapMediaType(String mediaType) {
202-
return MEDIA_MAPPING.getOrDefault(mediaType, "MediaTypes.APPLICATION_OCTETSTREAM /* unknown -> " + mediaType + " */ ");
185+
return MEDIA_MAPPING.getOrDefault(mediaType, "MediaTypes.APPLICATION_OCTETSTREAM /* @todo(unknown) -> " + mediaType + " */ ");
203186
}
204187

205188
private final static Map<String, String> MEDIA_MAPPING = getMappings();
206189

207190
private static Map<String, String> getMappings() {
191+
// add new values in order
208192
Map<String, String> result = new HashMap<>();
209-
result.put("application/json", "MediaTypes.APPLICATION_JSON");
210-
result.put("application/xml", "MediaTypes.APPLICATION_XML");
211-
result.put("application/javascript", "MediaTypes.APPLICATION_JAVASCRIPT");
212193
result.put("*/*", "MediaTypes.ALL");
213-
result.put("application/x-www-form-urlencoded", "MediaTypes.APPLICATION_FORM_URLENCODED");
194+
195+
result.put("application/grpc", "MediaTypes.APPLICATION_GRPC");
196+
result.put("application/javascript", "MediaTypes.APPLICATION_JAVASCRIPT");
197+
result.put("application/json", "MediaTypes.APPLICATION_JSON");
214198
result.put("application/octetstream", "MediaTypes.APPLICATION_OCTETSTREAM");
215199
result.put("application/pdf", "MediaTypes.APPLICATION_OCTETSTREAM");
216200
result.put("application/x-protobuf", "MediaTypes.APPLICATION_PROTOBUF");
217-
result.put("application/grpc", "MediaTypes.APPLICATION_GRPC");
218-
result.put("text/css", "MediaTypes.TEXT_CSS");
219-
result.put("text/html", "MediaTypes.TEXT_HTML");
220-
result.put("text/plain", "MediaTypes.TEXT_PLAIN_UTF8");
201+
result.put("application/x-www-form-urlencoded", "MediaTypes.APPLICATION_FORM_URLENCODED");
202+
result.put("application/xml", "MediaTypes.APPLICATION_XML");
203+
result.put("application/zip", "MediaTypes.APPLICATION_ZIP");
204+
205+
result.put("image/gif", "MediaTypes.IMAGE_GIF");
206+
result.put("image/jpeg", "MediaTypes.IMAGE_JPEG");
221207
result.put("image/png", "MediaTypes.IMAGE_PNG");
222208
result.put("image/svg+xml", "MediaTypes.IMAGE_SVG");
223-
result.put("image/jpeg", "MediaTypes.IMAGE_JPEG");
224-
result.put("image/gif", "MediaTypes.IMAGE_GIF");
225209
result.put("image/x-icon", "MediaTypes.IMAGE_ICO");
210+
211+
result.put("text/css", "MediaTypes.TEXT_CSS");
212+
result.put("text/html", "MediaTypes.TEXT_HTML");
213+
result.put("text/plain", "MediaTypes.TEXT_PLAIN_UTF8");
214+
226215
return result;
227216
}
228217
}

0 commit comments

Comments
 (0)