Skip to content

Commit

Permalink
[Julia] Fix error in server enum generation
Browse files Browse the repository at this point in the history
Fixed issue in enum generation for julia-server code.
An empty struct was generated, where it should have generated a type alias.
  • Loading branch information
tanmaykm committed Jul 12, 2023
1 parent ec63812 commit 7f37235
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
{{#models}}
{{#model}}
{{#isAlias}}
if !isdefined(@__MODULE__, :{{classname}})
const {{classname}} = {{dataType}}
else
@warn("Skipping redefinition of {{classname}} to {{dataType}}")
end
{{>partial_model_alias}}
{{/isAlias}}{{^isAlias}}{{#oneOf}}{{#-first}}
{{>partial_model_oneof}}
{{/-first}}{{/oneOf}}{{^oneOf}}{{#anyOf}}{{#-first}}
{{>partial_model_anyof}}
{{/-first}}{{/anyOf}}{{^anyOf}}
{{/-first}}{{/anyOf}}{{^anyOf}}{{#hasVars}}
{{>partial_model_single}}
{{/hasVars}}{{^hasVars}}
{{>partial_model_alias}}
{{/hasVars}}
{{/anyOf}}{{/oneOf}}{{/isAlias}}{{/model}}{{/models}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if !isdefined(@__MODULE__, :{{classname}})
const {{classname}} = {{dataType}}
else
@warn("Skipping redefinition of {{classname}} to {{dataType}}")
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{#anyOf}}{{#-first}}
@doc raw"""{{#description}}{{description}}
{{/description}}
@doc raw"""{{name}}{{#description}}
{{description}}{{/description}}

{{classname}}(; value=nothing)
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{#oneOf}}{{#-first}}
@doc raw"""{{#description}}{{description}}
{{/description}}
@doc raw"""{{name}}{{#description}}
{{description}}{{/description}}

{{classname}}(; value=nothing)
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@doc raw"""{{#description}}{{description}}
{{/description}}
@doc raw"""{{name}}{{#description}}
{{description}}{{/description}}

{{classname}}(;
{{#allVars}}
Expand Down Expand Up @@ -40,7 +40,7 @@ function OpenAPI.validate_property(::Type{ {{classname}} }, name::Symbol, val)
{{#allVars}}
{{#isEnum}}
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
{{/isEnum}}
{{^isEnum}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# 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(;
code=nothing,
Expand Down
3 changes: 2 additions & 1 deletion samples/server/petstore/julia/src/models/model_Category.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# 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(;
id=nothing,
Expand Down
3 changes: 2 additions & 1 deletion samples/server/petstore/julia/src/models/model_Order.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# 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(;
id=nothing,
Expand Down
3 changes: 2 additions & 1 deletion samples/server/petstore/julia/src/models/model_Pet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# 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(;
id=nothing,
Expand Down
3 changes: 2 additions & 1 deletion samples/server/petstore/julia/src/models/model_Tag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# 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(;
id=nothing,
Expand Down
3 changes: 2 additions & 1 deletion samples/server/petstore/julia/src/models/model_User.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# 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(;
id=nothing,
Expand Down

0 comments on commit 7f37235

Please sign in to comment.