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

Can not build API in GO using https://github.com/deepmap/oapi-codegen #35

Closed
awildeep opened this issue May 12, 2023 · 8 comments
Closed
Labels
accepted Good idea and is being worked on

Comments

@awildeep
Copy link

I am attempting to play with the API using golang, however trying to build types and the client are failing using oapi-codegen.

oapi-codegen/oapi-codegen#1045

It seems oapi-codegen requires fairly extensive mapping to be done for $ref's, and it does not like relative paths at all. I am posting this issue here in case anyone else in the community has managed to build the API for golang (either with oapi-codegen or some other tool) and can help me get started.

Otherwise, I'll have to resign myself to manually building a client API in go.

Thanks for any suggestions, thoughts, or ideas you might have in advance.

@ptxmac
Copy link

ptxmac commented May 13, 2023

Take a look at https://github.com/ogen-go/ogen - it looks like a more active and (maybe) better openapi generator for go.
It still complains about a few problems in the spec, but that can be fixed by just removing a few (possible wrong?) fields:

diff --git a/models/Cooldown.json b/models/Cooldown.json
index f10e582..abbc344 100644
--- a/models/Cooldown.json
+++ b/models/Cooldown.json
@@ -20,8 +20,7 @@
     "expiration": {
       "type": "string",
       "format": "date-time",
-      "description": "The date and time when the cooldown expires in ISO 8601 format",
-      "minimum": 0
+      "description": "The date and time when the cooldown expires in ISO 8601 format"
     }
   },
   "required": [
diff --git a/models/Survey.json b/models/Survey.json
index 7cd4f44..178ab48 100644
--- a/models/Survey.json
+++ b/models/Survey.json
@@ -22,8 +22,7 @@
     "expiration": {
       "type": "string",
       "format": "date-time",
-      "description": "The date and time when the survey expires. After this date and time, the survey will no longer be available for extraction.",
-      "minimum": 0
+      "description": "The date and time when the survey expires. After this date and time, the survey will no longer be available for extraction."
     },
     "size": {
       "type": "string",

@awildeep
Copy link
Author

@ptxmac thanks for the suggestion. I'll take a look at it when I get some time.

@space-admiral
Copy link
Contributor

Thanks for bringing this up! I think other languages had similar issues with references. We'll update the docs with an example people in the community found: you can get the bundled export here from stoplight:
https://stoplight.io/api/v1/projects/spacetraders/spacetraders/nodes/reference/SpaceTraders.json?fromExportButton=true&snapshotType=http_service&deref=optimizedBundle

@space-admiral space-admiral added the accepted Good idea and is being worked on label May 21, 2023
@space-admiral
Copy link
Contributor

Going to add some special notes to the docs about using the bundled reference.

@FloWi
Copy link
Contributor

FloWi commented May 29, 2023

This "minimum": 0 also caused problems using smithy-translate. After removing this entry the translation into a smithy-model worked.

@space-admiral
Copy link
Contributor

I think we can remove these fields. Do we have any idea why the tooling doesn't support minimum 0?

@FloWi
Copy link
Contributor

FloWi commented Jun 10, 2023

Guess it doesn't make sense to have a string of type dateTime have a minimum-value of 0. maybe it'd work if you give it a minimum value of a valid date string? But tbh I wouldn't bother and just remove it :)

@space-admiral
Copy link
Contributor

I think this is fixed - the only minimum properties now should be on integer types. Thanks again for following up on the reason why this was breaking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Good idea and is being worked on
Projects
None yet
Development

No branches or pull requests

4 participants