Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/generators/aspnetcore.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ CONFIG OPTIONS for aspnetcore
sourceFolder
source folder for generated code (Default: src)

aspnetCoreVersion
ASP.NET Core version: 2.1 (default), 2.0 (deprecated) (Default: 2.1)

sortParamsByRequiredFlag
Sort method arguments to place required parameters before optional parameters. (Default: true)

Expand Down
3 changes: 3 additions & 0 deletions docs/generators/cpp-pistache-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ CONFIG OPTIONS for cpp-pistache-server
addExternalLibs
Add the Possibility to fetch and compile external Libraries needed by this Framework. (Default: true)

helpersPackage
Specify the package name to be used for the helpers (e.g. org.openapitools.server.helpers). (Default: org.openapitools.server.helpers)

Back to the [generators list](README.md)
3 changes: 3 additions & 0 deletions docs/generators/dart.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ CONFIG OPTIONS for dart
sourceFolder
source folder for generated code

supportDart2
support dart2 (Default: true)

Back to the [generators list](README.md)
5 changes: 5 additions & 0 deletions docs/generators/elm.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

CONFIG OPTIONS for elm

elmVersion
Elm version: 0.18, 0.19 (Default: 0.19)
0.19 - Elm 0.19
0.18 - Elm 0.18

Back to the [generators list](README.md)
7 changes: 5 additions & 2 deletions docs/generators/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ CONFIG OPTIONS for java
Use Play! Async HTTP client (Play WS API) (Default: false)

playVersion
Version of Play! Framework (possible values "play24", "play25")
Version of Play! Framework (possible values "play24", "play25" (default), "play26")

supportJava6
Whether to support Java6 with the Jersey1 library. (Default: false)
Expand All @@ -134,10 +134,13 @@ CONFIG OPTIONS for java
useRuntimeException
Use RuntimeException instead of Exception (Default: false)

feignVersion
Version of OpenFeign: '10.x', '9.x' (default) (Default: false)

library
library template (sub-template) to use (Default: okhttp-gson)
jersey1 - HTTP client: Jersey client 1.19.4. JSON processing: Jackson 2.8.9. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.
feign - HTTP client: OpenFeign 9.4.0. JSON processing: Jackson 2.8.9. Enable OpenFeign 10.0.1 using '-DuseFeign10=true'.
feign - HTTP client: OpenFeign 9.4.0. JSON processing: Jackson 2.8.9. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.x'
jersey2 - HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.8.9
okhttp-gson - HTTP client: OkHttp 2.7.5. JSON processing: Gson 2.8.1. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.
retrofit - HTTP client: OkHttp 2.7.5. JSON processing: Gson 2.3.1 (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.
Expand Down
2 changes: 1 addition & 1 deletion docs/generators/kotlin-spring.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ CONFIG OPTIONS for kotlin-spring
server title name or client service name (Default: OpenAPI Kotlin Spring)

basePackage
base package for generated code (Default: org.openapitools)
base package (invokerPackage) for generated code (Default: org.openapitools)

serverPort
configuration the port in which the sever is to run on (Default: 8080)
Expand Down
3 changes: 3 additions & 0 deletions docs/generators/spring.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ CONFIG OPTIONS for spring
responseWrapper
wrap the responses in given type (Future,Callable,CompletableFuture,ListenableFuture,DeferredResult,HystrixCommand,RxObservable,RxSingle or fully qualified type)

virtualService
Generates the virtual service. For more details refer - https://github.com/elan-venture/virtualan/wiki (Default: false)

useTags
use tags for creating interface and controller classnames (Default: false)

Expand Down
3 changes: 3 additions & 0 deletions docs/generators/typescript-angular.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,7 @@ CONFIG OPTIONS for typescript-angular
modelFileSuffix
The suffix of the file of the generated model (model<suffix>.ts). Default is ''.

fileNaming
Naming convention for the output files: 'camelCase', 'kebab-case'. Default is 'camelCase'.

Back to the [generators list](README.md)
Original file line number Diff line number Diff line change
Expand Up @@ -841,15 +841,14 @@ public String escapeReservedWord(String name) {
/**
* Return the name with escaped characters.
*
* @param name the name to be escaped
* @param charactersToAllow characters that are not escaped
* @param name the name to be escaped
* @param charactersToAllow characters that are not escaped
* @param appdendixToReplacement String to append to replaced characters.
* @return the escaped word
* <p>
* throws Runtime exception as word is not escaped properly.
* @deprecated since version 3.2.3, may be removed with the next major release (4.0)
* @see org.openapitools.codegen.utils.StringUtils#escape directly instead
*
* @deprecated since version 3.2.3, may be removed with the next major release (4.0)
*/
@Deprecated
public String escapeSpecialCharacters(String name, List<String> charactersToAllow, String appdendixToReplacement) {
Expand Down Expand Up @@ -1096,11 +1095,6 @@ public String generateExamplePath(String path, Operation operation) {
public String toInstantiationType(Schema schema) {
if (ModelUtils.isMapSchema(schema)) {
Schema additionalProperties = ModelUtils.getAdditionalProperties(schema);
String type = additionalProperties.getType();
if (null == type) {
LOGGER.error("No Type defined for Additional Property " + additionalProperties + "\n" //
+ "\tIn Property: " + schema);
}
String inner = getSchemaType(additionalProperties);
return instantiationTypes.get("map") + "<String, " + inner + ">";
} else if (ModelUtils.isArraySchema(schema)) {
Expand Down Expand Up @@ -2254,7 +2248,7 @@ public CodegenOperation fromOperation(String path,
}
operationId = removeNonNameElementToCamelCase(operationId);

if(path.startsWith("/")) {
if (path.startsWith("/")) {
op.path = path;
} else {
op.path = "/" + path;
Expand Down Expand Up @@ -2295,7 +2289,10 @@ public CodegenOperation fromOperation(String path,
op.responses.get(op.responses.size() - 1).hasMore = false;

if (methodResponse != null) {
final Schema responseSchema = ModelUtils.getSchemaFromResponse(methodResponse);
Schema responseSchema = ModelUtils.getSchemaFromResponse(methodResponse);
if (openAPI != null && openAPI.getComponents() != null) { // has models/aliases defined
responseSchema = ModelUtils.unaliasSchema(openAPI.getComponents().getSchemas(), responseSchema);
}
if (responseSchema != null) {
CodegenProperty cm = fromProperty("response", responseSchema);

Expand Down Expand Up @@ -2662,12 +2659,12 @@ public CodegenCallback fromCallback(String name, Callback callback, Map<String,
}

Stream.of(
Pair.of("get", pi.getGet()),
Pair.of("head", pi.getHead()),
Pair.of("put", pi.getPut()),
Pair.of("post", pi.getPost()),
Pair.of("delete", pi.getDelete()),
Pair.of("patch", pi.getPatch()),
Pair.of("get", pi.getGet()),
Pair.of("head", pi.getHead()),
Pair.of("put", pi.getPut()),
Pair.of("post", pi.getPost()),
Pair.of("delete", pi.getDelete()),
Pair.of("patch", pi.getPatch()),
Pair.of("options", pi.getOptions()))
.filter(p -> p.getValue() != null)
.forEach(p -> {
Expand All @@ -2676,7 +2673,7 @@ public CodegenCallback fromCallback(String name, Callback callback, Map<String,

boolean genId = op.getOperationId() == null;
if (genId) {
op.setOperationId(getOrGenerateOperationId(op, c.name+"_"+expression.replaceAll("\\{\\$.*}", ""), method));
op.setOperationId(getOrGenerateOperationId(op, c.name + "_" + expression.replaceAll("\\{\\$.*}", ""), method));
}

if (op.getExtensions() == null) {
Expand Down Expand Up @@ -3265,8 +3262,8 @@ private void addParentContainer(CodegenModel model, String name, Schema schema)
*
* @param word The word
* @return The underscored version of the word
* @deprecated since version 3.2.3, may be removed with the next major release (4.0)
* @see org.openapitools.codegen.utils.StringUtils#underscore
* @deprecated since version 3.2.3, may be removed with the next major release (4.0)
*/
@Deprecated
public static String underscore(String word) {
Expand All @@ -3278,8 +3275,8 @@ public static String underscore(String word) {
*
* @param word The word
* @return The dashized version of the word, e.g. "my-name"
* @deprecated since version 3.2.3, may be removed with the next major release (4.0)
* @see org.openapitools.codegen.utils.StringUtils#dashize
* @deprecated since version 3.2.3, may be removed with the next major release (4.0)
*/
@SuppressWarnings("static-method")
@Deprecated
Expand Down Expand Up @@ -3492,8 +3489,8 @@ protected String removeNonNameElementToCamelCase(final String name, final String
*
* @param word string to be camelize
* @return camelized string
* @deprecated since version 3.2.3, may be removed with the next major release (4.0)
* @see org.openapitools.codegen.utils.StringUtils#camelize(String)
* @deprecated since version 3.2.3, may be removed with the next major release (4.0)
*/
@Deprecated
public static String camelize(String word) {
Expand All @@ -3506,8 +3503,8 @@ public static String camelize(String word) {
* @param word string to be camelize
* @param lowercaseFirstLetter lower case for first letter if set to true
* @return camelized string
* @deprecated since version 3.2.3, may be removed with the next major release (4.0)
* @see org.openapitools.codegen.utils.StringUtils#camelize(String, boolean)
* @deprecated since version 3.2.3, may be removed with the next major release (4.0)
*/
@Deprecated
public static String camelize(String word, boolean lowercaseFirstLetter) {
Expand Down Expand Up @@ -4697,10 +4694,10 @@ private void setParameterNullable(CodegenParameter parameter, CodegenProperty pr
* Post-process the auto-generated file, e.g. using go-fmt to format the Go code. The file type can be "model-test",
* "model-doc", "model", "api", "api-test", "api-doc", "supporting-mustache", "supporting-common",
* "openapi-generator-ignore", "openapi-generator-version"
*
* <p>
* TODO: store these values in enum instead
*
* @param file file to be processed
* @param file file to be processed
* @param fileType file type
*/
public void postProcessFile(File file, String fileType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public static boolean isMapSchema(Schema schema) {
if (schema.getAdditionalProperties() instanceof Schema) {
return true;
}
if (schema.getAdditionalProperties() instanceof Boolean && (Boolean)schema.getAdditionalProperties()) {
if (schema.getAdditionalProperties() instanceof Boolean && (Boolean) schema.getAdditionalProperties()) {
return true;
}
return false;
Expand Down Expand Up @@ -638,21 +638,42 @@ private static Schema getSchemaFromContent(Content content) {
* Get the actual schema from aliases. If the provided schema is not an alias, the schema itself will be returned.
*
* @param allSchemas all schemas
* @param schema schema (alias or direct reference)
* @param schema schema (alias or direct reference)
* @return actual schema
*/
public static Schema unaliasSchema(Map<String, Schema> allSchemas, Schema schema) {
if (allSchemas == null || allSchemas.isEmpty()) {
LOGGER.warn("allSchemas cann't be null/empty in unaliasSchema. Returned 'schema'");
return schema;
}

if (schema != null && StringUtils.isNotEmpty(schema.get$ref())) {
Schema ref = allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref()));
if (ref == null) {
LOGGER.warn("{} is not defined", schema.get$ref());
return schema;
} else if (isObjectSchema(ref)) { // model
return schema;
} else if (isStringSchema(ref) && (ref.getEnum() != null && !ref.getEnum().isEmpty())) {
// top-level enum class
return schema;
} else if (isMapSchema(ref) || isArraySchema(ref) || isComposedSchema(ref)) { // map/array def should be created as models
} else if (isArraySchema(ref) || isComposedSchema(ref)) { // array def should be created as models
return schema;
} else if (isMapSchema(ref)) {
if (ref.getProperties() != null && !ref.getProperties().isEmpty()) // has properties
return schema; // treat it as model
else {
// treat it as a typical map
/* TODO unalias the map item if it's an alias
if (ref.getAdditionalProperties() != null) {

Schema innerSchema = (Schema) ref.getAdditionalProperties();
if (StringUtils.isNotEmpty(innerSchema.get$ref())) { // map item is a ref to something else
//Schema unaliasInnerSchema = unaliasSchema(allSchemas, allSchemas.get(ModelUtils.getSimpleRef(innerSchema.get$ref())));
//ref.setAdditionalProperties(unaliasInnerSchema);
}
}*/
return unaliasSchema(allSchemas, allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())));
}
} else if (isObjectSchema(ref)) { // model
return schema;
} else {
return unaliasSchema(allSchemas, allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())));
Expand All @@ -662,10 +683,10 @@ public static Schema unaliasSchema(Map<String, Schema> allSchemas, Schema schema
}

public static Schema getAdditionalProperties(Schema schema) {
if(schema.getAdditionalProperties() instanceof Schema) {
if (schema.getAdditionalProperties() instanceof Schema) {
return (Schema) schema.getAdditionalProperties();
}
if(schema.getAdditionalProperties() instanceof Boolean && (Boolean)schema.getAdditionalProperties()) {
if (schema.getAdditionalProperties() instanceof Boolean && (Boolean) schema.getAdditionalProperties()) {
return new ObjectSchema();
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Name | Type | Description | Notes
**MapMapOfString** | **Dictionary&lt;string, Dictionary&lt;string, string&gt;&gt;** | | [optional]
**MapOfEnumString** | **Dictionary&lt;string, string&gt;** | | [optional]
**DirectMap** | **Dictionary&lt;string, bool?&gt;** | | [optional]
**IndirectMap** | [**StringBooleanMap**](StringBooleanMap.md) | | [optional]
**IndirectMap** | **Dictionary&lt;string, bool?&gt;** | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public enum InnerEnum
/// <param name="mapOfEnumString">mapOfEnumString.</param>
/// <param name="directMap">directMap.</param>
/// <param name="indirectMap">indirectMap.</param>
public MapTest(Dictionary<string, Dictionary<string, string>> mapMapOfString = default(Dictionary<string, Dictionary<string, string>>), Dictionary<string, InnerEnum> mapOfEnumString = default(Dictionary<string, InnerEnum>), Dictionary<string, bool?> directMap = default(Dictionary<string, bool?>), StringBooleanMap indirectMap = default(StringBooleanMap))
public MapTest(Dictionary<string, Dictionary<string, string>> mapMapOfString = default(Dictionary<string, Dictionary<string, string>>), Dictionary<string, InnerEnum> mapOfEnumString = default(Dictionary<string, InnerEnum>), Dictionary<string, bool?> directMap = default(Dictionary<string, bool?>), Dictionary<string, bool?> indirectMap = default(Dictionary<string, bool?>))
{
this.MapMapOfString = mapMapOfString;
this.MapOfEnumString = mapOfEnumString;
Expand All @@ -88,7 +88,7 @@ public enum InnerEnum
/// Gets or Sets IndirectMap
/// </summary>
[DataMember(Name="indirect_map", EmitDefaultValue=false)]
public StringBooleanMap IndirectMap { get; set; }
public Dictionary<string, bool?> IndirectMap { get; set; }

/// <summary>
/// Returns the string presentation of the object
Expand Down Expand Up @@ -153,8 +153,8 @@ public bool Equals(MapTest input)
) &&
(
this.IndirectMap == input.IndirectMap ||
(this.IndirectMap != null &&
this.IndirectMap.Equals(input.IndirectMap))
this.IndirectMap != null &&
this.IndirectMap.SequenceEqual(input.IndirectMap)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,7 @@ data MapTest = MapTest
{ mapTestMapMapOfString :: !(Maybe (Map.Map String (Map.Map String Text))) -- ^ "map_map_of_string"
, mapTestMapOfEnumString :: !(Maybe (Map.Map String E'Inner)) -- ^ "map_of_enum_string"
, mapTestDirectMap :: !(Maybe (Map.Map String Bool)) -- ^ "direct_map"
, mapTestIndirectMap :: !(Maybe StringBooleanMap) -- ^ "indirect_map"
, mapTestIndirectMap :: !(Maybe (Map.Map String Bool)) -- ^ "indirect_map"
} deriving (P.Show, P.Eq, P.Typeable)

-- | FromJSON MapTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ mapTestDirectMapL f MapTest{..} = (\mapTestDirectMap -> MapTest { mapTestDirectM
{-# INLINE mapTestDirectMapL #-}

-- | 'mapTestIndirectMap' Lens
mapTestIndirectMapL :: Lens_' MapTest (Maybe StringBooleanMap)
mapTestIndirectMapL :: Lens_' MapTest (Maybe (Map.Map String Bool))
mapTestIndirectMapL f MapTest{..} = (\mapTestIndirectMap -> MapTest { mapTestIndirectMap, ..} ) <$> f mapTestIndirectMap
{-# INLINE mapTestIndirectMapL #-}

Expand Down
3 changes: 2 additions & 1 deletion samples/client/petstore/haskell-http-client/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1324,7 +1324,8 @@ components:
type: boolean
type: object
indirect_map:
$ref: '#/components/schemas/StringBooleanMap'
additionalProperties:
type: boolean
type: object
ArrayTest:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ instance Arbitrary MapTest where
<$> arbitrary -- mapTestMapMapOfString :: Maybe (Map.Map String (Map.Map String Text))
<*> arbitrary -- mapTestMapOfEnumString :: Maybe (Map.Map String Text)
<*> arbitrary -- mapTestDirectMap :: Maybe (Map.Map String Bool)
<*> arbitrary -- mapTestIndirectMap :: Maybe StringBooleanMap
<*> arbitrary -- mapTestIndirectMap :: Maybe (Map.Map String Bool)

instance Arbitrary MixedPropertiesAndAdditionalPropertiesClass where
arbitrary =
Expand Down
Loading