swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

OpenApi 3.1 contentEncoding: base64url not working

Open Louisasa opened this issue 2 months ago • 4 comments

Q&A (please complete the following information)

  • OS: macOS
  • Browser: chrome
  • Method of installation: npm
  • Swagger-UI version: v5.29.5
  • Swagger/OpenAPI version: OpenAPI 3.1.0

Content & configuration

Example Swagger/OpenAPI definition:

paths:
  /authorize:
    get:
      summary: Make an authorisation request
      operationId: authorize
      parameters:
        - name: request
          in: query
          required: true
          schema:
            $ref: '#/components/schemas/JWT'

components:
  schemas:
    JWT:
      type: string
      format: jwt
      pattern: '^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$'
      contentEncoding: base64url
      contentSchema:
        type: object
        properties:
          header:
            $ref: '#/components/schemas/JWTHeader'
          payload:
            $ref: '#/components/schemas/JWTPayload'

    JWTHeader:
      type: object
      properties:
        alg:
          type: string
          description: Algorithm used for signing
          example: "HS256"

    JWTPayload:
      type: object
      properties:
        test_id:
          type: string

Describe the bug you're encountering

contentEncoding: base64url causes an issue when I try to expand the parameters of /authorize I've cloned swagger-ui and ran directly from there so I don't believe it's setup.

To reproduce...

Steps to reproduce the behavior: Try to open the parameters and get the following error

TypeError: Unknown encoding: base64url
    at Uint8Array.slowToString (swagger-ui-bundle.js:2:380321)
    at Uint8Array.toString (swagger-ui-bundle.js:2:386727)
    at base64url (swagger-ui-bundle.js:2:1459775)
    at Proxy.types_string (swagger-ui-bundle.js:2:1462383)
    at main_sampleFromSchemaGeneric (swagger-ui-bundle.js:2:1472308)
    at Object.main_sampleFromSchema [as sampleFromSchema] (swagger-ui-bundle.js:2:1472553)
    at Object.memoized [as memoizedSampleFromSchema] (swagger-ui-bundle.js:2:406173)
    at Object.getJsonSampleSchema (swagger-ui-bundle.js:2:1473075)
    at swagger-ui-bundle.js:2:1474279
    at Object.getSampleSchema (swagger-ui-bundle.js:2:1389017)

Louisasa avatar Oct 21 '25 09:10 Louisasa

Hi, I'm new to this organiztion and would like to try and investigate this bug. I'll see if I can reproduce it locally and will share any findings.

KrishCodesw avatar Oct 21 '25 20:10 KrishCodesw

Hi, can my PR be reviewed please ?

KrishCodesw avatar Oct 25 '25 15:10 KrishCodesw

Hi, I don't think I'm the right person to review your work. Regardless, I don't think you're doing the right thing as you're converting base64url to base64, instead of supporting base64url?

Louisasa avatar Oct 28 '25 08:10 Louisasa

Hi @KrishCodesw,

Thanks for your patience! We’re reorganizing some processes and working on major updates (including the new Swagger Editor), so reviews are taking a bit longer than usual. Your PR is in the queue and we’ll get to it as soon as we can.

@Louisasa, if you have time, your review would be really helpful. Final approval will come from our side, but community feedback makes things easier and faster.

Thanks! Swagger Team

MichakrawSB avatar Nov 15 '25 11:11 MichakrawSB