Skip to content

[Bug]: URISyntaxException Illegal character in opaque part at index 2 for v3.1.1 OpenAPI.yaml file #2223

@Ino-Earnie

Description

@Ino-Earnie

Description

I have an OpenAPI.yaml file that parses fine with version 3.0.3 but with 3.1.1 the parser throws a URISyntaxException: Illegal character in opaque part at index 2. There is also a message: Unexpected field type: null named: regionId. In this case regionId is the first definition in components/schemas. The error always refers to the first definition in components/schemas.

Affected Version

2.1.32

This began when upgrading from 3.0.3. to 3.1.1. The error happens on all our APIs we have tried to upgrade to 3.1.1

Steps to Reproduce

Parse thes OpenAPI.yaml below.

Expected Behavior

Should parse without error

Actual Behavior

Throws:

java.net.URISyntaxException: Illegal character in opaque part at index 2:

Logs / Stack Traces

at java.net.URI$Parser.fail (URI.java:2976)
at java.net.URI$Parser.checkChars (URI.java:3147)
at java.net.URI$Parser.parse (URI.java:3183)
at java.net.URI.<init> (URI.java:623)
at io.swagger.v3.parser.reference.ReferenceUtils.resolve (ReferenceUtils.java:29)
at io.swagger.v3.parser.reference.ReferenceVisitor.resolveSchemaRef (ReferenceVisitor.java:227)
at io.swagger.v3.parser.reference.ReferenceVisitor.visitSchema (ReferenceVisitor.java:141)
at io.swagger.v3.parser.reference.OpenAPI31Traverser.traverseSchema (OpenAPI31Traverser.java:801)
at io.swagger.v3.parser.reference.OpenAPI31Traverser.traverseSchema (OpenAPI31Traverser.java:867)
at io.swagger.v3.parser.reference.OpenAPI31Traverser.traverseSchemaMap (OpenAPI31Traverser.java:960)
at io.swagger.v3.parser.reference.OpenAPI31Traverser.traverseComponents (OpenAPI31Traverser.java:169)
at io.swagger.v3.parser.reference.OpenAPI31Traverser.traverseOpenApi (OpenAPI31Traverser.java:128)
at io.swagger.v3.parser.reference.OpenAPI31Traverser.traverse (OpenAPI31Traverser.java:65)
at io.swagger.v3.parser.reference.OpenAPIDereferencer31.dereference (OpenAPIDereferencer31.java:74)
at io.swagger.v3.parser.OpenAPIV3Parser.resolve (OpenAPIV3Parser.java:227)
at io.swagger.v3.parser.OpenAPIV3Parser.readContents (OpenAPIV3Parser.java:183)
at io.swagger.v3.parser.OpenAPIV3Parser.readLocation (OpenAPIV3Parser.java:97)
at io.swagger.v3.parser.OpenAPIV3Parser.read (OpenAPIV3Parser.java:124)
at io.swagger.v3.parser.OpenAPIV3Parser.read (OpenAPIV3Parser.java:113)
at com.ferguson.maven.plugin.springboot.camel.GenerateSpringBootCamelPlugin.execute (GenerateSpringBootCamelPlugin.java:569)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:299)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:963)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:296)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:199)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:569)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

Environment

Windows 11
Oracle Java 17
Maven

Additional Context

openapi: 3.1.1
info:
  title: Ferguson Customer Public API
  description: Services that provide access to Ferguson's customer information
  contact:
    name: Ferguson Middleware Services team
  license:
    name: Ferguson Services
    url: 'https://ferguson.com/licenses/LICENSE-1.0.html'
  version: v1.0
servers:
  - url: https://localhost:8083/customer-publicapi-v1/svc
    description: Development
tags:
  - name: domain
    description: Customer
  - name: visibility
    description: public
paths:
  /{mainCustomerId}/billToZip/{billToZipCode}:
    get:
      operationId: getMainCustomerInfoBillZipcode
      summary: Service to get Customer information from main Customer account and associated billTo zipcode
      description: Service to get related Customer information
      parameters:
        - $ref: '#/components/parameters/transId'
        - $ref: '#/components/parameters/mainCustomerId'
        - $ref: '#/components/parameters/billToZipCode'

      responses:
        '200':
          description: Request Successful
          headers:
            trans-id:
              $ref: '#/components/headers/trans-id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/customerInfoResponse'

        '400':
          description: Bad request
          headers:
            trans-id:
              $ref: '#/components/headers/trans-id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/validationErrors'

        '404':
          description: Not Found
          headers:
            trans-id:
              $ref: '#/components/headers/trans-id'
        '500':
          description: Internal Error
          headers:
            trans-id:
              $ref: '#/components/headers/trans-id'
            fe-resp-code:
              $ref: '#/components/headers/fe-resp-code'
            fe-resp-msg:
              $ref: '#/components/headers/fe-resp-msg'

