Skip to content

Commit

Permalink
Fix identation for yaml.v3
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaeljusto committed May 26, 2022
1 parent cf184d7 commit b9536ea
Show file tree
Hide file tree
Showing 33 changed files with 337 additions and 332 deletions.
7 changes: 6 additions & 1 deletion openapi2/openapi2.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package openapi2 // import "github.com/teamwork/kommentaar/openapi2"

import (
"bytes"
"encoding/json"
"fmt"
"io"
Expand Down Expand Up @@ -469,7 +470,11 @@ func write(outFormat string, w io.Writer, prog *docparse.Program) error {
case "json":
d, err = json.Marshal(&out)
case "yaml":
d, err = yaml.Marshal(&out)
var b bytes.Buffer
yamlEncoder := yaml.NewEncoder(&b)
yamlEncoder.SetIndent(2)
err = yamlEncoder.Encode(&out)
d = b.Bytes()
default:
err = fmt.Errorf("unknown format: %#v", outFormat)
}
Expand Down
12 changes: 6 additions & 6 deletions testdata/openapi2/src/blank-line/want.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ info:
title: x
version: x
consumes:
- application/json
- application/json
produces:
- application/json
- application/json
tags:
- name: tag
- name: tag
paths:
/path:
post:
operationId: POST_path
tags:
- tag
- tag
consumes:
- application/x-www-form-urlencoded
- application/x-www-form-urlencoded
produces:
- application/json
- application/json
responses:
200:
description: 200 OK (no data)
Expand Down
2 changes: 1 addition & 1 deletion testdata/openapi2/src/description-print-var/want.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ paths:
I'm escaped $foo
produces:
- application/json
- application/json
responses:
200:
description: 200 OK (no data)
Expand Down
6 changes: 3 additions & 3 deletions testdata/openapi2/src/embedded-pointer/want.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ info:
title: x
version: x
consumes:
- application/json
- application/json
produces:
- application/json
- application/json
paths:
/path:
post:
operationId: POST_path
produces:
- application/json
- application/json
responses:
200:
description: 200 OK
Expand Down
30 changes: 15 additions & 15 deletions testdata/openapi2/src/embedded-sometimes/want.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,31 @@ info:
title: x
version: x
consumes:
- application/json
- application/json
produces:
- application/json
- application/json
tags:
- name: foobar
- name: foobar
paths:
/foo/{id}:
post:
operationId: POST_foo_{id}
tags:
- foobar
- foobar
consumes:
- application/json
- application/json
produces:
- application/json
- application/json
parameters:
- name: id
in: path
type: integer
required: true
- name: embedded-sometimes.RequestObj
in: body
required: true
schema:
$ref: '#/definitions/embedded-sometimes.RequestObj'
- name: id
in: path
type: integer
required: true
- name: embedded-sometimes.RequestObj
in: body
required: true
schema:
$ref: '#/definitions/embedded-sometimes.RequestObj'
responses:
200:
description: 200 OK
Expand Down
18 changes: 9 additions & 9 deletions testdata/openapi2/src/endpoint-extend/want.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ info:
title: x
version: x
consumes:
- application/json
- application/json
produces:
- application/json
- application/json
paths:
/path:
post:
consumes:
- application/xml
- application/xml
operationId: POST_path
parameters:
- in: body
name: endpoint-extend.reqRef
required: true
schema:
$ref: '#/definitions/endpoint-extend.reqRef'
- in: body
name: endpoint-extend.reqRef
required: true
schema:
$ref: '#/definitions/endpoint-extend.reqRef'
produces:
- application/json
- application/json
responses:
"200":
description: 200 OK (no data)
Expand Down
24 changes: 12 additions & 12 deletions testdata/openapi2/src/export/want.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ info:
title: x
version: x
consumes:
- application/json
- application/json
produces:
- application/json
- application/json
paths:
/path:
post:
operationId: POST_path
consumes:
- application/json
- application/json
produces:
- application/json
- application/json
parameters:
- name: exported
in: query
type: string
- name: export.ref2
in: body
required: true
schema:
$ref: '#/definitions/export.ref2'
- name: exported
in: query
type: string
- name: export.ref2
in: body
required: true
schema:
$ref: '#/definitions/export.ref2'
responses:
200:
description: 200 OK (no data)
Expand Down
6 changes: 3 additions & 3 deletions testdata/openapi2/src/field-whitelist/want.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ info:
title: x
version: x
consumes:
- application/json
- application/json
produces:
- application/json
- application/json
paths:
/path:
post:
operationId: POST_path
produces:
- application/json
- application/json
responses:
200:
description: 200 OK
Expand Down
6 changes: 3 additions & 3 deletions testdata/openapi2/src/interface/want.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ info:
title: x
version: x
consumes:
- application/json
- application/json
produces:
- application/json
- application/json
paths:
/path:
get:
operationId: GET_path
produces:
- application/json
- application/json
responses:
200:
description: 200 OK
Expand Down
86 changes: 43 additions & 43 deletions testdata/openapi2/src/multiple-routes/want.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,85 +3,85 @@ info:
title: x
version: x
consumes:
- application/json
- application/json
produces:
- application/json
- application/json
tags:
- name: somethingelse
- name: tag
- name: somethingelse
- name: tag
paths:
/bar:
put:
operationId: PUT_bar
tags:
- somethingelse
- somethingelse
summary: Tagline
description: Desc
consumes:
- application/x-www-form-urlencoded
- application/x-www-form-urlencoded
produces:
- application/json
- application/json
parameters:
- name: id
in: path
type: string
required: true
- name: id
in: query
type: string
- name: id
in: formData
type: string
- name: id
in: path
type: string
required: true
- name: id
in: query
type: string
- name: id
in: formData
type: string
responses:
200:
description: 200 OK (no data)
/foo:
get:
operationId: GET_foo
tags:
- tag
- tag
summary: Tagline
description: Desc
consumes:
- application/x-www-form-urlencoded
- application/x-www-form-urlencoded
produces:
- application/json
- application/json
parameters:
- name: id
in: path
type: string
required: true
- name: id
in: query
type: string
- name: id
in: formData
type: string
- name: id
in: path
type: string
required: true
- name: id
in: query
type: string
- name: id
in: formData
type: string
responses:
200:
description: 200 OK (no data)
/path/{id}:
post:
operationId: POST_path_{id}
tags:
- tag
- tag
summary: Tagline
description: Desc
consumes:
- application/x-www-form-urlencoded
- application/x-www-form-urlencoded
produces:
- application/json
- application/json
parameters:
- name: id
in: path
type: string
required: true
- name: id
in: query
type: string
- name: id
in: formData
type: string
- name: id
in: path
type: string
required: true
- name: id
in: query
type: string
- name: id
in: formData
type: string
responses:
200:
description: 200 OK (no data)
Expand Down
Loading

0 comments on commit b9536ea

Please sign in to comment.