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

Inline object not generated #1643

Open
er1c opened this issue Nov 23, 2022 · 1 comment
Open

Inline object not generated #1643

er1c opened this issue Nov 23, 2022 · 1 comment

Comments

@er1c
Copy link

er1c commented Nov 23, 2022

      "ApiError": {
        "type": "object",
        "properties": {
          "attribute": {
            "type": "string",
            "description": "The attribute that this error applies to. Omitted if this error is not in the context of a resource, or cannot be isolated to a single attribute.\n"
          },
          "type": {
            "type": "string",
            "description": "A classification for this error, which can be used to render the appropriate custom error template, or take other programmatic actions.\n"
          },
          "details": {
            "description": "Variables associated with this error that can be injected into a custom error template, or used to parameterize any other programatic actions.\n",
            "allOf": [
              {
                "type": "object",
                "additionalProperties": {
                  "type": "string"
                }
              }
            ]
          },
          "message": {
            "type": "string",
            "description": "A human-readable, English description of the error.\n"
          }
        }
      },

Resulting code:

/*
 * This file was generated by guardrail (https://github.com/guardrail-dev/guardrail).
 * Modifications will be overwritten; instead edit the OpenAPI/Swagger spec file.
 */
package com.evenfinancial.finance.v1.http4s.client.definitions
import cats.syntax.either._
import io.circe.syntax._
import cats.instances.all._
import _root_.com.evenfinancial.finance.v1.http4s.client.Implicits._
case class ApiError(attribute: Option[String] = None, `type`: Option[String] = None, details: Option[ApiError.Details] = None, message: Option[String] = None)
object ApiError {
  implicit val encodeApiError: _root_.io.circe.Encoder.AsObject[ApiError] = {
    val readOnlyKeys = _root_.scala.Predef.Set[_root_.scala.Predef.String]()
    _root_.io.circe.Encoder.AsObject.instance[ApiError](a => _root_.io.circe.JsonObject.fromIterable(_root_.scala.Vector(("attribute", a.attribute.asJson), ("type", a.`type`.asJson), ("details", a.details.asJson), ("message", a.message.asJson)))).mapJsonObject(_.filterKeys(key => !(readOnlyKeys contains key)))
  }
  implicit val decodeApiError: _root_.io.circe.Decoder[ApiError] = new _root_.io.circe.Decoder[ApiError] { final def apply(c: _root_.io.circe.HCursor): _root_.io.circe.Decoder.Result[ApiError] = for (v0 <- c.downField("attribute").as[Option[String]]; v1 <- c.downField("type").as[Option[String]]; v2 <- c.downField("details").as[Option[ApiError.Details]]; v3 <- c.downField("message").as[Option[String]]) yield ApiError(v0, v1, v2, v3) }
}

There's no ApiError.Details generated.

@er1c
Copy link
Author

er1c commented Nov 23, 2022

Just to confirm, this did work if not trying to inline the object:

      "ApiError": {
        "type": "object",
        "properties": {
          "attribute": {
            "type": "string",
            "description": "The attribute that this error applies to. Omitted if this error is not in the context of a resource, or cannot be isolated to a single attribute.\n"
          },
          "type": {
            "type": "string",
            "description": "A classification for this error, which can be used to render the appropriate custom error template, or take other programmatic actions.\n"
          },
          "details": {
            "description": "Variables associated with this error that can be injected into a custom error template, or used to parameterize any other programatic actions.\n",
            "allOf": [
              {
                "$ref": "#/components/schemas/ApiErrorDetails"
              }
            ]
          },
          "message": {
            "type": "string",
            "description": "A human-readable, English description of the error.\n"
          }
        }
      },
      "ApiErrorDetails": {
        "type": "object",
        "additionalProperties": {
          "type": "string"
        }
      },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant