Skip to content
Discussion options

You must be logged in to vote

Mutual TLS is supported by OpenAPI 3.1, and by this library too. Please check an example below:

	reflector := openapi31.Reflector{}
	securityName := "mTLS-example"

	// Declare security scheme.
	reflector.SpecEns().ComponentsEns().WithSecuritySchemesItem(
		securityName,
		openapi31.SecuritySchemeOrReference{
			SecurityScheme: (&openapi31.SecurityScheme{MutualTLS: &openapi31.MutualTLS{}}).
				WithDescription("My mutual TLS security."),
		},
	)

	oc, err := reflector.NewOperationContext(http.MethodGet, "/secure")
	require.NoError(t, err)
	oc.AddRespStructure(struct {
		Secret string `json:"secret"`
	}{})

	// Add security requirement to operation.
	oc.AddSecurity(securityName)

	// Add o…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@yuanhh
Comment options

Answer selected by yuanhh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants