diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJuliaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJuliaCodegen.java
index 728b5160d767..6fec46385629 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJuliaCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJuliaCodegen.java
@@ -422,7 +422,7 @@ public abstract class AbstractJuliaCodegen extends DefaultCodegen {
} else if (ModelUtils.isIntegerSchema(schema) || ModelUtils.isLongSchema(schema) || ModelUtils.isNumberSchema(schema)) {
return schema.getDefault().toString();
} else if (ModelUtils.isStringSchema(schema)) {
- String _default = (String) schema.getDefault();
+ String _default = String.valueOf(schema.getDefault());
return "\"" + _default + "\"";
}
}
diff --git a/modules/openapi-generator/src/test/resources/3_0/julia/petstore.yaml b/modules/openapi-generator/src/test/resources/3_0/julia/petstore.yaml
index 0c94c44ac167..826074f7a374 100644
--- a/modules/openapi-generator/src/test/resources/3_0/julia/petstore.yaml
+++ b/modules/openapi-generator/src/test/resources/3_0/julia/petstore.yaml
@@ -569,6 +569,26 @@ paths:
description: User not found
security:
- api_key: []
+ /fake/uuid_default_value_test:
+ get:
+ tags:
+ - fake
+ summary: test uuid default value
+ description: test uuid default value
+ operationId: uuid_default_value
+ parameters:
+ - name: uuid_parameter
+ in: header
+ description: test uuid default value
+ required: true
+ schema:
+ type: string
+ format: uuid
+ responses:
+ '400':
+ description: Invalid username supplied
+ '404':
+ description: User not found
externalDocs:
description: Find out more about Swagger
url: 'http://swagger.io'
@@ -746,3 +766,7 @@ components:
another_property:
type: integer
format: int32
+ uuid_default_value:
+ type: string
+ format: uuid
+ default: 1111-2222-3333-4444
diff --git a/samples/client/petstore/julia/.openapi-generator/FILES b/samples/client/petstore/julia/.openapi-generator/FILES
index 678cb05e38de..0fd28f028701 100644
--- a/samples/client/petstore/julia/.openapi-generator/FILES
+++ b/samples/client/petstore/julia/.openapi-generator/FILES
@@ -1,6 +1,7 @@
README.md
docs/ApiResponse.md
docs/Category.md
+docs/FakeApi.md
docs/MappedModel.md
docs/Order.md
docs/Pet.md
@@ -10,6 +11,7 @@ docs/Tag.md
docs/User.md
docs/UserApi.md
src/OpenAPIGenPetStoreClient.jl
+src/apis/api_FakeApi.jl
src/apis/api_PetApi.jl
src/apis/api_StoreApi.jl
src/apis/api_UserApi.jl
diff --git a/samples/client/petstore/julia/README.md b/samples/client/petstore/julia/README.md
index 741d292ef0cf..5cd5be5bbf72 100644
--- a/samples/client/petstore/julia/README.md
+++ b/samples/client/petstore/julia/README.md
@@ -20,6 +20,7 @@ Documentation is also embedded in Julia which can be used with a Julia specific
Class | Method
------------ | -------------
+*FakeApi* | [**uuid_default_value**](docs/FakeApi.md#uuid_default_value)
**GET** /fake/uuid_default_value_test
test uuid default value
*PetApi* | [**add_pet**](docs/PetApi.md#add_pet)
**POST** /pet
Add a new pet to the store
*PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet)
**DELETE** /pet/{petId}
Deletes a pet
*PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status)
**GET** /pet/findByStatus
Finds Pets by status
diff --git a/samples/client/petstore/julia/docs/FakeApi.md b/samples/client/petstore/julia/docs/FakeApi.md
new file mode 100644
index 000000000000..fbba161f3aaa
--- /dev/null
+++ b/samples/client/petstore/julia/docs/FakeApi.md
@@ -0,0 +1,39 @@
+# FakeApi
+
+All URIs are relative to *http://petstore.swagger.io/v2*
+
+Method | HTTP request | Description
+------------- | ------------- | -------------
+[**uuid_default_value**](FakeApi.md#uuid_default_value) | **GET** /fake/uuid_default_value_test | test uuid default value
+
+
+# **uuid_default_value**
+> uuid_default_value(_api::FakeApi, uuid_parameter::String; _mediaType=nothing) -> Nothing, OpenAPI.Clients.ApiResponse
+> uuid_default_value(_api::FakeApi, response_stream::Channel, uuid_parameter::String; _mediaType=nothing) -> Channel{ Nothing }, OpenAPI.Clients.ApiResponse
+
+test uuid default value
+
+test uuid default value
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **_api** | **FakeApi** | API context |
+**uuid_parameter** | **String**| test uuid default value | [default to nothing]
+
+### Return type
+
+Nothing
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: Not defined
+
+[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
+
diff --git a/samples/client/petstore/julia/docs/MappedModel.md b/samples/client/petstore/julia/docs/MappedModel.md
index 3d9632d852d8..4d3ff25fecc1 100644
--- a/samples/client/petstore/julia/docs/MappedModel.md
+++ b/samples/client/petstore/julia/docs/MappedModel.md
@@ -5,6 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**mappedProperty** | **Int64** | | [optional] [default to nothing]
+**uuid_default_value** | **String** | | [optional] [default to nothing]
[[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md)
diff --git a/samples/client/petstore/julia/src/OpenAPIGenPetStoreClient.jl b/samples/client/petstore/julia/src/OpenAPIGenPetStoreClient.jl
index 23c04145c824..9f15c32588da 100644
--- a/samples/client/petstore/julia/src/OpenAPIGenPetStoreClient.jl
+++ b/samples/client/petstore/julia/src/OpenAPIGenPetStoreClient.jl
@@ -11,6 +11,7 @@ const API_VERSION = "1.0.0"
include("modelincludes.jl")
+include("apis/api_FakeApi.jl")
include("apis/api_PetApi.jl")
include("apis/api_StoreApi.jl")
include("apis/api_UserApi.jl")
@@ -25,6 +26,7 @@ export Tag
export User
# export operations
+export FakeApi
export PetApi
export StoreApi
export UserApi
diff --git a/samples/client/petstore/julia/src/apis/api_FakeApi.jl b/samples/client/petstore/julia/src/apis/api_FakeApi.jl
new file mode 100644
index 000000000000..11eff8e716c2
--- /dev/null
+++ b/samples/client/petstore/julia/src/apis/api_FakeApi.jl
@@ -0,0 +1,46 @@
+# This file was generated by the Julia OpenAPI Code Generator
+# Do not modify this file directly. Modify the OpenAPI specification instead.
+
+struct FakeApi <: OpenAPI.APIClientImpl
+ client::OpenAPI.Clients.Client
+end
+
+"""
+The default API base path for APIs in `FakeApi`.
+This can be used to construct the `OpenAPI.Clients.Client` instance.
+"""
+basepath(::Type{ FakeApi }) = "http://petstore.swagger.io/v2"
+
+const _returntypes_uuid_default_value_FakeApi = Dict{Regex,Type}(
+ Regex("^" * replace("400", "x"=>".") * "\$") => Nothing,
+ Regex("^" * replace("404", "x"=>".") * "\$") => Nothing,
+)
+
+function _oacinternal_uuid_default_value(_api::FakeApi, uuid_parameter::String; _mediaType=nothing)
+ _ctx = OpenAPI.Clients.Ctx(_api.client, "GET", _returntypes_uuid_default_value_FakeApi, "/fake/uuid_default_value_test", [])
+ OpenAPI.Clients.set_param(_ctx.header, "uuid_parameter", uuid_parameter) # type String
+ OpenAPI.Clients.set_header_accept(_ctx, [])
+ OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? [] : [_mediaType])
+ return _ctx
+end
+
+@doc raw"""test uuid default value
+
+test uuid default value
+
+Params:
+- uuid_parameter::String (required)
+
+Return: Nothing, OpenAPI.Clients.ApiResponse
+"""
+function uuid_default_value(_api::FakeApi, uuid_parameter::String; _mediaType=nothing)
+ _ctx = _oacinternal_uuid_default_value(_api, uuid_parameter; _mediaType=_mediaType)
+ return OpenAPI.Clients.exec(_ctx)
+end
+
+function uuid_default_value(_api::FakeApi, response_stream::Channel, uuid_parameter::String; _mediaType=nothing)
+ _ctx = _oacinternal_uuid_default_value(_api, uuid_parameter; _mediaType=_mediaType)
+ return OpenAPI.Clients.exec(_ctx, response_stream)
+end
+
+export uuid_default_value
diff --git a/samples/client/petstore/julia/src/models/model_MappedModel.jl b/samples/client/petstore/julia/src/models/model_MappedModel.jl
index a720b1425893..94bf2fe52a1b 100644
--- a/samples/client/petstore/julia/src/models/model_MappedModel.jl
+++ b/samples/client/petstore/julia/src/models/model_MappedModel.jl
@@ -7,20 +7,24 @@ to test mapping features
MappedModel(;
mappedProperty=nothing,
+ uuid_default_value=nothing,
)
- mappedProperty::Int64
+ - uuid_default_value::String
"""
Base.@kwdef mutable struct MappedModel <: OpenAPI.APIModel
mappedProperty::Union{Nothing, Int64} = nothing
+ uuid_default_value::Union{Nothing, String} = nothing
- function MappedModel(mappedProperty, )
+ function MappedModel(mappedProperty, uuid_default_value, )
OpenAPI.validate_property(MappedModel, Symbol("another_property"), mappedProperty)
- return new(mappedProperty, )
+ OpenAPI.validate_property(MappedModel, Symbol("uuid_default_value"), uuid_default_value)
+ return new(mappedProperty, uuid_default_value, )
end
end # type MappedModel
-const _property_types_MappedModel = Dict{Symbol,String}(Symbol("another_property")=>"Int64", )
+const _property_types_MappedModel = Dict{Symbol,String}(Symbol("another_property")=>"Int64", Symbol("uuid_default_value")=>"String", )
OpenAPI.property_type(::Type{ MappedModel }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_MappedModel[name]))}
function check_required(o::MappedModel)
@@ -31,4 +35,7 @@ function OpenAPI.validate_property(::Type{ MappedModel }, name::Symbol, val)
if name === Symbol("another_property")
OpenAPI.validate_param(name, "MappedModel", :format, val, "int32")
end
+ if name === Symbol("uuid_default_value")
+ OpenAPI.validate_param(name, "MappedModel", :format, val, "uuid")
+ end
end
diff --git a/samples/server/petstore/julia/.openapi-generator/FILES b/samples/server/petstore/julia/.openapi-generator/FILES
index 4d1221f98b9a..c712606f5235 100644
--- a/samples/server/petstore/julia/.openapi-generator/FILES
+++ b/samples/server/petstore/julia/.openapi-generator/FILES
@@ -2,6 +2,7 @@ README.md
docs/AnotherModel.md
docs/ApiResponse.md
docs/Category.md
+docs/FakeApi.md
docs/Order.md
docs/Pet.md
docs/PetApi.md
@@ -10,6 +11,7 @@ docs/Tag.md
docs/User.md
docs/UserApi.md
src/OpenAPIGenPetStoreServer.jl
+src/apis/api_FakeApi.jl
src/apis/api_PetApi.jl
src/apis/api_StoreApi.jl
src/apis/api_UserApi.jl
diff --git a/samples/server/petstore/julia/README.md b/samples/server/petstore/julia/README.md
index 453d687742fe..79b0a50917dc 100644
--- a/samples/server/petstore/julia/README.md
+++ b/samples/server/petstore/julia/README.md
@@ -41,6 +41,7 @@ The following server methods must be implemented:
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
+*FakeApi* | [**uuid_default_value**](docs/FakeApi.md#uuid_default_value) | **GET** /fake/uuid_default_value_test | test uuid default value
*PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store
*PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet
*PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status
diff --git a/samples/server/petstore/julia/docs/AnotherModel.md b/samples/server/petstore/julia/docs/AnotherModel.md
index 97cd056157f5..3fc35e1b3606 100644
--- a/samples/server/petstore/julia/docs/AnotherModel.md
+++ b/samples/server/petstore/julia/docs/AnotherModel.md
@@ -5,6 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**another_property** | **Int64** | | [optional] [default to nothing]
+**uuid_default_value** | **String** | | [optional] [default to nothing]
[[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md)
diff --git a/samples/server/petstore/julia/docs/FakeApi.md b/samples/server/petstore/julia/docs/FakeApi.md
new file mode 100644
index 000000000000..4a605399a3dc
--- /dev/null
+++ b/samples/server/petstore/julia/docs/FakeApi.md
@@ -0,0 +1,38 @@
+# FakeApi
+
+All URIs are relative to *http://petstore.swagger.io/v2*
+
+Method | HTTP request | Description
+------------- | ------------- | -------------
+[**uuid_default_value**](FakeApi.md#uuid_default_value) | **GET** /fake/uuid_default_value_test | test uuid default value
+
+
+# **uuid_default_value**
+> uuid_default_value(req::HTTP.Request, uuid_parameter::String;) -> Nothing
+
+test uuid default value
+
+test uuid default value
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **req** | **HTTP.Request** | The HTTP Request object |
+**uuid_parameter** | **String**| test uuid default value | [default to nothing]
+
+### Return type
+
+Nothing
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: Not defined
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
diff --git a/samples/server/petstore/julia/src/OpenAPIGenPetStoreServer.jl b/samples/server/petstore/julia/src/OpenAPIGenPetStoreServer.jl
index e399bf6bdfca..ecf97ffead3b 100644
--- a/samples/server/petstore/julia/src/OpenAPIGenPetStoreServer.jl
+++ b/samples/server/petstore/julia/src/OpenAPIGenPetStoreServer.jl
@@ -7,6 +7,9 @@ Encapsulates generated server code for OpenAPIGenPetStoreServer
The following server methods must be implemented:
+- **uuid_default_value**
+ - *invocation:* GET /fake/uuid_default_value_test
+ - *signature:* uuid_default_value(req::HTTP.Request, uuid_parameter::String;) -> Nothing
- **add_pet**
- *invocation:* POST /pet
- *signature:* add_pet(req::HTTP.Request, pet::Pet;) -> Pet
@@ -81,6 +84,7 @@ const API_VERSION = "1.0.0"
include("modelincludes.jl")
+include("apis/api_FakeApi.jl")
include("apis/api_PetApi.jl")
include("apis/api_StoreApi.jl")
include("apis/api_UserApi.jl")
@@ -106,6 +110,7 @@ The order in which middlewares are invoked are:
`init |> read |> pre_validation |> validate |> pre_invoke |> invoke |> post_invoke`
"""
function register(router::HTTP.Router, impl; path_prefix::String="", optional_middlewares...)
+ registerFakeApi(router, impl; path_prefix=path_prefix, optional_middlewares...)
registerPetApi(router, impl; path_prefix=path_prefix, optional_middlewares...)
registerStoreApi(router, impl; path_prefix=path_prefix, optional_middlewares...)
registerUserApi(router, impl; path_prefix=path_prefix, optional_middlewares...)
diff --git a/samples/server/petstore/julia/src/apis/api_FakeApi.jl b/samples/server/petstore/julia/src/apis/api_FakeApi.jl
new file mode 100644
index 000000000000..d4bce31b9490
--- /dev/null
+++ b/samples/server/petstore/julia/src/apis/api_FakeApi.jl
@@ -0,0 +1,37 @@
+# This file was generated by the Julia OpenAPI Code Generator
+# Do not modify this file directly. Modify the OpenAPI specification instead.
+
+
+function uuid_default_value_read(handler)
+ function uuid_default_value_read_handler(req::HTTP.Request)
+ openapi_params = Dict{String,Any}()
+ headers = Dict{String,String}(HTTP.headers(req))
+ openapi_params["uuid_parameter"] = OpenAPI.Servers.to_param(String, headers, "uuid_parameter", required=true, )
+ req.context[:openapi_params] = openapi_params
+
+ return handler(req)
+ end
+end
+
+function uuid_default_value_validate(handler)
+ function uuid_default_value_validate_handler(req::HTTP.Request)
+ openapi_params = req.context[:openapi_params]
+
+ return handler(req)
+ end
+end
+
+function uuid_default_value_invoke(impl; post_invoke=nothing)
+ function uuid_default_value_invoke_handler(req::HTTP.Request)
+ openapi_params = req.context[:openapi_params]
+ ret = impl.uuid_default_value(req::HTTP.Request, openapi_params["uuid_parameter"];)
+ resp = OpenAPI.Servers.server_response(ret)
+ return (post_invoke === nothing) ? resp : post_invoke(req, resp)
+ end
+end
+
+
+function registerFakeApi(router::HTTP.Router, impl; path_prefix::String="", optional_middlewares...)
+ HTTP.register!(router, "GET", path_prefix * "/fake/uuid_default_value_test", OpenAPI.Servers.middleware(impl, uuid_default_value_read, uuid_default_value_validate, uuid_default_value_invoke; optional_middlewares...))
+ return router
+end
diff --git a/samples/server/petstore/julia/src/models/model_AnotherModel.jl b/samples/server/petstore/julia/src/models/model_AnotherModel.jl
index 7e9980bd8946..e5235e2e4be0 100644
--- a/samples/server/petstore/julia/src/models/model_AnotherModel.jl
+++ b/samples/server/petstore/julia/src/models/model_AnotherModel.jl
@@ -7,20 +7,24 @@ to test mapping features
AnotherModel(;
another_property=nothing,
+ uuid_default_value=nothing,
)
- another_property::Int64
+ - uuid_default_value::String
"""
Base.@kwdef mutable struct AnotherModel <: OpenAPI.APIModel
another_property::Union{Nothing, Int64} = nothing
+ uuid_default_value::Union{Nothing, String} = nothing
- function AnotherModel(another_property, )
+ function AnotherModel(another_property, uuid_default_value, )
OpenAPI.validate_property(AnotherModel, Symbol("another_property"), another_property)
- return new(another_property, )
+ OpenAPI.validate_property(AnotherModel, Symbol("uuid_default_value"), uuid_default_value)
+ return new(another_property, uuid_default_value, )
end
end # type AnotherModel
-const _property_types_AnotherModel = Dict{Symbol,String}(Symbol("another_property")=>"Int64", )
+const _property_types_AnotherModel = Dict{Symbol,String}(Symbol("another_property")=>"Int64", Symbol("uuid_default_value")=>"String", )
OpenAPI.property_type(::Type{ AnotherModel }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_AnotherModel[name]))}
function check_required(o::AnotherModel)
@@ -31,4 +35,7 @@ function OpenAPI.validate_property(::Type{ AnotherModel }, name::Symbol, val)
if name === Symbol("another_property")
OpenAPI.validate_param(name, "AnotherModel", :format, val, "int32")
end
+ if name === Symbol("uuid_default_value")
+ OpenAPI.validate_param(name, "AnotherModel", :format, val, "uuid")
+ end
end