guardrail-dev / guardrail-dev/guardrail
Missing showJSON in generated code
- Dominant language
- Scala
- Stars
- 541
- Forks
- 138
- PR merge metrics
- No merged PRs in 30d
Description
I used Snyk public Swagger to generate a client and noticed a lot of compilation errors:
```
[error] target/scala-2.13/src_managed/main/io/snyk/api/Reporting API/ReportingApiClient.scala:131:43: could not find implicit value for parameter ev: io.snyk.api.Implicits.Show[io.circe.Json]
[error] x => List(("filters", Formatter.show(x)))
```
To solve this, I simply added a new implicit show val:
```
implicit val showJSON = build[Json](_.toString)
```
I think it's related to #370, just when the request body has enum array:
```
/reporting/counts/projects/latest:
post:
responses:
'200':
description: OK
headers: {}
examples:
application/json; charset=utf-8:
results:
- day: '2017-07-01'
count: 0
schema:
type: object
properties:
results:
type: array
items:
type: object
properties:
day:
type: string
description: The date in the format `YYYY-MM-DD`
count:
type: number
description: The number of projects
required:
- day
- count
description: A list of project counts by day
required:
- results
'400':
description: Bad Request
headers: {}
examples:
application/json; charset=utf-8:
code: 400
ok: false
error:
name: ValidationError
innerErrors:
- >-
invalid type filters.projects is an invalid project
unsupported-project
schema:
type: object
properties:
code:
type: number
description: The error response code
ok:
type: boolean
error:
type: object
properties:
name:
type: string
description: A descriptive message of the error
innerErrors:
type: array
items:
type: string
description: A list of additional reasons why the error occurred
required:
- name
required:
- code
- ok
- error
summary: Get latest project counts
operationId: Get latest project counts
description: ''
tags:
- Reporting API
parameters:
- name: body
in: body
schema:
type: object
properties:
filters:
type: object
properties:
orgs:
type: array
items:
type: string
description: The list of org IDs to filter the results by
languages:
type: string
enum:
- javascript
- ruby
- java
- scala
- python
- golang
- php
- dotnet
- swift-objective-c
- elixir
- docker
- terraform
- kubernetes
- helm
- cloudformation
description: The type of languages to filter the results by
projects:
type: array
items:
type: string
description: The list of project IDs to filter the results by
required:
- orgs
example:
filters:
orgs: []
languages: javascript
projects: []
produces:
- application/json; charset=utf-8
```
Contributor guide
Research direction
Start with the generated target/scala-2.13/src_managed/main/io/snyk/api/Reporting API/ReportingApiClient.scala and inspect the io.snyk.api.Implicits.Show definitions. Trace generation from the supplied Swagger schema, then verify that a client containing the enum-array request body compiles without the missing Show[io.circe.Json] error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, scala
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100