Skip to content

Commit

Permalink
update test data
Browse files Browse the repository at this point in the history
  • Loading branch information
sudorandom committed Aug 20, 2024
1 parent e4bd50f commit e5a7f7d
Show file tree
Hide file tree
Showing 39 changed files with 1,316 additions and 644 deletions.
12 changes: 5 additions & 7 deletions internal/converter/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,13 @@ func Convert(req *pluginpb.CodeGeneratorRequest) (*pluginpb.CodeGeneratorRespons
return nil, err
}

logLevel := slog.LevelInfo
if opts.Debug {
logLevel = slog.LevelDebug
slog.SetDefault(slog.New(
tint.NewHandler(os.Stderr, &tint.Options{
Level: slog.LevelDebug,
}),
))
}
slog.SetDefault(slog.New(
tint.NewHandler(os.Stderr, &tint.Options{
Level: logLevel,
}),
))

files := []*pluginpb.CodeGeneratorResponse_File{}
genFiles := make(map[string]struct{}, len(req.FileToGenerate))
Expand Down
Binary file modified internal/converter/fixtures/fileset.binpb
Binary file not shown.
3 changes: 3 additions & 0 deletions internal/converter/fixtures/flex.cases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ cases:
body: '{}'
headers:
Content-Type: application/json
Connect-Protocol-Version: 1

- name: "normalrpc-full"
path: "flex.FlexService/NormalRPC"
Expand Down Expand Up @@ -31,6 +32,7 @@ cases:
}
headers:
Content-Type: application/json
Connect-Protocol-Version: 1

# 64bit numeric types can use strings (as they must if they're large enough)
- name: "normalrpc-strings"
Expand All @@ -48,3 +50,4 @@ cases:
}
headers:
Content-Type: application/json
Connect-Protocol-Version: 1
2 changes: 2 additions & 0 deletions internal/converter/fixtures/google_value.cases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ cases:
body: '"kevin"'
headers:
Content-Type: application/json
Connect-Protocol-Version: 1

- name: "healthcheck with object"
path: "samples.Test/HealthCheck"
body: '{"value": "kevin"}'
headers:
Content-Type: application/json
Connect-Protocol-Version: 1
errors:
- ".*Reason: expected string, but got object, Location: /type.*"
8 changes: 8 additions & 0 deletions internal/converter/fixtures/helloworld.cases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ cases:
query: 'message=%7B%22name%22%3A%20%22kevin%22%7D'
headers:
Content-Type: application/json
Connect-Protocol-Version: 1

- name: "hello-wrong-value-type"
method: GET
path: "helloworld.Greeter/SayHello"
query: 'message=%7B%22name%22%3A%201%7D'
headers:
Content-Type: application/json
Connect-Protocol-Version: 1
errors:
- ".*Reason: expected string, but got number, Location: /properties/name/type.*"

Expand All @@ -21,6 +23,7 @@ cases:
query: 'message=%7B%22nane%22%3A%20%22kevin%22%7D'
headers:
Content-Type: application/json
Connect-Protocol-Version: 1
errors:
- ".*additionalProperties 'nane' not allowed, Location: /additionalProperties.*"

Expand All @@ -30,6 +33,7 @@ cases:
query: 'message=%7B%22name%22%3A%20%22kevin%22%2C%20%22extra%22%3A%201234%7D'
headers:
Content-Type: application/json
Connect-Protocol-Version: 1
errors:
- ".*additionalProperties 'extra' not allowed, Location: /additionalProperties.*"

Expand All @@ -38,12 +42,14 @@ cases:
body: '{"name": "kevin"}'
headers:
Content-Type: application/json
Connect-Protocol-Version: 1

- name: "writehello-wrong-value-type"
path: "helloworld.Greeter/WriteHello"
body: '{"name": 1}'
headers:
Content-Type: application/json
Connect-Protocol-Version: 1
errors:
- ".*Reason: expected string, but got number, Location: /properties/name/type.*"

Expand All @@ -52,6 +58,7 @@ cases:
body: '{"nane": "kevin"}'
headers:
Content-Type: application/json
Connect-Protocol-Version: 1
errors:
- ".*additionalProperties 'nane' not allowed, Location: /additionalProperties.*"

Expand All @@ -60,5 +67,6 @@ cases:
body: '{"name": "kevin", "extra": 1234}'
headers:
Content-Type: application/json
Connect-Protocol-Version: 1
errors:
- ".*additionalProperties 'extra' not allowed, Location: /additionalProperties.*"
14 changes: 14 additions & 0 deletions internal/converter/fixtures/output/array_of_enums.openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@
"title": "ArrayOfEnums",
"additionalProperties": false
},
"connect-protocol-version": {
"type": "number",
"title": "Connect-Protocol-Version",
"enum": [
1
],
"description": "Define the version of the Connect protocol",
"const": 1
},
"connect-timeout-header": {
"type": "number",
"title": "Connect-Timeout-Ms",
"description": "Define the timeout, in ms"
},
"connect.error": {
"type": "object",
"properties": {
Expand Down
11 changes: 11 additions & 0 deletions internal/converter/fixtures/output/array_of_enums.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ components:
$ref: '#/components/schemas/enums.ArrayOfEnums.inline'
title: ArrayOfEnums
additionalProperties: false
connect-protocol-version:
type: number
title: Connect-Protocol-Version
enum:
- 1
description: Define the version of the Connect protocol
const: 1
connect-timeout-header:
type: number
title: Connect-Timeout-Ms
description: Define the timeout, in ms
connect.error:
type: object
properties:
Expand Down
14 changes: 14 additions & 0 deletions internal/converter/fixtures/output/array_of_messages.openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@
"title": "Thing",
"additionalProperties": false
},
"connect-protocol-version": {
"type": "number",
"title": "Connect-Protocol-Version",
"enum": [
1
],
"description": "Define the version of the Connect protocol",
"const": 1
},
"connect-timeout-header": {
"type": "number",
"title": "Connect-Timeout-Ms",
"description": "Define the timeout, in ms"
},
"connect.error": {
"type": "object",
"properties": {
Expand Down
11 changes: 11 additions & 0 deletions internal/converter/fixtures/output/array_of_messages.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ components:
additionalProperties: false
title: Thing
additionalProperties: false
connect-protocol-version:
type: number
title: Connect-Protocol-Version
enum:
- 1
description: Define the version of the Connect protocol
const: 1
connect-timeout-header:
type: number
title: Connect-Timeout-Ms
description: Define the timeout, in ms
connect.error:
type: object
properties:
Expand Down
26 changes: 21 additions & 5 deletions internal/converter/fixtures/output/editions_2023.openapi.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"openapi": "3.1.0",
"info": {},
"info": {
"title": "editions"
},
"paths": {},
"components": {
"schemas": {
"Person.Employment": {
"editions.Person.Employment": {
"type": "string",
"title": "Employment",
"enum": [
Expand All @@ -13,7 +15,7 @@
"EMPLOYMENT_PARTTIME"
]
},
"Person.Pay_Type": {
"editions.Person.Pay_Type": {
"type": "string",
"title": "Pay_Type",
"enum": [
Expand All @@ -22,7 +24,7 @@
"PAY_TYPE_HOURLY"
]
},
"Person": {
"editions.Person": {
"type": "object",
"properties": {
"name": {
Expand All @@ -36,12 +38,26 @@
"additionalProperties": false
},
"employment": {
"$ref": "#/components/schemas/Person.Employment"
"$ref": "#/components/schemas/editions.Person.Employment"
}
},
"title": "Person",
"additionalProperties": false
},
"connect-protocol-version": {
"type": "number",
"title": "Connect-Protocol-Version",
"enum": [
1
],
"description": "Define the version of the Connect protocol",
"const": 1
},
"connect-timeout-header": {
"type": "number",
"title": "Connect-Timeout-Ms",
"description": "Define the timeout, in ms"
},
"connect.error": {
"type": "object",
"properties": {
Expand Down
22 changes: 17 additions & 5 deletions internal/converter/fixtures/output/editions_2023.openapi.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
openapi: 3.1.0
info: {}
info:
title: editions
paths: {}
components:
schemas:
Person.Employment:
editions.Person.Employment:
type: string
title: Employment
enum:
- EMPLOYMENT_UNSPECIFIED
- EMPLOYMENT_FULLTIME
- EMPLOYMENT_PARTTIME
Person.Pay_Type:
editions.Person.Pay_Type:
type: string
title: Pay_Type
enum:
- PAY_TYPE_UNSPECIFIED
- PAY_TYPE_SALARY
- PAY_TYPE_HOURLY
Person:
editions.Person:
type: object
properties:
name:
Expand All @@ -29,9 +30,20 @@ components:
title: id
additionalProperties: false
employment:
$ref: '#/components/schemas/Person.Employment'
$ref: '#/components/schemas/editions.Person.Employment'
title: Person
additionalProperties: false
connect-protocol-version:
type: number
title: Connect-Protocol-Version
enum:
- 1
description: Define the version of the Connect protocol
const: 1
connect-timeout-header:
type: number
title: Connect-Timeout-Ms
description: Define the timeout, in ms
connect.error:
type: object
properties:
Expand Down
Loading

0 comments on commit e5a7f7d

Please sign in to comment.