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
implement new field: x-go-type-import #633
implement new field: x-go-type-import #633
Conversation
Tried to use your x-go-type with an imported type but as a result it produces a pointer to this type. Do you have nullable in your code? |
@Viltonhoy oapi-codegen generates pointer type when a field is not in required list schemas:
Pet:
properties:
age:
x-go-type: uuid.UUID
x-go-type-import:
path: github.com/google/uuid
required:
- age Result: type Pet struct {
Age uuid.UUID `json:"age"`
} |
@deepmap-marcinr Hello, could you check this changes plz, if you have free time?:) |
Wht not testing the |
@othalla thanks for your comment, I fixed it |
I'm really looking forward to this PR in the master |
We can already add any arbitrary imports via the configuration file for oapi-codegen, so I was wondering why we want to do this via the spec? I've been trying to avoid having multiple ways of doing the same thing where it can be helped. |
@deepmap-marcinr Hi! Thanks for your reply! :) |
* implement new field: x-go-type-import * implement getting of request bodies imports * implement getting of responses imports * refactoring: rename GetImportsFromSchema to GetImports * refactoring: add error wrapping * update README * fix: generate import only if define x-go-type and x-go-type-import * fix: bug of import generation * fix: remove useless checking * docs: add description for 'name' field * test: add tests for x-go-type-import into codegen_test * docs: fix README.md * refactor: fix error msg * refactor: use existing importMap type * refactor: fix error msg Co-authored-by: Vladimir Stepanov <v.stepanov@redmadrobot.com>
Close #498