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

Wrong TypeScript type for Consent Request Session #12

Closed
IGassmann opened this issue Apr 23, 2020 · 7 comments · Fixed by #15
Closed

Wrong TypeScript type for Consent Request Session #12

IGassmann opened this issue Apr 23, 2020 · 7 comments · Fixed by #15
Labels
bug Something is not working. help wanted We are looking for help on this one.

Comments

@IGassmann
Copy link

'accessToken'?: { [key: string]: object; };

should be:

    'accessToken'?: { [key: string]: any; };

'idToken'?: { [key: string]: object; };

should be:

        'idToken'?: { [key: string]: any; };

Otherwise, it expects only empty objects.

@IGassmann
Copy link
Author

Same problem for https://github.com/ory/sdk/blob/master/clients/hydra/typescript/model/consentRequest.ts#L27

The issue seems for when we can pass custom objects.

@aeneasr aeneasr added bug Something is not working. help wanted We are looking for help on this one. labels Apr 23, 2020
@aeneasr aeneasr added this to To do in Maintainer's Board via automation Apr 23, 2020
@aeneasr
Copy link
Member

aeneasr commented Apr 23, 2020

Hm yeah, that's true. The definition comes from here:

https://github.com/ory/hydra/blob/master/consent/types.go#L543

which is translated to:

https://github.com/ory/hydra/blob/master/.schema/api.swagger.json#L2095-L2101

I think type object is correct but I'm not sure why additionalProperties is added there and if that's causing the issue?

@aeneasr
Copy link
Member

aeneasr commented Apr 23, 2020

Could you try and generate the typescript code and take the linked swagger.json and update the additionalProperties part? If that's causing the issue I guess we could open an issue in openapi-generator

@aeneasr
Copy link
Member

aeneasr commented Apr 23, 2020

There's actually a new version available for openapi-generator so maybe it would be a good idea to bump it as it includes several bugfixes for TypeScript. It would also make sense to tag the version:

https://github.com/ory/sdk/blob/master/Dockerfile#L71

@IGassmann
Copy link
Author

I haven't tested, but it looks like the generated OpenAPI specification should actually be the following according to https://swagger.io/docs/specification/data-models/dictionaries/.

type: object
additionalProperties:
  type: string

If that's true, that indicates the problem resides in the tool being used for generating the OpenAPI specification.

@aeneasr
Copy link
Member

aeneasr commented May 18, 2020

Found the upstream: go-swagger/go-swagger#1402

@matejkramny
Copy link

matejkramny commented Apr 8, 2022

I think this issue came back but for the Go client this time

If in the openapi spec I remove the additionalProperties: true comment the generator produces the correct type

The sanitizer could remove the additionalProperties field for swagger specs https://github.com/ory/cli/blob/master/cmd/dev/swagger/sanitize.go#L96

spec from pet store

"Pet": {
        "description": "A pet for sale in the pet store",
        "title": "a Pet",
        "type": "object",
        "properties": {
          "access_token": {
            "type": "object",
            "x-go-name": "AccessToken"
          },
          "id_token": {
            "type": "object",
            "additionalProperties": {
              "type": "object"
            },
            "x-go-name": "IDToken"
          }
        },
        "xml": {
          "name": "Pet"
        }
      },
// Pet A pet for sale in the pet store
type Pet struct {
	AccessToken map[string]interface{}            `json:"access_token,omitempty"`
	IdToken     map[string]map[string]interface{} `json:"id_token,omitempty"`
}

Hydra issue related: ory/hydra#3058

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working. help wanted We are looking for help on this one.
Projects
Development

Successfully merging a pull request may close this issue.

3 participants