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

Proposal swag 2.0 using open api 3.0 #548

Open
Nerzal opened this issue Oct 29, 2019 · 40 comments
Open

Proposal swag 2.0 using open api 3.0 #548

Nerzal opened this issue Oct 29, 2019 · 40 comments
Labels

Comments

@Nerzal
Copy link
Contributor

Nerzal commented Oct 29, 2019

Hey everyone.
As the support of Swagger 2.0 is pretty stable now, we should start to make a list of all features / changes we need to support Open Api 3.0.

We might create a new 2.0 milestone and move/create Open Api 3.0 support issues in there.

@superdave
Copy link

I would love this, we've been holding off on it at work because it's not OpenAPI 3. What's best for me to help?

@ubogdan
Copy link
Contributor

ubogdan commented Feb 26, 2020

@superdave PR is always welcome.

@tylfin
Copy link

tylfin commented Jun 26, 2020

Would love this to get access to the oneOf functionality for schema responses

@alandtsang
Copy link

Does it support OpenAPI Specification 3 now?

@Nerzal
Copy link
Contributor Author

Nerzal commented Dec 11, 2020

nope.
The spec lib which is used under the hood does only support Swagger 2.0.

We'd need to switch to a spec lib that supports OpenAPI 3, if there is such a lib by now

@ipfans
Copy link

ipfans commented Dec 16, 2020

@Nerzal maybe just try https://github.com/getkin/kin-openapi

@OneCricketeer
Copy link

I've found a way to generate openapi3 specs from the output of this project

#386 (comment)

@hotrungnhan
Copy link

upppppppppppppppppppppppppppppppppppppp!

@vtopc
Copy link

vtopc commented Sep 23, 2021

Any progress with this? Except for workaround

@ubogdan
Copy link
Contributor

ubogdan commented Sep 23, 2021

I don't think It will happen any time soon.

@Nerzal
Copy link
Contributor Author

Nerzal commented Sep 23, 2021

i have a branch, where i refactore swaggo to use open api 3.0 specs, but will still take some weeks/months until it is finished, as i do not have that much time at hand to complete it

@ubogdan
Copy link
Contributor

ubogdan commented Sep 24, 2021

We can't support this kind of change overnight.
More than that, this will introduce breaking changes, and this has to go with v2.
On the other hand, we see many requests regarding improvements and bug fixes for the current parser.
Working on a new version too early will introduce the additional overhead of merging the v1 fixes in the new branch.

@vtopc
Copy link

vtopc commented Sep 24, 2021

i have a branch, where i refactore swaggo to use open api 3.0 specs, but will still take some weeks/months until it is finished, as i do not have that much time at hand to complete it

Could you share the branch?

@Nerzal
Copy link
Contributor Author

Nerzal commented Sep 27, 2021

Still lots of work to do, but "soon" i'll have some time.

https://github.com/Nerzal/swag/tree/feature/openapi3

Here is the comparison:
Nerzal@a962819

@ubogdan ubogdan mentioned this issue Dec 11, 2021
@ubogdan ubogdan added the feature label Jan 1, 2022
@guiyomh
Copy link

guiyomh commented Mar 11, 2022

@Nerzal How Can I help you to finish your work?

@santosh
Copy link

santosh commented Aug 24, 2022

Is there any alternative project which supports OpenAPI v3? I think we are way behind.

@ubogdan
Copy link
Contributor

ubogdan commented Aug 24, 2022

@santosh eventually we should offer support on how to migrate from swag.

@Nerzal
Copy link
Contributor Author

Nerzal commented Mar 21, 2023

I started a new attempt.

I'm making pretty good progress here.
I can already parse general API info + lots of the operation parts.

Nerzal#5

@ubogdan
Copy link
Contributor

ubogdan commented Mar 21, 2023

I can make v2 branch for openapi v3 if you want.

@Nerzal
Copy link
Contributor Author

Nerzal commented Mar 23, 2023

Sounds good.
My current goal is to implement everything we have now in the OpenAPI 3.1 spec.
As soon as this is working i'll make a PR to the new V2 branch.

@ubogdan
Copy link
Contributor

ubogdan commented Mar 23, 2023

Done. Please make the PR against this branch https://github.com/swaggo/swag/tree/v2

@Nerzal
Copy link
Contributor Author

Nerzal commented Mar 23, 2023

Okay, i'll open a Work in Progress PR now.
We can use that to potentially discuss implementation details.

