Skip to content

ticketInfo field is documented as string but returns an object in /api/{serviceId}/auth/authorization/issue response #10

@winor30

Description

@winor30

Issue

In the Authlete API schema, the ticketInfo field in the response from the /api/{serviceId}/auth/authorization/issue endpoint is defined as a string type.

openapi-for-go/api/openapi.yaml

Lines 17485 to 17488 in 91e60ba

ticketInfo:
description: |
The information about the ticket.
type: string

However, the actual API response returns an object like {"context": null}.
So if we use the generated Go client, it fails to unmarshal the response JSON properly.

Steps to Reproduce

Call the API by curl as follows:

$ curl -v -X POST https://jp.authlete.com/api/***/auth/authorization/issue \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer ***' \
-d '{ "ticket": "***", "subject": "***" }'

Actual Response from curl

{
  "action": "LOCATION",
  "responseContent": "***",
  "accessToken": null,
  "accessTokenExpiresAt": 0,
  "accessTokenDuration": 0,
  "idToken": null,
  "authorizationCode": "****",
  "jwtAccessToken": null,
  "ticketInfo": {"context": null},
  "resultCode": "A040001",
  "resultMessage": "[A040001] The authorization request was processed successfully."
}

Current Schema Definition

ticketInfo:
  description: |
    The information about the ticket.
  type: string

Error in Generated Go Client

When using the Go client generated from the OpenAPI schema, we encounter an unmarshaling error:

ctx := context.Background()
ctx = context.WithValue(ctx, v3.ContextServerIndex, 1) // jp region
ctx = context.WithValue(ctx, v3.ContextAccessToken, "***")

serviceID := "***"
configuration := v3.NewConfiguration()
apiClient := v3.NewAPIClient(configuration)

ticket := "***"
sub := "john"

request := v3.NewAuthorizationIssueRequest(ticket, sub)

res, _, err := apiClient.AuthorizationEndpointAPI.AuthAuthorizationIssueApi(ctx, serviceID).AuthorizationIssueRequest(*request).Execute()

if err != nil {
    log.Fatalf("error calling authlete: %v", err)
}

Resulting error:

$ go run ./main.go
error calling authlete: json: cannot unmarshal object into Go struct field AuthorizationIssueResponse.ticketInfo of type string

Proposed Fix

Update the schema to match the actual implementation:

ticketInfo:
  description: |
    The information about the ticket.
  type: object
  properties:
    context:
      type: ["string", "null"]
....

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