guardrail-dev / guardrail-dev/guardrail
Problem with inline object within additionalProperties
- Dominant language
- Scala
- Stars
- 541
- Forks
- 138
- PR merge metrics
- No merged PRs in 30d
Description
The following example (taken from the schema of the CRD https://github.com/argoproj/argo-cd/blob/41f54aa556f3ffb3fa4cf93d784fb7d30c15041c/manifests/crds/appproject-crd.yaml):
```yaml
openapi: 3.0.1
info:
title: Whatever
version: 1.0.0
paths: { }
components:
schemas:
status:
description: AppProjectStatus contains status information for AppProject
CRs
properties:
jwtTokensByRole:
additionalProperties:
description: JWTTokens represents a list of JWT tokens
properties:
items:
items:
description: JWTToken holds the issuedAt and expiresAt values
of a token
properties:
exp:
format: int64
type: integer
iat:
format: int64
type: integer
id:
type: string
required:
- iat
type: object
type: array
type: object
description: JWTTokensByRole contains a list of JWT tokens issued
for a given role
type: object
type: object
```
generates this code:
```scala
case class Status(jwtTokensByRole: Option[Map[String, Status.JwtTokensByRole]] = None)
object Status {
implicit val encodeStatus: _root_.io.circe.Encoder.AsObject[Status] = {
val readOnlyKeys = _root_.scala.Predef.Set[_root_.scala.Predef.String]()
_root_.io.circe.Encoder.AsObject.instance[Status](a => _root_.io.circe.JsonObject.fromIterable(_root_.scala.Vector(("jwtTokensByRole", a.jwtTokensByRole.asJson)))).mapJsonObject(_.filterKeys(key => !(readOnlyKeys contains key)))
}
implicit val decodeStatus: _root_.io.circe.Decoder[Status] = new _root_.io.circe.Decoder[Status] { final def apply(c: _root_.io.circe.HCursor): _root_.io.circe.Decoder.Result[Status] = for (v0 <- c.downField("jwtTokensByRole").as[Option[Map[String, Status.JwtTokensByRole]]]) yield Status(v0) }
}
```
in which `Status.JwtTokensByRole` is missing.
Contributor guide
Research direction
Start with the OpenAPI example from the Argo CD CRD and compare it with the generated Status code shown in the issue. Trace how inline objects under additionalProperties are handled; done means the nested Status.JwtTokensByRole type is generated and the resulting Scala output compiles.
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