-
-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I can not generate interface #249
Comments
@MohMehrnia thanks for taking the time to report this. Do you have a support key? Do you get any specific error? It could be that the OpenAPI spec contains validation errors, try using the |
I tried the OpenAPI spec file myself, but first I had to format it in with indentations to be a bit more readable {
"swaggerVersion": "1.2",
"apis": [
{
"path": "/v2/servers/{serverName}/vhosts/{vhostName}/applications",
"description": "Application Operations"
},
{
"path": "/v2/machine/monitoring/current",
"description": "Machine Level Current Statistics"
},
{
"path": "/v2/machine/monitoring/historic",
"description": "Machine Level Historic Statistics"
},
{
"path": "/v2/servers/{serverName}/licenses",
"description": "Server Licenses"
},
{
"path": "/v2/servers/{serverName}/listeners",
"description": "Server Listeners"
},
{
"path": "/v2/servers/{serverName}/log4j",
"description": "Server log4j system"
},
{
"path": "/v2/servers/{serverName}/mediacache",
"description": "Server MediaCache"
},
{
"path": "/v3/servers/{serverName}/mediacache",
"description": "Server MediaCache Version 3"
},
{
"path": "/v2/servers/{serverName}/mediacasters",
"description": "Server MediaCasters"
},
{
"path": "/v2/servers/{serverName}/monitoring",
"description": "Server Monitoring"
},
{
"path": "/v2/servers/{serverName}/publishers",
"description": "Server Publishers"
},
{
"path": "/v3/servers/{serverName}/publishers",
"description": "Server Publishers Version 3"
},
{
"path": "/restinfo",
"description": "REST information"
},
{
"path": "/v2/servers",
"description": "Servers Configuration"
},
{
"path": "/v2/servers/{serverName}/status",
"description": "Server Status"
},
{
"path": "/v2/servers/{serverName}/transcoder",
"description": "Server Transcoder"
},
{
"path": "/v2/servers/{serverName}/tune",
"description": "Server Tuning"
},
{
"path": "/v2/servers/{serverName}/users",
"description": "Server Users"
},
{
"path": "/v2/servers/{serverName}/vhosts",
"description": "VHost Operations"
}
],
"apiVersion": "1.0.0"
} Unfortunately, this spec has too little information to generate anything from. Even if you use the public partial interface IApiClient
{
} I haven't worked much with Swagger v1.2 but I can see from older docs that it supports If you're using Swagger v1.2 then Refitter will expect something like this: {
"apiVersion": "1.0.0",
"swaggerVersion": "1.2",
"basePath": "http://petstore.swagger.wordnik.com/api",
"resourcePath": "/store",
"produces": [
"application/json"
],
"authorizations": {},
"apis": [
{
"path": "/store/order/{orderId}",
"operations": [
{
"method": "GET",
"summary": "Find purchase order by ID",
"notes": "For valid response try integer IDs with value <= 5. Anything above 5 or nonintegers will generate API errors",
"type": "Order",
"nickname": "getOrderById",
"authorizations": {},
"parameters": [
{
"name": "orderId",
"description": "ID of pet that needs to be fetched",
"required": true,
"type": "string",
"paramType": "path"
}
],
"responseMessages": [
{
"code": 400,
"message": "Invalid ID supplied"
},
{
"code": 404,
"message": "Order not found"
}
]
},
{
"method": "DELETE",
"summary": "Delete purchase order by ID",
"notes": "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors",
"type": "void",
"nickname": "deleteOrder",
"authorizations": {
"oauth2": [
{
"scope": "test:anything",
"description": "anything"
}
]
},
"parameters": [
{
"name": "orderId",
"description": "ID of the order that needs to be deleted",
"required": true,
"type": "string",
"paramType": "path"
}
],
"responseMessages": [
{
"code": 400,
"message": "Invalid ID supplied"
},
{
"code": 404,
"message": "Order not found"
}
]
}
]
},
{
"path": "/store/order",
"operations": [
{
"method": "POST",
"summary": "Place an order for a pet",
"notes": "",
"type": "void",
"nickname": "placeOrder",
"authorizations": {
"oauth2": [
{
"scope": "test:anything",
"description": "anything"
}
]
},
"parameters": [
{
"name": "body",
"description": "order placed for purchasing the pet",
"required": true,
"type": "Order",
"paramType": "body"
}
],
"responseMessages": [
{
"code": 400,
"message": "Invalid order"
}
]
}
]
}
],
"models": {
"Order": {
"id": "Order",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"petId": {
"type": "integer",
"format": "int64"
},
"quantity": {
"type": "integer",
"format": "int32"
},
"status": {
"type": "string",
"description": "Order Status",
"enum": [
"placed",
"approved",
"delivered"
]
},
"shipDate": {
"type": "string",
"format": "date-time"
}
}
}
}
} which is taken from https://github.com/OAI/OpenAPI-Specification/blob/main/versions/1.2.md#521-object-example Sorry, but I don't think I can help you with this @MohMehrnia |
this is json qwith wuth you suggestion format but bug is still |
@MohMehrnia I just tried out the spec you shared. Unfortunately, you're right, it can't seem to be parsed correctly. Apparently, it seems that NSwag, the library I use to parse OpenAPI specifications doesn't support version 1.2. NSwag only supports v2.0 and v3.0, it can sometimes work with v3.1 as well but not all features are supported You might want to convert or migrate it to v3.0. It's a large spec so converting/migrating it to v3.0 by hand might be a lot of work. I have seen a couple of tools for converting a v2.0 spec to v3.0 but I've never tried working with a v1.2 spec (until today) |
I try this link but generate empty http://185.113.9.221:8089/v2/servers/%7BserverName%7D/vhosts/%7BvhostName%7D/applications |
@MohMehrnia I tried converting that spec using Swagger Converter and got v3.0.1 spec that contained errors. I tried to fix them manually, but since I don't know the API, I might have just introduced errors. Anyway, this file: converted-swagger-v1-spec.json now produces this Output. I had to compress it myself so I can upload it to Github I haven't tested if it even at all compiles, but it should be a good starting point |
how do convert to 3.01? |
|
show me this error
|
@MohMehrnia Have you tried the files I linked to here? |
@MohMehrnia I did the conversion for you, which resulted in this file: converted-swagger-v1-spec.json. I had to make minor changes so that it works and it now produces this Output. Please check the hyperlinks in my comments |
@MohMehrnia Swagger spec v1 is a bit out of the scope of what Refitter handles so I think I will close this issue |
thanks |
log4j.json I can not convert this file @christianhelle ?! |
@MohMehrnia What errors do you get? Do you have a support key? What version of Refitter are you using? |
Latest version, some property not detected |
you can tested a send files |
thanks for helping |
I tried out the files you and NSwag doesn't seem to like them much, actually I tried them with 4 different code generators and it seems that only Microsoft Kiota knows how to read the OAS documents You can try out one of my other tools called REST API Client Code Generator To install:
to generate code
I'm considering switching out NSwag entirely with hand generated contracts as NSwag is a bit to strict with OpenAPI specs |
@MohMehrnia I tried fixing the OpenAPI specs by hand and got them to work with Refitter. I didn't trying building the output file though, but it should be a start. Here they are with the fixes... log4j.json The output error messages that Refitter writes is a direct hint to what needed to be fixed in the spec |
Hi @christianhelle
|
This doesn't really have anything to do with Refitter (or Refit) and this looks like the HTTP response body didn't contain any JSON payload. Perhaps the API returned HTTP 4xx or 5xx with an HTML body? You can add a message handler that logs the raw HTTP response to your HttpClient delegating handlers pipeline to verify |
I fixed last error by show me another error
|
Result is a with postman
|
i have a json
{"swaggerVersion":"1.2","apis":[{"path":"/v2/servers/{serverName}/vhosts/{vhostName}/applications","description":"Application Operations"},{"path":"/v2/machine/monitoring/current","description":"Machine Level Current Statistics"},{"path":"/v2/machine/monitoring/historic","description":"Machine Level Historic Statistics"},{"path":"/v2/servers/{serverName}/licenses","description":"Server Licenses"},{"path":"/v2/servers/{serverName}/listeners","description":"Server Listeners"},{"path":"/v2/servers/{serverName}/log4j","description":"Server log4j system"},{"path":"/v2/servers/{serverName}/mediacache","description":"Server MediaCache"},{"path":"/v3/servers/{serverName}/mediacache","description":"Server MediaCache Version 3"},{"path":"/v2/servers/{serverName}/mediacasters","description":"Server MediaCasters"},{"path":"/v2/servers/{serverName}/monitoring","description":"Server Monitoring"},{"path":"/v2/servers/{serverName}/publishers","description":"Server Publishers"},{"path":"/v3/servers/{serverName}/publishers","description":"Server Publishers Version 3"},{"path":"/restinfo","description":"REST information"},{"path":"/v2/servers","description":"Servers Configuration"},{"path":"/v2/servers/{serverName}/status","description":"Server Status"},{"path":"/v2/servers/{serverName}/transcoder","description":"Server Transcoder"},{"path":"/v2/servers/{serverName}/tune","description":"Server Tuning"},{"path":"/v2/servers/{serverName}/users","description":"Server Users"},{"path":"/v2/servers/{serverName}/vhosts","description":"VHost Operations"}],"apiVersion":"1.0.0"}
buy i can not generate interface
The text was updated successfully, but these errors were encountered: