forked from Azure/azure-functions-openapi-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
#588 Issue 정리
Woosam Hwang edited this page Sep 2, 2023
·
2 revisions
#588 Issue - 링크
public class Yellow
{
}
public partial class Color : System.Collections.ObjectModel.Collection<Yellow>
{
}
[OpenApiRequestBody(contentType: "application/json", bodyType: typeof(Color), Required = true, Description = "Pet object that needs to be updated to the store")]
위의 클래스로 BodyType을 설정하여 실행할 경우 해당 Type을 찾지 못해서 Null로 반환하여 오류 발생
이를 해결하기 위해서 아래의 코드로 수정
underlyingType = type.GetElementType() ?? (type.GetGenericArguments() != null && type.GetGenericArguments().Length > 0 ? type.GetGenericArguments()[0] : type.BaseType.GetGenericArguments()[0]);
type.GetElementType()이 Null일 경우 type.GenericArguments() 또한 Null일 경우 type.BaseType.GetGenericArguments()[0]로 할당
"summary": "Update an existing pet",
"description": "This updates an existing pet.",
"operationId": "updatePet",
"requestBody": {
"description": "Pet object that needs to be updated to the store",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/yellow"
}
}
}
},
"required": true
}
"yellow": {
"type": "object"
}
위의 결과로 나오나 기존 Color Class에 대한 이름이 존재하지 않음
"summary": "Update an existing pet",
"description": "This updates an existing pet.",
"operationId": "updatePet",
"requestBody": {
"description": "Pet object that needs to be updated to the store",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Color_yellow"
}
}
}
},
"required": true
}
"Color_yellow": {
"$ref" : "#/components/schemas/yellow"
}
"yellow": {
"type": "object"
}
위의 결과처럼 나오게 하는 것이 목표
{
"openapi": "3.0.1",
"info": {
"title": "Swagger Petstore (Injected)",
"description": "This is a sample server Petstore API designed by [http://swagger.io](http://swagger.io).",
"termsOfService": "https://github.com/Azure/azure-functions-openapi-extension",
"contact": {
"name": "Enquiry",
"url": "https://github.com/Azure/azure-functions-openapi-extension/issues",
"email": "[email protected]"
},
"license": {
"name": "MIT",
"url": "http://opensource.org/licenses/MIT"
},
"version": "1.0.0"
},
"servers": [
{
"url": "http://localhost:7071/api"
}
],
"paths": {
"/pet": {
"put": {
"tags": [
"pet"
],
"summary": "Update an existing pet",
"description": "This updates an existing pet.",
"operationId": "updatePet",
"requestBody": {
"description": "Pet object that needs to be updated to the store",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/yellow"
}
}
}
},
"required": true
},
"responses": {
"400": {
"description": "Invalid ID supplied",
"x-ms-summary": "Invalid ID supplied"
},
"404": {
"description": "Pet not found",
"x-ms-summary": "Pet not found"
},
"405": {
"description": "Validation exception",
"x-ms-summary": "Validation exception"
}
},
"security": [
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
],
"x-ms-visibility": "important"
},
"post": {
"tags": [
"pet"
],
"summary": "Add a new pet to the store",
"description": "This add a new pet to the store.",
"operationId": "addPet",
"requestBody": {
"description": "Pet object that needs to be added to the store",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/pet"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "New pet details added",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/pet"
}
}
},
"x-ms-summary": "New pet details added"
},
"405": {
"description": "Invalid input",
"x-ms-summary": "Invalid input"
}
},
"security": [
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
],
"x-ms-visibility": "important"
}
},
"/pet/findByStatus": {
"get": {
"tags": [
"pet"
],
"summary": "Finds Pets by status",
"description": "Multiple status values can be provided with comma separated strings.",
"operationId": "findPetsByStatus",
"parameters": [
{
"name": "status",
"in": "query",
"description": "Status values that need to be considered for filter",
"required": true,
"style": "form",
"schema": {
"type": "array",
"items": {
"enum": [
"available",
"pending",
"sold"
],
"type": "string",
"default": "available"
}
},
"x-ms-summary": "Pet status value",
"x-ms-visibility": "important"
}
],
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/pet"
}
}
}
},
"x-ms-summary": "successful operation"
},
"400": {
"description": "Invalid status value",
"x-ms-summary": "Invalid status value"
}
},
"security": [
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
],
"x-ms-visibility": "important"
}
},
"/pet/findByTags": {
"get": {
"tags": [
"pet"
],
"summary": "Finds Pets by tags",
"description": "Muliple tags can be provided with comma separated strings.",
"operationId": "findPetsByTags",
"parameters": [
{
"name": "tags",
"in": "query",
"description": "Tags to filter by",
"required": true,
"style": "form",
"schema": {
"type": "array",
"items": {
"type": "string"
}
},
"x-ms-summary": "Tags to filter by",
"x-ms-visibility": "important"
}
],
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/pet"
}
}
}
},
"x-ms-summary": "successful operation"
},
"400": {
"description": "Invalid tag value",
"x-ms-summary": "Invalid tag value"
}
},
"deprecated": true,
"security": [
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
],
"x-ms-visibility": "important"
}
},
"/pet/{petId}": {
"get": {
"tags": [
"pet"
],
"summary": "Find pet by ID",
"description": "Returns a single pet.",
"operationId": "getPetById",
"parameters": [
{
"name": "petId",
"in": "path",
"description": "ID of pet to return",
"required": true,
"schema": {
"type": "integer",
"format": "int64"
},
"x-ms-summary": "ID of pet to return",
"x-ms-visibility": "important"
}
],
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/pet"
}
}
},
"x-ms-summary": "successful operation"
},
"400": {
"description": "Invalid ID supplied",
"x-ms-summary": "Invalid ID supplied"
},
"404": {
"description": "Pet not found",
"x-ms-summary": "Pet not found"
}
},
"security": [
{
"api_key": [ ]
}
],
"x-ms-visibility": "important"
},
"post": {
"tags": [
"pet"
],
"summary": "Updates a pet in the store with form data",
"description": "This updates a pet in the store with form data.",
"operationId": "updatePetWithForm",
"parameters": [
{
"name": "petId",
"in": "path",
"description": "ID of pet that needs to be updated",
"required": true,
"schema": {
"type": "integer",
"format": "int64"
},
"x-ms-summary": "ID of pet that needs to be updated",
"x-ms-visibility": "important"
}
],
"requestBody": {
"description": "Pet object that needs to be added to the store",
"content": {
"application/x-www-form-urlencoded": {
"schema": {
"$ref": "#/components/schemas/petUrlForm"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/pet"
}
}
},
"x-ms-summary": "successful operation"
},
"405": {
"description": "Invalid input",
"x-ms-summary": "Invalid input"
}
},
"security": [
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
],
"x-ms-visibility": "important"
},
"delete": {
"tags": [
"pet"
],
"summary": "Deletes a pet",
"description": "This deletes a pet.",
"operationId": "deletePet",
"parameters": [
{
"name": "api_key",
"in": "header",
"schema": {
"type": "string"
},
"x-ms-visibility": "important"
},
{
"name": "petId",
"in": "path",
"description": "Pet id to delete",
"required": true,
"schema": {
"type": "integer",
"format": "int64"
},
"x-ms-summary": "Pet id to delete",
"x-ms-visibility": "important"
}
],
"responses": {
"200": {
"description": "successful operation",
"x-ms-summary": "successful operation"
},
"400": {
"description": "Invalid ID supplied",
"x-ms-summary": "Invalid ID supplied"
},
"404": {
"description": "Pet not found",
"x-ms-summary": "Pet not found"
}
},
"security": [
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
],
"x-ms-visibility": "important"
}
},
"/pet/{petId}/uploadImage": {
"post": {
"tags": [
"pet"
],
"summary": "Uploads an image",
"description": "This uploads an image.",
"operationId": "uploadFile",
"parameters": [
{
"name": "petId",
"in": "path",
"description": "ID of pet to update",
"required": true,
"schema": {
"type": "integer",
"format": "int64"
},
"x-ms-summary": "ID of pet to update",
"x-ms-visibility": "important"
}
],
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"$ref": "#/components/schemas/petFormData"
}
}
}
},
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/apiResponse"
}
}
},
"x-ms-summary": "successful operation"
}
},
"security": [
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
],
"x-ms-visibility": "important"
}
},
"/store/inventory": {
"get": {
"tags": [
"store"
],
"summary": "Returns pet inventories by status",
"description": "This returns a map of status codes to quantities.",
"operationId": "getInventory",
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": {
"type": "integer",
"format": "int32"
}
}
}
}
}
},
"security": [
{
"api_key": [ ]
}
],
"x-ms-visibility": "important"
}
},
"/store/order": {
"post": {
"tags": [
"store"
],
"summary": "Places an order for a pet",
"description": "This places an order for a pet.",
"operationId": "placeOrder",
"requestBody": {
"description": "Order placed for purchasing the pet",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/order"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/order"
}
}
},
"x-ms-summary": "successful operation"
},
"400": {
"description": "Invalid input",
"x-ms-summary": "Invalid input"
}
},
"x-ms-visibility": "important"
}
},
"/store/order/{orderId}": {
"get": {
"tags": [
"store"
],
"summary": "Finds purchase order by ID",
"description": "This finds purchase order by ID.",
"operationId": "getOrderById",
"parameters": [
{
"name": "orderId",
"in": "path",
"description": "ID of order that needs to be fetched",
"required": true,
"schema": {
"type": "integer",
"format": "int64"
},
"x-ms-summary": "ID of order that needs to be fetched",
"x-ms-visibility": "important"
}
],
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/order"
}
}
}
},
"400": {
"description": "Invalid ID supplied",
"x-ms-summary": "Invalid ID supplied"
},
"404": {
"description": "Order not found",
"x-ms-summary": "Order not found"
}
},
"x-ms-visibility": "important"
},
"delete": {
"tags": [
"store"
],
"summary": "Deletes purchase order by ID",
"description": "For valid response try integer IDs with positive integer value. Negative or non - integer values will generate API errors.",
"operationId": "deleteOrder",
"parameters": [
{
"name": "orderId",
"in": "path",
"description": "ID of order that needs to be deleted",
"required": true,
"schema": {
"type": "integer",
"format": "int64"
},
"x-ms-summary": "ID of order that needs to be deleted",
"x-ms-visibility": "important"
}
],
"responses": {
"400": {
"description": "Invalid ID supplied",
"x-ms-summary": "Invalid ID supplied"
},
"404": {
"description": "Order not found",
"x-ms-summary": "Order not found"
}
},
"x-ms-visibility": "important"
}
},
"/user": {
"post": {
"tags": [
"user"
],
"summary": "Creates user",
"description": "This can only be done by the logged in user.",
"operationId": "createUser",
"requestBody": {
"description": "Created user object",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/user"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/user"
}
}
},
"x-ms-summary": "successful operation"
}
},
"x-ms-visibility": "important"
}
},
"/user/createWithArray": {
"post": {
"tags": [
"user"
],
"summary": "Creates list of users with given input array",
"description": "This Creates list of users with given input array.",
"operationId": "createUsersWithArrayInput",
"requestBody": {
"description": "List of user object",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/user"
}
}
}
},
"required": true
},
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/user"
}
}
}
},
"x-ms-summary": "successful operation"
}
},
"x-ms-visibility": "important"
}
},
"/user/createWithList": {
"post": {
"tags": [
"user"
],
"summary": "Creates list of users with given input array",
"description": "This Creates list of users with given input array.",
"operationId": "createUsersWithListInput",
"requestBody": {
"description": "List of user object",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/user"
}
}
}
},
"required": true
},
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/user"
}
}
}
},
"x-ms-summary": "successful operation"
}
},
"x-ms-visibility": "important"
}
},
"/user/login": {
"get": {
"tags": [
"user"
],
"summary": "Logs user into the system",
"description": "This logs user into the system.",
"operationId": "loginUser",
"parameters": [
{
"name": "username",
"in": "query",
"description": "The user name for login",
"required": true,
"schema": {
"type": "string"
},
"x-ms-summary": "The user name for login",
"x-ms-visibility": "important"
},
{
"name": "password",
"in": "query",
"description": "The password for login in clear text",
"required": true,
"schema": {
"type": "string"
},
"x-ms-summary": "The password for login in clear text",
"x-ms-visibility": "important"
}
],
"responses": {
"200": {
"description": "successful operation",
"headers": {
"X-Rate-Limit": {
"description": "calls per hour allowed by the user",
"schema": {
"type": "integer",
"format": "int32"
}
},
"X-Expires-After": {
"description": "date in UTC when token expires",
"schema": {
"type": "string",
"format": "date-time"
}
}
},
"content": {
"text/plain": {
"schema": {
"type": "string"
}
}
},
"x-ms-summary": "successful operation"
}
},
"x-ms-visibility": "important"
}
},
"/user/logout": {
"get": {
"tags": [
"user"
],
"summary": "Logs out current logged in user session",
"description": "This logs out current logged in user session.",
"operationId": "logoutUser",
"responses": {
"200": {
"description": "successful operation",
"x-ms-summary": "successful operation"
}
},
"x-ms-visibility": "important"
}
},
"/user/{username}": {
"get": {
"tags": [
"user"
],
"summary": "Gets user by user name",
"description": "This gets user by user name.",
"operationId": "getUserByName",
"parameters": [
{
"name": "username",
"in": "path",
"description": "The user name for login",
"required": true,
"schema": {
"type": "string"
},
"x-ms-summary": "The user name for login",
"x-ms-visibility": "important"
}
],
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/user"
}
}
},
"x-ms-summary": "successful operation"
},
"400": {
"description": "Invalid username supplied",
"x-ms-summary": "Invalid username supplied"
},
"404": {
"description": "User not found",
"x-ms-summary": "User not found"
}
},
"x-ms-visibility": "important"
}
},
"/ping": {
"get": {
"tags": [
"ping"
],
"summary": "Pings for health check",
"description": "This pings for health check.",
"operationId": "ping",
"responses": {
"200": {
"description": "Successful operation",
"content": {
"text/plain": {
"schema": {
"type": "string"
}
}
},
"x-ms-summary": "Successful operation"
}
},
"x-ms-visibility": "important"
}
}
},
"components": {
"schemas": {
"apiResponse": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32",
"nullable": true
},
"type": {
"type": "string"
},
"message": {
"type": "string"
}
}
},
"category": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"order": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"petId": {
"type": "integer",
"format": "int64"
},
"quantity": {
"type": "integer",
"format": "int32"
},
"shipDate": {
"type": "string",
"format": "date-time"
},
"status": {
"enum": [
"placed",
"approved",
"delivered"
],
"type": "string",
"description": "Order Status"
},
"complete": {
"type": "boolean",
"default": false
}
}
},
"pet": {
"required": [
"photoUrls",
"name"
],
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/components/schemas/category"
},
"name": {
"minLength": 1,
"type": "string"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/components/schemas/tag"
}
},
"status": {
"enum": [
"available",
"pending",
"sold"
],
"type": "string",
"description": "pet status in the store"
}
}
},
"petFormData": {
"type": "object",
"properties": {
"additionalMetadata": {
"type": "string",
"description": "Additional data to pass to server"
},
"file": {
"type": "string",
"description": "File to upload",
"format": "binary"
}
}
},
"petUrlForm": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Updated name of the pet"
},
"status": {
"enum": [
"available",
"pending",
"sold"
],
"type": "string",
"description": "Updated status of the pet"
}
}
},
"tag": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"user": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"username": {
"type": "string"
},
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"email": {
"type": "string"
},
"password": {
"type": "string"
},
"phone": {
"type": "string"
},
"userStatus": {
"type": "integer",
"description": "User Status",
"format": "int32"
}
}
},
"yellow": {
"type": "object"
}
},
"securitySchemes": {
"petstore_auth": {
"type": "oauth2",
"flows": {
"implicit": {
"authorizationUrl": "http://petstore.swagger.io/oauth/dialog",
"scopes": {
"write:pets": "modify pets in your account",
"read:pets": "read your pets"
}
}
}
},
"api_key": {
"type": "apiKey",
"name": "api_key",
"in": "header"
}
}
}
}