0

I have spring boot application written in Kotlin lang.

We have REST API contract described in open api file. We use API first approach. So we use open api generator:

plugins {
    ...
    id("org.openapi.generator") version "7.17.0"
}

On the top of the file I had

openapi: 3.0.3

But I decide to switch to (reason is generating map with integer key)

openapi: 3.1.0

After appliying this change I've started to experience the error:

> Task :generateServer FAILED
Error resolving #/components/parameters/my_customer_id_header
java.net.URISyntaxException: Illegal character in opaque part at index 2: C:\work\myApp\docs\openapi.yaml
    at java.base/java.net.URI$Parser.fail(URI.java:2995)
    at java.base/java.net.URI$Parser.checkChars(URI.java:3166)
    at java.base/java.net.URI$Parser.parse(URI.java:3202)
    at java.base/java.net.URI.<init>(URI.java:645)
    at io.swagger.v3.parser.reference.Visitor.readURI(Visitor.java:80)
    at io.swagger.v3.parser.reference.ReferenceVisitor.parse(ReferenceVisitor.java:319)

Corresponding specification looks like:

paths:
  /public/v1/myApp/foo/{request_id}:
    get:
      operationId: foo
      parameters:
        - $ref: '#/components/parameters/my_customer_id_header'
...
components:
  parameters:
    ...

    my_customer_id_header:
      in: header
      name: x-my-customer-id
      required: true
      schema:
        type: string
        format: uuid

1 Answer 1

1

Was able to fix by replacement:

 register<GenerateTask>("...") {
        inputSpec.set(project.file(oasSpecLocation).path)

with

 register<GenerateTask>("...") {
        inputSpec.set(project.file(oasSpecLocation).toURI().toString())
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.