@f3liz/rescript-autogen-openapi 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,16 +20,14 @@ let docComment = `{{#if summary}}// {{{summary}}}
20
20
  {{/if}}{{#if description}}// {{{description}}}
21
21
  {{/if}}`;
22
22
 
23
- let endpointFunction = `{{{docComment}}}let {{{functionName}}} = ({{{bodyParam}}}{{{paramSep}}}~fetch: {{{fetchTypeSignature}}}): promise<{{{functionName}}}Response> => {
23
+ let endpointFunction = `{{{docComment}}}let {{{functionName}}} = async ({{{bodyParam}}}{{{paramSep}}}~fetch: {{{fetchTypeSignature}}}): {{{functionName}}}Response => {
24
24
  {{{bodyValueConversion}}}
25
- fetch(
25
+ let response = await fetch(
26
26
  ~url="{{{path}}}",
27
27
  ~method_="{{{methodUpper}}}",
28
28
  ~body={{{bodyArg}}},
29
- )->Promise.then(response => {
29
+ )
30
30
  {{{responseHandling}}}
31
- ->Promise.resolve
32
- })
33
31
  }`;
34
32
 
35
33
  let moduleWrapped = `{{{header}}}
@@ -58,9 +58,9 @@ function generateEndpointFunction(endpoint, overrideDir, moduleName) {
58
58
  "202",
59
59
  "204"
60
60
  ], code => endpoint.responses[code])[0];
61
- let responseHandling = Stdlib_Option.mapOr(successResponse, " response", response => Stdlib_Option.mapOr(response.content, " let _ = response\n ()", content => {
61
+ let responseHandling = Stdlib_Option.mapOr(successResponse, " response", response => Stdlib_Option.mapOr(response.content, " let _ = response", content => {
62
62
  if (Object.entries(content).length !== 0) {
63
- return ` let value = response->S.parseOrThrow(` + functionName + `ResponseSchema)\n value`;
63
+ return ` response->S.parseOrThrow(` + functionName + `ResponseSchema)`;
64
64
  } else {
65
65
  return " response";
66
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@f3liz/rescript-autogen-openapi",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Generate ReScript code with Sury schemas from OpenAPI 3.1 specs. Supports multiple forks with diff/merge capabilities.",
5
5
  "keywords": [
6
6
  "rescript",
@@ -25,16 +25,14 @@ let docComment = `{{#if summary}}// {{{summary}}}
25
25
 
26
26
  // === EndpointGenerator ===
27
27
 
28
- let endpointFunction = `{{{docComment}}}let {{{functionName}}} = ({{{bodyParam}}}{{{paramSep}}}~fetch: {{{fetchTypeSignature}}}): promise<{{{functionName}}}Response> => {
28
+ let endpointFunction = `{{{docComment}}}let {{{functionName}}} = async ({{{bodyParam}}}{{{paramSep}}}~fetch: {{{fetchTypeSignature}}}): {{{functionName}}}Response => {
29
29
  {{{bodyValueConversion}}}
30
- fetch(
30
+ let response = await fetch(
31
31
  ~url="{{{path}}}",
32
32
  ~method_="{{{methodUpper}}}",
33
33
  ~body={{{bodyArg}}},
34
- )->Promise.then(response => {
34
+ )
35
35
  {{{responseHandling}}}
36
- ->Promise.resolve
37
- })
38
36
  }`
39
37
 
40
38
  let moduleWrapped = `{{{header}}}
@@ -53,9 +53,9 @@ let generateEndpointFunction = (endpoint: endpoint, ~overrideDir=?, ~moduleName=
53
53
  ->Array.get(0)
54
54
 
55
55
  let responseHandling = successResponse->Option.mapOr(" response", response =>
56
- response.content->Option.mapOr(" let _ = response\n ()", content =>
56
+ response.content->Option.mapOr(" let _ = response", content =>
57
57
  Dict.toArray(content)->Array.length > 0
58
- ? ` let value = response->S.parseOrThrow(${functionName}ResponseSchema)\n value`
58
+ ? ` response->S.parseOrThrow(${functionName}ResponseSchema)`
59
59
  : " response"
60
60
  )
61
61
  )