Inconsitency between Swgger spec and Code #7686

Closed
opened 2025-11-02 07:33:35 -06:00 by GiteaMirror · 6 comments
Owner

Originally created by @nektro on GitHub (Aug 12, 2021).

  • Gitea version (or commit ref): v1.14.6
  • Git version: 2.30.2
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No

Description

For the Repository type (there's bound to be others but I did not check everything) there is an inconsistency between the OpenAPI spec generated by Swagger and actual backing Go code.

https://try.gitea.io/api/swagger#model-Repository

https://pkg.go.dev/code.gitea.io/gitea@v1.14.6/modules/structs#Repository

As you will see, there are a number of fields which have their json tag paired with omitempty. However, these fields are not marked as optional in the swagger docs and so attempting to generate Gitea client bindings for another language based on these docs becomes problematic.

Swagger actually expects a required list and says that all fields are optional by default. So by Gitea not having a required list it is not accurately Modelling its models.

Originally created by @nektro on GitHub (Aug 12, 2021). - Gitea version (or commit ref): v1.14.6 - Git version: 2.30.2 - Can you reproduce the bug at https://try.gitea.io: - [x] Yes (provide example URL) - [ ] No ## Description For the `Repository` type (there's bound to be others but I did not check everything) there is an inconsistency between the OpenAPI spec generated by Swagger and actual backing Go code. https://try.gitea.io/api/swagger#model-Repository https://pkg.go.dev/code.gitea.io/gitea@v1.14.6/modules/structs#Repository As you will see, there are a number of fields which have their json tag paired with `omitempty`. However, these fields are not marked as optional in the swagger docs and so attempting to generate Gitea client bindings for another language based on these docs becomes problematic. Swagger [actually expects a required list](https://swagger.io/docs/specification/data-models/data-types/#required) and says that all fields are optional by default. So by Gitea not having a `required` list it is not accurately Modelling its models.
GiteaMirror added the type/docs label 2025-11-02 07:33:35 -06:00
Author
Owner

@nektro commented on GitHub (Aug 12, 2021):

It appears some definitions do actually have this property. Searching for "required": [ in the raw json yields 26 results. However, given that there are 142 definitions as of this writing, I believe this issue still stands.

@nektro commented on GitHub (Aug 12, 2021): It appears some definitions do actually have this property. Searching for `"required": [` in the raw json yields 26 results. However, given that there are 142 definitions as of this writing, I believe this issue still stands.
Author
Owner

@nektro commented on GitHub (Sep 5, 2021):

?

@nektro commented on GitHub (Sep 5, 2021): ?
Author
Owner

@nektro commented on GitHub (Oct 19, 2021):

?

@nektro commented on GitHub (Oct 19, 2021): ?
Author
Owner

@lunny commented on GitHub (Oct 21, 2021):

try.gitea.io will always follow main branch and another URL of you is for v1.14.6. They may changed a lot.

@lunny commented on GitHub (Oct 21, 2021): try.gitea.io will always follow main branch and another URL of you is for v1.14.6. They may changed a lot.
Author
Owner

@nektro commented on GitHub (Oct 21, 2021):

it was the most recent at the time

@nektro commented on GitHub (Oct 21, 2021): it was the most recent at the time
Author
Owner

@lunny commented on GitHub (May 25, 2023):

As mentioned above, you need to compare the same version. I will close this one, please reopen it if you have further quesiton.

@lunny commented on GitHub (May 25, 2023): As mentioned above, you need to compare the same version. I will close this one, please reopen it if you have further quesiton.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#7686