Skip to content
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

transform api member comment to start newlines #60

Merged
merged 1 commit into from
Oct 28, 2024
Merged
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
1 change: 1 addition & 0 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ pkgs.mkShell {
ghc
cabal-install
ghcid
ormolu
];
}
14 changes: 13 additions & 1 deletion src/Tie/Codegen/Operation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module Tie.Codegen.Operation
where

import qualified Data.Map.Strict as Map
import qualified Debug.Trace
import Prettyprinter (Doc, (<+>))
import qualified Prettyprinter as PP
import qualified Prettyprinter.Render.Text as PP
Expand Down Expand Up @@ -185,7 +186,18 @@ codegenApiTypeOperation resolver Operation {..} = do
Nothing ->
"--" <+> "@" <> toParamName name <> "@" <> PP.line
Just comment ->
"--" <+> "@" <> toParamName name <> "@" <+> PP.pretty comment <> PP.line
"--"
<+> "@"
<> toParamName name
<> "@"
<> PP.line
<> codegenMultilineComment comment
<> PP.line

codegenMultilineComment :: Text -> Doc ann
codegenMultilineComment commentLines =
let comments = fmap ("-- " <>) $ lines commentLines
in PP.cat (fmap PP.pretty comments)

codegenRequestBodyComment RequestBody {description} = case description of
Nothing ->
Expand Down
47 changes: 47 additions & 0 deletions test/golden/description.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
openapi: "3.0.0"
info:
version: 1.0.0
title: Scarf
license:
name: AllRightsReserved
servers:
- url: https://scarf.sh/api/v1
paths:
/test:
parameters:
- name: package_query
in: query
required: false
description: >
Use this query parameter to filter for the packages thats suits your use case.
It can be used by passing in either package names or package ids.
To query for multiple packages you can pass in comma separated values.
For example:

```

package_query=17ea97c0-d350-45ce-9f36-ebb66694196c,558664cd-fece-47f5-a9ca-f30974cf96a5,...

```

Or if you prefer using package names, you can also pass in

```

package_query=package_name_1,package_name_2...

```
schema:
type: string
get:
summary: test
operationId: test
responses:
'200':
description: CSV response without schema
content:
application/json:
schema:
description: Undocumented
type: array
components: {}
Loading
Loading