microcks: OpenApi Overriden and duplicated exemples

Describe the bug

When loading https://gitlab.com/api/v4/projects/53591717/repository/files/complex-example-2%2Fopenapi.yaml/raw?head=main The exemples are duplicated and Overriden. image Here we can see that the Mock response for /owner/0 and /owner/0/car are the same.

Expected behavior

/owner/0/car should return

  [
    { "model": "BMW X5", "year": 2018 },
    { "model": "Tesla Model 3", "year": 2020 },
  ]

from the exemple

summary: Laurent's Cars
value:
  [
    { "model": "BMW X5", "year": 2018 },
    { "model": "Tesla Model 3", "year": 2020 },
  ]

Actual behavior

but Returns the same exemple as /owner/0

How to Reproduce?

  1. import https://gitlab.com/api/v4/projects/53591717/repository/files/complex-example-2%2Fopenapi.yaml/raw?head=main with importer
  2. go to the Service

Microcks version or git rev

docker.io/microcks/microcks:nightly@sha256:22eef53ce58777d07340b9a1fadccdf356f45a034034c208f8d996cb0330cfe1

Install method (docker-compose, helm chart, operator, docker-desktop extension,…)

docker-compose

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 17 (17 by maintainers)

Commits related to this issue

Most upvoted comments

I found when it happens. It happens when a ref dosen’t have “/” in it.

For exemple there are two files like this

- baseContext/file1.yaml
- baseContext/file2.yaml

and in file2.yaml we have a ref like this: $ref: “file1.yaml”.

bug at line 160 in file webapp/src/main/java/io/github/microcks/util/AbstractJsonRepositoryImporter.java

 String referenceContext = buildContext(baseContext, ref.substring(0, ref.lastIndexOf('/'))

baseContext = “baseContext” ref = “file1.yaml”

which does not have a /

Not at the moment. Will be for next release 😉

Oops… good catch. Will wait before launching the release process 🤞

@lbroudoux Github is currently dying https://www.githubstatus.com/ . You should probably wait before releasing

Everything else looks OK for me

Will replace it with:

String referencePath = ref.contains("/") ? ref.substring(0, ref.lastIndexOf('/')) : ".";
String referenceContext = buildContext(baseContext, referencePath);

This is a side effect of #1035. Will fix it asap.