Skip to content

Commit 1ba18a0

Browse files
authored
[Elm] Add missing operation summary (#20147)
* Add missing operation summary * Regenerate samples * Print notes and or summary if any exists * Regenerate clients
1 parent 23aa2e2 commit 1ba18a0

File tree

6 files changed

+71
-16
lines changed

6 files changed

+71
-16
lines changed

modules/openapi-generator/src/main/resources/elm/operation.mustache

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ import Json.Decode
1313
import Json.Encode{{#includeUuid}}
1414
import Uuid exposing (Uuid){{/includeUuid}}{{#includeFile}}
1515
import File exposing (File){{/includeFile}}
16+
1617
{{#operations}}
1718
{{#operation}}
1819
{{#allParams}}
1920
{{#isEnum}}
2021

21-
2222
{{>customType}}
2323

2424

@@ -28,12 +28,15 @@ import File exposing (File){{/includeFile}}
2828
{{/operation}}
2929
{{/operations}}
3030
{{#operations}}
31-
{{#operation}}
32-
31+
{{#operation}}{{#summary}}
32+
{-| {{{summary}}}
3333
{{#notes}}
34-
{-| {{{notes}}}
35-
-}
34+
35+
{{{notes}}}
36+
3637
{{/notes}}
38+
-}{{/summary}}{{^summary}}{{#notes}}{-| {{{notes}}}
39+
-}{{/notes}}{{/summary}}
3740
{{#lambda.removeWhitespace}}
3841
{{operationId}} : {{#allParams}}{{>operationParameter}} -> {{/allParams}}
3942
{{#authMethods}}{{#isBasicBearer}}String -> {{/isBasicBearer}}{{/authMethods}}Api.Request

samples/client/petstore/elm/src/Api/Request/Pet.elm

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ stringFromStatus model =
6161

6262

6363

64+
{-| Add a new pet to the store
65+
-}
6466
addPet : Api.Data.Pet -> Api.Request Api.Data.Pet
6567
addPet pet_body =
6668
Api.request
@@ -73,6 +75,8 @@ addPet pet_body =
7375
Api.Data.petDecoder
7476

7577

78+
{-| Deletes a pet
79+
-}
7680
deletePet : Int -> Maybe String -> Api.Request ()
7781
deletePet petId_path apiKey_header =
7882
Api.request
@@ -85,7 +89,10 @@ deletePet petId_path apiKey_header =
8589
(Json.Decode.succeed ())
8690

8791

88-
{-| Multiple status values can be provided with comma separated strings
92+
{-| Finds Pets by status
93+
94+
Multiple status values can be provided with comma separated strings
95+
8996
-}
9097
findPetsByStatus : List Status -> Api.Request (List Api.Data.Pet)
9198
findPetsByStatus status_query =
@@ -99,7 +106,10 @@ findPetsByStatus status_query =
99106
(Json.Decode.list Api.Data.petDecoder)
100107

101108

102-
{-| Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
109+
{-| Finds Pets by tags
110+
111+
Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
112+
103113
-}
104114
findPetsByTags : List String -> Api.Request (List Api.Data.Pet)
105115
findPetsByTags tags_query =
@@ -113,7 +123,10 @@ findPetsByTags tags_query =
113123
(Json.Decode.list Api.Data.petDecoder)
114124

115125

116-
{-| Returns a single pet
126+
{-| Find pet by ID
127+
128+
Returns a single pet
129+
117130
-}
118131
getPetById : Int -> Api.Request Api.Data.Pet
119132
getPetById petId_path =
@@ -127,6 +140,8 @@ getPetById petId_path =
127140
Api.Data.petDecoder
128141

129142

143+
{-| Update an existing pet
144+
-}
130145
updatePet : Api.Data.Pet -> Api.Request Api.Data.Pet
131146
updatePet pet_body =
132147
Api.request
@@ -139,6 +154,8 @@ updatePet pet_body =
139154
Api.Data.petDecoder
140155

141156

157+
{-| Updates a pet in the store with form data
158+
-}
142159
updatePetWithForm : Int -> Maybe String -> Maybe String -> Api.Request ()
143160
updatePetWithForm petId_path name status =
144161
Api.request
@@ -151,6 +168,8 @@ updatePetWithForm petId_path name status =
151168
(Json.Decode.succeed ())
152169

153170

171+
{-| uploads an image
172+
-}
154173
uploadFile : Int -> Maybe String -> Maybe File -> Api.Request Api.Data.ApiResponse
155174
uploadFile petId_path additionalMetadata file =
156175
Api.request

samples/client/petstore/elm/src/Api/Request/Store.elm

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ import Http
2727
import Json.Decode
2828
import Json.Encode
2929

30-
{-| For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
30+
31+
{-| Delete purchase order by ID
32+
33+
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
34+
3135
-}
3236
deleteOrder : String -> Api.Request ()
3337
deleteOrder orderId_path =
@@ -41,7 +45,10 @@ deleteOrder orderId_path =
4145
(Json.Decode.succeed ())
4246

4347

44-
{-| Returns a map of status codes to quantities
48+
{-| Returns pet inventories by status
49+
50+
Returns a map of status codes to quantities
51+
4552
-}
4653
getInventory : Api.Request (Dict.Dict String Int)
4754
getInventory =
@@ -55,7 +62,10 @@ getInventory =
5562
(Json.Decode.dict Json.Decode.int)
5663

5764

58-
{-| For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions
65+
{-| Find purchase order by ID
66+
67+
For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions
68+
5969
-}
6070
getOrderById : Int -> Api.Request Api.Data.Order_
6171
getOrderById orderId_path =
@@ -69,6 +79,8 @@ getOrderById orderId_path =
6979
Api.Data.orderDecoder
7080

7181

82+
{-| Place an order for a pet
83+
-}
7284
placeOrder : Api.Data.Order_ -> Api.Request Api.Data.Order_
7385
placeOrder order_body =
7486
Api.request

samples/client/petstore/elm/src/Api/Request/User.elm

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ import Http
3131
import Json.Decode
3232
import Json.Encode
3333

34-
{-| This can only be done by the logged in user.
34+
35+
{-| Create user
36+
37+
This can only be done by the logged in user.
38+
3539
-}
3640
createUser : Api.Data.User -> Api.Request ()
3741
createUser user_body =
@@ -45,6 +49,8 @@ createUser user_body =
4549
(Json.Decode.succeed ())
4650

4751

52+
{-| Creates list of users with given input array
53+
-}
4854
createUsersWithArrayInput : List Api.Data.User -> Api.Request ()
4955
createUsersWithArrayInput user_body =
5056
Api.request
@@ -57,6 +63,8 @@ createUsersWithArrayInput user_body =
5763
(Json.Decode.succeed ())
5864

5965

66+
{-| Creates list of users with given input array
67+
-}
6068
createUsersWithListInput : List Api.Data.User -> Api.Request ()
6169
createUsersWithListInput user_body =
6270
Api.request
@@ -69,7 +77,10 @@ createUsersWithListInput user_body =
6977
(Json.Decode.succeed ())
7078

7179

72-
{-| This can only be done by the logged in user.
80+
{-| Delete user
81+
82+
This can only be done by the logged in user.
83+
7384
-}
7485
deleteUser : String -> Api.Request ()
7586
deleteUser username_path =
@@ -83,6 +94,8 @@ deleteUser username_path =
8394
(Json.Decode.succeed ())
8495

8596

97+
{-| Get user by user name
98+
-}
8699
getUserByName : String -> Api.Request Api.Data.User
87100
getUserByName username_path =
88101
Api.request
@@ -95,6 +108,8 @@ getUserByName username_path =
95108
Api.Data.userDecoder
96109

97110

111+
{-| Logs user into the system
112+
-}
98113
loginUser : String -> String -> Api.Request String
99114
loginUser username_query password_query =
100115
Api.request
@@ -107,6 +122,8 @@ loginUser username_query password_query =
107122
Json.Decode.string
108123

109124

125+
{-| Logs out current logged in user session
126+
-}
110127
logoutUser : Api.Request ()
111128
logoutUser =
112129
Api.request
@@ -119,7 +136,10 @@ logoutUser =
119136
(Json.Decode.succeed ())
120137

121138

122-
{-| This can only be done by the logged in user.
139+
{-| Updated user
140+
141+
This can only be done by the logged in user.
142+
123143
-}
124144
updateUser : String -> Api.Data.User -> Api.Request ()
125145
updateUser username_path user_body =

samples/openapi3/client/elm/src/Api/Request/Default.elm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ stringFromHeaderType model =
5454

5555

5656

57-
5857
type Enumeration
5958
= EnumerationA
6059
| EnumerationB
@@ -83,7 +82,6 @@ stringFromEnumeration model =
8382

8483

8584

86-
8785
type Enum
8886
= EnumA
8987
| EnumB
@@ -160,6 +158,8 @@ queryGet string_query int_query enum_query =
160158
(Json.Decode.succeed ())
161159

162160

161+
{-| Secured endpoint
162+
-}
163163
securedPost : String -> Api.Request ()
164164
securedPost auth_token =
165165
Api.request

samples/openapi3/client/elm/src/Api/Request/Primitive.elm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import Http
2424
import Json.Decode
2525
import Json.Encode
2626

27+
2728
update : Api.Data.Primitive -> Api.Request Api.Data.Primitive
2829
update primitive_body =
2930
Api.request

0 commit comments

Comments
 (0)