Some comments like host, basepath and some more do not exist anymore and need a new swag comment syntax.
There are some more examples. I guess some of them could need some discussion, when i come to the point.

I'm currently working full time on this project, so that will happen pretty soon

@ubogdan
Copy link
Contributor

ubogdan commented Mar 23, 2023

@Nerzal Let's keep it simple. This doesn't mean it has to be done in 1 single PR.
We first need an MVP and we will do a beta release. So the community will have the chance to test and provide feedback.

@hookenz
Copy link

hookenz commented Mar 24, 2023

would love anyOf to support multiple body schemas

@Nerzal
Copy link
Contributor Author

Nerzal commented Mar 24, 2023

I guess we could call it an MVP as soon as response objects and request bodies are correctly parsed, which is what i am working on currently.

My next step is Adding some Tests, as parsing a real world documentation while debugging tends to get pretty complicated.

@Nerzal
Copy link
Contributor Author

Nerzal commented Mar 24, 2023

image

Yes implementing tests helps.
More or less i try to adapt all existing tests

@Nerzal
Copy link
Contributor Author

Nerzal commented Apr 5, 2023

The first throw of the implementation is now on the V2 branch. It needs testing, feel free to report issues. I'll try to fix them

@ubogdan
Copy link
Contributor

ubogdan commented Apr 5, 2023

v2.0.0-beta is avail for testing ...

@Breigner01
Copy link

Hi,

I see that a lot of work is being done to implement open API 3.0 specifications, (there are commits dating from last week on branch v2).
Is there an issue or discussion that I could follow to get updated on how this goes and even what needs to be done so that I could even try to help implement certain things?

@eliyahus
Copy link

@Nerzal thanks for adding the ability to generate OpenAPI v3.1! Any plans to support generation of OpenAPI 3.0 spec?

@Bijan-Massoumi
Copy link

where can I find documentation on 3.1 generation? also how differently do I need to annotate / is it a smooth transition?

@wenqi73
Copy link

wenqi73 commented Aug 24, 2023

Any progress on the spec 3.0 generation?

@santosh
Copy link

santosh commented Aug 24, 2023

I'd really appreciate if someone could write a blog post (or tutorial video) on how to use the latest v2 of swaggo/swag which uses OpenAPI v3?

@memphis88
Copy link

You can use the new version programmatically, e.g.

package main

import (
	"log"

	"github.com/swaggo/swag/v2"
	"github.com/swaggo/swag/v2/gen"
)

func main() {
	err := gen.New().Build(&gen.Config{
		SearchDir: "./",
		MainAPIFile:        "internal/v2/api/service.go",
		PropNamingStrategy: swag.CamelCase,
		OutputDir:          "./docs",
		OutputTypes:        []string{"json", "yaml"},
		ParseDependency:    true,
		// This is a swag/v2 field
		GenerateOpenAPI3Doc: false,
		ParseVendor:        true,
	})

	if err != nil {
		log.Fatalf("Failed to generate swagger.json err: %v", err)
	}
}

I suppose the new flag is also available on the cli, I just haven't tried that. As far as I could tell the new version converts v2 to v3 by using the same annotations but I found it buggy so far.

@rattrayalex
Copy link

It seems that development of OpenAPI v3.x has stalled out, is that so? Does anyone have alternative libraries that they can recommend to migrate to?

@obrhoff
Copy link

obrhoff commented Feb 2, 2024

I personally migrated to oapi-codegen. In my opinion, it is better to write the API specification first and then generate the interfaces on the server/clients based on it.

For migration, I used the file generated by Swaggo as a basis to generate the interface. I started making my specification changes directly in the YAML file from that point onward.

@simranjitnagra18
Copy link

@Nerzal Any progress on the spec 3.0 generation? When is the expected release date for v2?

@simranjitnagra18
Copy link

It seems that development of OpenAPI v3.x has stalled out, is that so? Does anyone have alternative libraries that they can recommend to migrate to?

@rattrayalex did you get any alternative library?

@rattrayalex
Copy link

I've heard good things about https://github.com/danielgtaylor/huma but haven't tried it myself.

@8thgencore
Copy link

8thgencore commented Mar 4, 2024

I've heard good things about https://github.com/danielgtaylor/huma but haven't tried it myself.

there is also such a framework that works with go 1.22
https://github.com/go-fuego/fuego

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

No branches or pull requests