Skip to content
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

Issue with file uploads #102

Open
joshstrange opened this issue Jun 3, 2020 · 3 comments
Open

Issue with file uploads #102

joshstrange opened this issue Jun 3, 2020 · 3 comments

Comments

@joshstrange
Copy link

The JSON Swagger file looks like it should work according the the spec and I dug down into the code and I think the issue is in mapFormDataToV2 (or one level above).

Relevant parts of my spec:

"/photos/fromUpload": {
  "post": {
	"operationId": "createFromUpload",
	"summary": "",
	"parameters": [],
	"requestBody": {
	  "required": true,
	  "description": "Upload File",
	  "content": {
		"multipart/form-data": {
		  "schema": {
			"$ref": "#/components/schemas/FileUploadDto"
		  }
		}
	  }
	},
	"responses": {
	  "201": {
		"description": "",
		"content": {
		  "application/json": {
			"schema": {
			  "$ref": "#/components/schemas/PhotoEntity"
			}
		  }
		}
	  }
	},
	"tags": [
	  "photos"
	]
  }
},

......

"FileUploadDto": {
	"type": "object",
	"properties": {
	  "file": {
		"type": "string",
		"format": "binary"
	  }
	},
	"required": [
	  "file"
	]
  },

From debugging the code I see that right being passed into mapFormDataToV2 my multiDataProperties is:

{ schema: { '$ref': '#/components/schemas/FileUploadDto' } }

but inside mapFormDataToV2 it doesn't "expand" the $ref like you do in getResponseType.ts. I tried expanding the FileUploadDto inline in the code and it correctly generated the axios code.

I feel like the fix is to either copy/paste some/all of the logic from getResponseType.ts into mapFormDataToV2 or abstract the logic away into another function they both use. Thoughts?

@Manweill
Copy link
Owner

Manweill commented Jun 5, 2020

does not support uploading files by reference dto now.

@joshstrange
Copy link
Author

@Manweill Would you accept a PR that made it work with reference DTO's?

@Manweill
Copy link
Owner

Manweill commented Jun 5, 2020

@joshstrange
Welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants