Referring to example: https://learn.microsoft.com/en-us/azure/machine-learning/how-to-deploy-advanced-entry-script?view=azureml-api-1#automatically-generate-a-swagger-schema
I am looking to enhance my Swagger documentation by including details such as optional inputs for model and example enums. Is this achievable with inference-schema? I haven't come across any examples demonstrating this. When attempting to provide the json_schema with enums and required fields in my request format using the input_schema decorator, it seems that Swagger considers everything as required.
example:
{
"ServiceInput": {
"type": "object",
"properties": {
"request_payload": {
"type": "object",
"required": [
"input1",
"requestTimestamp",
"requestTimezone"
],
"properties": {
"input1": {
"type": "integer",
"format": "int64"
},
"input2": {
"type": "integer",
"format": "int64"
},
"requestTimestamp": {
"type": "string"
},
"requestTimezone": {
"type": "string"
}
}
}
},
"example": {
"request_payload": {
"input1": 200,
"requestTimestamp": "2023-05-05T12:12:12.000Z",
"requestTimezone": "Europe/Berlin",
"input2": 10
}
}
}
}
In above example input2 is optional in the request inputPayload, and i would like to show this on swagger doc (auto generated one).
I am aware that I can pass my own custom swagger specs to the deployment but i was wondering if this can be done automatically with inference-schema while cerating deployment.
That would essentially eliminate the need of manually editing swagger docs.
Any guidance on how to achieve this would be greatly appreciated.
To create an optional parameter, you need to give
GlobalParametersof typeStandardPythonParameterTypeto theinput_schemadecorator.Below is the sample
score.pyI am using.Create a parameter of type
StandardPythonParameterType:Then, in the decorator, provide it as below:
Here,
GlobalParametersis case-sensitive.Code:
You can refer to this Stack solution