components:
  schemas:
    regionId:
      type: string
      description: Region Id
      example: "RICH"
    branchId:
      type: string
      description: Branch Id
      example: "1350"
    customerType:
      type: string
      enum:
        - MASTER
        - MAIN
        - JOB
    customerName:
      type: string
      description: Account name
      example: "WP CLARKS FARM LLC"
    contractIds:
      type: array
      items:
        type: string
        description: Contract Id
    customerNumber:
      type: string
      description: Customer Id
      example: "276962"
    jobName:
      type: string
      description: Job name
      example: "OTIS HATFIELD"
    jobNumber:
      type: string
      description: Customer Id of the Job
      example: "93738"
    billingAddress:
      description: Billing address of the account
      type: object
      properties:
        streets:
          title: Line(s) of Street Address
          type: array
          items:
            type: string
            example: "1250 W. Mockingbird Lane"
        city:
          title: City
          type: string
          example: "Newport News"
        state:
          title: State Code
          type: string
          example: VA
        postalCode:
          title: Postal Code
          type: string
          example: 23606

    customerInfoResponse:
      title: Customer Info Response with master, main and job info
      type: object
      properties:
        masterCustomerNumber:
          type: string
          description: Master customer number
          example: '371394'
        customerType:
          $ref: '#/components/schemas/customerType'
        mainCustomers:
          type: array
          items:
            $ref: '#/components/schemas/mainCustomer'
    mainCustomer:
      type: object
      properties:
        customerType:
          $ref: '#/components/schemas/customerType'
        regionId:
          $ref: '#/components/schemas/regionId'
        branchId:
          $ref: '#/components/schemas/branchId'
        customerName:
          $ref: '#/components/schemas/customerName'
        contractIds:
          $ref: '#/components/schemas/contractIds'
        customerNumber:
          $ref: '#/components/schemas/customerNumber'
        billingAddress:
          type: array
          items:
            $ref: '#/components/schemas/billingAddress'
        mainCustomerJobs:
          type: array
          items:
            $ref: '#/components/schemas/mainCustomerJob'

    mainCustomerJob:
      type: object
      properties:
        customerType:
          $ref: '#/components/schemas/customerType'
        regionId:
          $ref: '#/components/schemas/regionId'
        branchId:
          $ref: '#/components/schemas/branchId'
        jobName:
          $ref: '#/components/schemas/jobName'
        contractIds:
          $ref: '#/components/schemas/contractIds'
        jobNumber:
          $ref: '#/components/schemas/jobNumber'
        billingAddress:
          type: array
          items:
            $ref: '#/components/schemas/billingAddress'
    validationError:
      title: Parameter Validation Error
      type: object
      x-allArgsConstructor: true
      properties:
        errorCode:
          title: Error Code
          description: Error Code indicating the nature of the error.
          type: string
          example: dataerror.k8.app.zipcode.invalid
        errorMsg:
          title: Error Message
          description: Human readable message associated with the errorCode.
          type: string
          example: invalid zipcode format
        field:
          title: Parameter in Error
          type: string
          example: billToZipCode
    validationErrors:
      title: List of Validation Errors
      type: array
      minItems: 1
      items:
        $ref: '#/components/schemas/validationError'
  headers:
    fe-resp-code:
      schema:
        type: string
        example: severe.error
      description: Response code
    fe-resp-msg:
      schema:
        type: string
        example: Severe Error
      description: Response message
    trans-id:
      schema:
        type: string
      description: Transaction Id (passed in by consumer or generated by the service)

  parameters:
    transId:
      name: trans-id
      in: header
      description: Transaction Id (Provided by service consumer)
      required: false
      schema:
        type: string
    mainCustomerId:
      name: mainCustomerId
      in: path
      description: Main Customer id
      required: true
      schema:
        type: string
    billToZipCode:
      name: billToZipCode
      in: path
      description: Billed to zip code associated with the Main Account
      required: true
      schema:
        type: string
        pattern: '^(\\d{5})([-\\s]*\\d{4})?$'

Checklist

  • I have searched the existing issues and this is not a duplicate.
  • I have provided sufficient information for maintainers to reproduce the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions