I have some DTO’s where the post body looks like this:
{
"course": "https://example.com/",
"category": "https://example.com/",
"content": "string",
"anonymous": true
}
Here, the fields “course” and “category” refer to other DTO’s. I want the example value to be automatically set to the correct path, e.g. "course": "/api/courses/1",
I know I can set it manually for every endpoint, but I was looking for a way to set this for all endpoints that use an iri-reference.
The json.openapi for this DTO looks like this:
"Course.Comment.jsonld": {
"type": "object",
"description": "",
"deprecated": false,
"properties": {
"@context": {
"readOnly": true,
"oneOf": [
{
"type": "string"
},
{
"type": "object",
"properties": {
"@vocab": {
"type": "string"
},
"hydra": {
"type": "string",
"enum": [
"http://www.w3.org/ns/hydra/core#"
]
}
},
"required": [
"@vocab",
"hydra"
],
"additionalProperties": true
}
]
},
"@id": {
"readOnly": true,
"type": "string"
},
"@type": {
"readOnly": true,
"type": "string"
},
"course": {
"type": [
"string",
"null"
],
"format": "iri-reference",
"example": "https://example.com/"
},
"category": {
"type": [
"string",
"null"
],
"format": "iri-reference",
"example": "https://example.com/"
},
"content": {
"type": [
"string",
"null"
]
},
"anonymous": {
"type": "boolean"
},
"creator": {
"readOnly": true,
"type": [
"string",
"null"
],
"format": "iri-reference",
"example": "https://example.com/"
},
"createdAt": {
"readOnly": true,
"type": "string"
},
"updatedAt": {
"readOnly": true,
"type": "string"
}
},
"required": [
"content"
]
},