forked from loafle/openapi-generator-original
[Julia] Fix error in server enum generation (#16079)
Fixed issue in enum generation for julia-server code. An empty struct was generated, where it should have generated a type alias.
This commit is contained in:
parent
ec6381295a
commit
c595a02b61
@ -2,15 +2,14 @@
|
|||||||
{{#models}}
|
{{#models}}
|
||||||
{{#model}}
|
{{#model}}
|
||||||
{{#isAlias}}
|
{{#isAlias}}
|
||||||
if !isdefined(@__MODULE__, :{{classname}})
|
{{>partial_model_alias}}
|
||||||
const {{classname}} = {{dataType}}
|
|
||||||
else
|
|
||||||
@warn("Skipping redefinition of {{classname}} to {{dataType}}")
|
|
||||||
end
|
|
||||||
{{/isAlias}}{{^isAlias}}{{#oneOf}}{{#-first}}
|
{{/isAlias}}{{^isAlias}}{{#oneOf}}{{#-first}}
|
||||||
{{>partial_model_oneof}}
|
{{>partial_model_oneof}}
|
||||||
{{/-first}}{{/oneOf}}{{^oneOf}}{{#anyOf}}{{#-first}}
|
{{/-first}}{{/oneOf}}{{^oneOf}}{{#anyOf}}{{#-first}}
|
||||||
{{>partial_model_anyof}}
|
{{>partial_model_anyof}}
|
||||||
{{/-first}}{{/anyOf}}{{^anyOf}}
|
{{/-first}}{{/anyOf}}{{^anyOf}}{{#hasVars}}
|
||||||
{{>partial_model_single}}
|
{{>partial_model_single}}
|
||||||
|
{{/hasVars}}{{^hasVars}}
|
||||||
|
{{>partial_model_alias}}
|
||||||
|
{{/hasVars}}
|
||||||
{{/anyOf}}{{/oneOf}}{{/isAlias}}{{/model}}{{/models}}
|
{{/anyOf}}{{/oneOf}}{{/isAlias}}{{/model}}{{/models}}
|
5
modules/openapi-generator/src/main/resources/julia-server/partial_model_alias.mustache
vendored
Normal file
5
modules/openapi-generator/src/main/resources/julia-server/partial_model_alias.mustache
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
if !isdefined(@__MODULE__, :{{classname}})
|
||||||
|
const {{classname}} = {{dataType}}
|
||||||
|
else
|
||||||
|
@warn("Skipping redefinition of {{classname}} to {{dataType}}")
|
||||||
|
end
|
@ -1,6 +1,6 @@
|
|||||||
{{#anyOf}}{{#-first}}
|
{{#anyOf}}{{#-first}}
|
||||||
@doc raw"""{{#description}}{{description}}
|
@doc raw"""{{name}}{{#description}}
|
||||||
{{/description}}
|
{{description}}{{/description}}
|
||||||
|
|
||||||
{{classname}}(; value=nothing)
|
{{classname}}(; value=nothing)
|
||||||
"""
|
"""
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{{#oneOf}}{{#-first}}
|
{{#oneOf}}{{#-first}}
|
||||||
@doc raw"""{{#description}}{{description}}
|
@doc raw"""{{name}}{{#description}}
|
||||||
{{/description}}
|
{{description}}{{/description}}
|
||||||
|
|
||||||
{{classname}}(; value=nothing)
|
{{classname}}(; value=nothing)
|
||||||
"""
|
"""
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
@doc raw"""{{#description}}{{description}}
|
@doc raw"""{{name}}{{#description}}
|
||||||
{{/description}}
|
{{description}}{{/description}}
|
||||||
|
|
||||||
{{classname}}(;
|
{{classname}}(;
|
||||||
{{#allVars}}
|
{{#allVars}}
|
||||||
@ -40,7 +40,7 @@ function OpenAPI.validate_property(::Type{ {{classname}} }, name::Symbol, val)
|
|||||||
{{#allVars}}
|
{{#allVars}}
|
||||||
{{#isEnum}}
|
{{#isEnum}}
|
||||||
if name === Symbol("{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}")
|
if name === Symbol("{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}")
|
||||||
OpenAPI.validate_param(name, "{{classname}}", :enum, val, [{{#allowableValues}}{{#values}}{{#isString}}"{{{this}}}"{{/isString}}{{^isString}}{{{this}}}{{/isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}])
|
OpenAPI.validate_param(name, "{{classname}}", :enum, val, [{{#_enum}}{{#isString}}"{{.}}"{{/isString}}{{^isString}}{{.}}{{/isString}}{{^-last}}, {{/-last}}{{/_enum}}])
|
||||||
end
|
end
|
||||||
{{/isEnum}}
|
{{/isEnum}}
|
||||||
{{^isEnum}}
|
{{^isEnum}}
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
# Do not modify this file directly. Modify the OpenAPI specification instead.
|
# Do not modify this file directly. Modify the OpenAPI specification instead.
|
||||||
|
|
||||||
|
|
||||||
@doc raw"""Describes the result of uploading an image resource
|
@doc raw"""ApiResponse
|
||||||
|
Describes the result of uploading an image resource
|
||||||
|
|
||||||
ApiResponse(;
|
ApiResponse(;
|
||||||
code=nothing,
|
code=nothing,
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
# Do not modify this file directly. Modify the OpenAPI specification instead.
|
# Do not modify this file directly. Modify the OpenAPI specification instead.
|
||||||
|
|
||||||
|
|
||||||
@doc raw"""A category for a pet
|
@doc raw"""Category
|
||||||
|
A category for a pet
|
||||||
|
|
||||||
Category(;
|
Category(;
|
||||||
id=nothing,
|
id=nothing,
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
# Do not modify this file directly. Modify the OpenAPI specification instead.
|
# Do not modify this file directly. Modify the OpenAPI specification instead.
|
||||||
|
|
||||||
|
|
||||||
@doc raw"""An order for a pets from the pet store
|
@doc raw"""Order
|
||||||
|
An order for a pets from the pet store
|
||||||
|
|
||||||
Order(;
|
Order(;
|
||||||
id=nothing,
|
id=nothing,
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
# Do not modify this file directly. Modify the OpenAPI specification instead.
|
# Do not modify this file directly. Modify the OpenAPI specification instead.
|
||||||
|
|
||||||
|
|
||||||
@doc raw"""A pet for sale in the pet store
|
@doc raw"""Pet
|
||||||
|
A pet for sale in the pet store
|
||||||
|
|
||||||
Pet(;
|
Pet(;
|
||||||
id=nothing,
|
id=nothing,
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
# Do not modify this file directly. Modify the OpenAPI specification instead.
|
# Do not modify this file directly. Modify the OpenAPI specification instead.
|
||||||
|
|
||||||
|
|
||||||
@doc raw"""A tag for a pet
|
@doc raw"""Tag
|
||||||
|
A tag for a pet
|
||||||
|
|
||||||
Tag(;
|
Tag(;
|
||||||
id=nothing,
|
id=nothing,
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
# Do not modify this file directly. Modify the OpenAPI specification instead.
|
# Do not modify this file directly. Modify the OpenAPI specification instead.
|
||||||
|
|
||||||
|
|
||||||
@doc raw"""A User who is purchasing from the pet store
|
@doc raw"""User
|
||||||
|
A User who is purchasing from the pet store
|
||||||
|
|
||||||
User(;
|
User(;
|
||||||
id=nothing,
|
id=nothing,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user