Skip to content

generate erlang code after opt processing #8049

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ public ErlangServerCodegen() {
*/
additionalProperties.put("apiVersion", apiVersion);
additionalProperties.put("apiPath", apiPath);
}

@Override
public void processOpts() {
super.processOpts();

if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
}
/**
* Supporting Files. You can write single files for the generator with the
* entire object tree available. If the input file has a suffix of `.mustache
Expand Down Expand Up @@ -182,7 +191,7 @@ public String toApiName(String name) {
* @return the escaped term
*/
@Override
public String escapeReservedWord(String name) {
public String escapeReservedWord(String name) {
if(this.reservedWordsMappings().containsKey(name)) {
return this.reservedWordsMappings().get(name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ validation_error(ViolatedRule, Name, Info) ->
throw({wrong_param, Name, ViolatedRule, Info}).

-spec get_value(body | qs_val | header | binding, Name :: any(), Req0 :: cowboy_req:req()) ->
{Value :: any(), Req :: cowboy_req:req()} |
{Value :: any(), Req :: cowboy_req:req()} |
{error, Reason :: any(), Req :: cowboy_req:req()}.
get_value(body, _Name, Req0) ->
{ok, Body, Req} = cowboy_req:body(Req0),
Expand Down Expand Up @@ -328,7 +328,7 @@ prepare_body(Body) ->
<<"">> -> <<"">>;
_ ->
try
jsx:decode(Body, [return_maps])
jsx:decode(Body, [return_maps])
catch
error:_ ->
{error, {invalid_body, not_json, Body}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ authorize_api_key(LogicHandler, OperationID, From, KeyParam, Req0) ->
get_api_key(header, KeyParam, Req0) ->
{Headers, Req} = cowboy_req:headers(Req0),
{
swagger_utils:get_opt(
{{packageName}}_utils:get_opt(
{{packageName}}_utils:to_header(KeyParam),
Headers
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

-export_type([init_opts/0]).

-spec get_paths(LogicHandler :: atom()) -> [{'_',[{
-spec get_paths(LogicHandler :: atom()) -> [{'_', [{
Path :: string(),
Handler :: atom(),
InitOpts :: init_opts()
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.0
2.4.0-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.3-SNAPSHOT
2.4.0-SNAPSHOT
56 changes: 52 additions & 4 deletions samples/server/petstore/erlang-server/priv/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@
"type" : "array",
"items" : {
"type" : "string",
"enum" : [ "available", "pending", "sold" ],
"default" : "available"
"default" : "available",
"enum" : [ "available", "pending", "sold" ]
},
"collectionFormat" : "csv"
} ],
Expand Down Expand Up @@ -563,7 +563,7 @@
"parameters" : [ {
"name" : "username",
"in" : "path",
"description" : "The name that needs to be fetched. Use user1 for testing. ",
"description" : "The name that needs to be fetched. Use user1 for testing.",
"required" : true,
"type" : "string"
} ],
Expand Down Expand Up @@ -684,6 +684,14 @@
},
"title" : "Pet Order",
"description" : "An order for a pets from the pet store",
"example" : {
"petId" : 6,
"quantity" : 1,
"id" : 0,
"shipDate" : "2000-01-23T04:56:07.000+00:00",
"complete" : false,
"status" : "placed"
},
"xml" : {
"name" : "Order"
}
Expand All @@ -701,6 +709,10 @@
},
"title" : "Pet category",
"description" : "A category for a pet",
"example" : {
"name" : "name",
"id" : 6
},
"xml" : {
"name" : "Category"
}
Expand Down Expand Up @@ -738,6 +750,16 @@
},
"title" : "a User",
"description" : "A User who is purchasing from the pet store",
"example" : {
"firstName" : "firstName",
"lastName" : "lastName",
"password" : "password",
"userStatus" : 6,
"phone" : "phone",
"id" : 0,
"email" : "email",
"username" : "username"
},
"xml" : {
"name" : "User"
}
Expand All @@ -755,6 +777,10 @@
},
"title" : "Pet Tag",
"description" : "A tag for a pet",
"example" : {
"name" : "name",
"id" : 1
},
"xml" : {
"name" : "Tag"
}
Expand Down Expand Up @@ -802,6 +828,23 @@
},
"title" : "a Pet",
"description" : "A pet for sale in the pet store",
"example" : {
"photoUrls" : [ "photoUrls", "photoUrls" ],
"name" : "doggie",
"id" : 0,
"category" : {
"name" : "name",
"id" : 6
},
"tags" : [ {
"name" : "name",
"id" : 1
}, {
"name" : "name",
"id" : 1
} ],
"status" : "available"
},
"xml" : {
"name" : "Pet"
}
Expand All @@ -821,7 +864,12 @@
}
},
"title" : "An uploaded response",
"description" : "Describes the result of uploading an image resource"
"description" : "Describes the result of uploading an image resource",
"example" : {
"code" : 0,
"type" : "type",
"message" : "message"
}
}
},
"externalDocs" : {
Expand Down