Skip to content

can't use $ref in x-www-form-urlencoded #1766

Open
@sammy-da

Description

@sammy-da

This works:

{
  "paths": {
    "/api/v1/oauth/token/introspect": {
      "post": {
        "deprecated": false,
        "description": "Token introspection for Daml Hub access tokens, as per [rfc7662#section-2](https://datatracker.ietf.org/doc/html/rfc7662#section-2)\n",
        "operationId": "introspectAccessToken",
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "token": {
                    "description": "access token to introspect",
                    "type": "string"
                  }
                },
                "required": [
                  "token"
                ]
              }
            }
          }
        }
      }
    }
  }
}

But if the inlined schema is moved to a dedicated schema, guardrail code-generation fails:

{
  "components": {
    "schemas": {
      "TokenIntrospectionRequest": {
        "properties": {
          "token": {
            "description": "access token to introspect",
            "type": "string"
          }
        },
        "required": [
          "token"
        ],
        "type": "object"
      }
    }
  },
  "paths": {
    "/api/v1/oauth/token/introspect": {
      "post": {
        "deprecated": false,
        "description": "Token introspection for Daml Hub access tokens, as per [rfc7662#section-2](https://datatracker.ietf.org/doc/html/rfc7662#section-2)\n",
        "operationId": "introspectAccessToken",
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/TokenIntrospectionRequest"
              }
            }
          }
        }
      }
    }
  }
}
Unable to generate decoder for application/x-www-form-urlencoded (.paths./api/v1/oauth/token/introspect.operations.POST.consumes[0])
Error:No decoders available (.paths./api/v1/oauth/token/introspect.operations.POST.consumes)

The spec says:

Alternatively, any time a Schema Object can be used, a Reference Object can be used in its place.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions