Forum Discussion
Thanks for the info. I'm still not 100% clear on what you are trying to achieve.
I've defined a version of an API with the path and schemas you have descripted at https://app.swaggerhub.com/apis/frank-kilcommins/UsersReference/1.0.0#/default/get_users
A sample response for the API would be as follows:
[
{
"id": "string",
"meta": [
{
"value": "string",
"display": "string",
"$ref": "string"
}
]
}
]
Note that $ref in a JSON payload response has no semantic meaning. I think you might be misinterpreting how to use references in your API definition. The way you have defined it means that it's just a string property with a name of "$ref". Using a JSON Schema keyword in this way may cause you issues in other tooling.
To be strictly compliant with OpenAPI 3.x, a JSON Reference can only be used where explicitly noted in the OpenAPI specification. For example, it can be used for Paths, Parameters, Schema Objects and more. Basically, if you can define a schema object inline then you can also put in a reference object.
You have defined your 'MetaData Object' as follows:
Metadata:
required:
- value
type: object
properties:
value:
type: string
display:
type: string
$ref:
type: string
The above usage is not using the $ref keyword as expected. To use references appropriately, the value of the $ref keyword must be a string representing an URI, URI reference, URI template or a JSON pointer.
For more information on how to use object references, see https://swagger.io/docs/specification/using-ref/
Thanks for the detailing ,https://app.swaggerhub.com/apis/frank-kilcommins/UsersReference/1.0.0#/default/get_users is my exact requirement.
But when you build that object and return the response of it via any endpoint in Java
The below is happening:
[{ "id": "string",
"meta": [{ "value": "string",
"display": "string",
"$Ref": "string",
"$ref": "string" }] }]
An Extra Ref is getting added runtime
Thanks,
Prasanna
Related Content
- 4 years ago
Recent Discussions
- 7 days ago
- 7 days ago
- 24 days ago