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

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

Open
sammy-da opened this issue Jun 22, 2023 · 2 comments
Open

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

sammy-da opened this issue Jun 22, 2023 · 2 comments

Comments

@sammy-da
Copy link

sammy-da commented Jun 22, 2023

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.

@blast-hardcheese
Copy link
Member

A bit late to reply here, I'll beg your pardon. I can't look at this at this moment, unfortunately.

Furthermore, the code to handle this hasn't been centralized, which is an omission in design which needs to get resolved.

Even if this was a blocker for you and you decided to not use guardrail, knowledge about which generator you were using would be helpful to resolve this.

Thank you.

@sammy-da
Copy link
Author

sammy-da commented Sep 6, 2023

Hey!

knowledge about which generator you were using would be helpful to resolve this.

akka-http server generator

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

Successfully merging a pull request may close this issue.

2 participants