Forum Discussion
HKosova
SmartBear Alumni (Retired)
Try this:
paths:
...
/user:
$ref: 'user.yaml#/paths/~1user'
/user/createWithArray:
$ref: 'user.yaml#/paths/~1user~1createWithArray'
/user/createWithList:
$ref: 'user.yaml#/paths/~1user~1createWithList'
/user/login:
$ref: 'user.yaml#/paths/~1user~1login'
/user/logout:
$ref: 'user.yaml#/paths/~1user~1logout'
# etc.
components:
schemas:
...
User:
$ref: 'user.yaml#/components/schemas/User'
# etc.
Note that path references look like
$ref: 'user.yaml#/paths/~1user~1createWithArray'
The part after #/ must specify the full "path" to the referenced node from the root of the file, hence the #/paths/... part. Endpoint names such as /user/createWithArray are written as ~1user~1createWithArray because the literal / characters in node names must be escaped as ~1 (see "Encoding $ref values" in this post).
doncarlito87
4 years agoNew Contributor
Hey thanks for your answer. I have modified my OpenApi yaml file as you described.
/structure/{structureId}:
$ref: 'structureGroup.yaml#/paths/~1structure~1structureId'
/structureGroup/listAllNames:
$ref: 'structureGroup.yaml#/paths/~1structureGroup~1listAllNames'
/structureGroup/{structureGroupId}:
$ref: 'structureGroup.yaml#/paths/~1structureGroup~1structureGroupId'
/structureGroup/location/{structureGroupId}:
$ref: 'structureGroupLocation#/paths/~1structureGroup~1location~1structureGroupId'
/structureGroup/allLocation:
$ref: 'structureGroupLocation#/paths/~1structureGroup~1allLocation'
/user:
$ref: 'user.yaml#/paths~1user'
/user/createWithArray:
$ref: 'user.yaml#/paths~1user/~1createWithArray'
/user/createWithList:
$ref: 'user.yaml#/paths~1user/~1createWithList'
/user/login:
$ref: 'user.yaml#/paths~1user/~1login'
/user/logout:
$ref: 'user.yaml#/paths~1user/~1logout'
/version:
$ref: 'version.yaml#/paths~1version'
/version/findAllByOrderByReleasedateAsc:
$ref: 'version.yaml#/paths/~1version~1findAllByOrderByReleasedateAsc'
/version/findAllByOrderByReleasedateDesc:
$ref: 'version.yaml#/paths/~1version~1findAllByOrderByReleasedateDesc'
/version/currentVersion:
$ref: 'version.yaml#/paths/~1version~1currentVersion'
/version/{versionId}:
$ref: 'version.yaml#/paths/~1version~1versionId'
components:
schemas:
StructureProperty:
$ref: 'structureGroup.yaml#/components/schemas/StructureProperty'
Structure:
$ref: 'structureGroup.yaml#/components/schemas/Structure'
StructureGroup:
$ref: 'structureGroup.yaml#/components/schemas/StructureGroup'
StructureGroupLocation:
$ref: 'structureGroupLocation.yaml#/components/schemas/StructureGroupLocation'
User:
$ref: 'user.yaml#/components/schemas/User'
Version:
$ref: 'version.yaml#/components/schemas/Version'
But i am still getting the following error
[ERROR] Failed to execute goal org.openapitools:openapi-generator-maven-plugin:5.1.1:generate (default) on project proinfra-basis-service: Code generation failed. See
above for the full exception. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
The errors concerning the paths have already disappeared.
What surprises me is that in paths of the top-level yaml file everything is written in the same color. Normally it is the path has one color and the reference another or (see image)?
Related Content
- 4 years ago
- 7 years ago
Recent Discussions
- 5 days ago