[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:
Tanmay Mohapatra 2023-07-12 16:34:30 +05:30 committed by GitHub
parent ec6381295a
commit c595a02b61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 29 additions and 19 deletions

View File

@ -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}}

View File

@ -0,0 +1,5 @@
if !isdefined(@__MODULE__, :{{classname}})
const {{classname}} = {{dataType}}
else
@warn("Skipping redefinition of {{classname}} to {{dataType}}")
end

View File

@ -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)
""" """

View File

@ -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)
""" """

View File

@ -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}}

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,