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

fix invalid swagger #2988

Merged
merged 3 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/_static/discovery/v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ paths:
- discovery
responses:
"200":
description:
description: List of configured Discovery Services
content:
application/json:
schema:
Expand Down Expand Up @@ -162,15 +162,15 @@ paths:
- name: did
in: path
required: true
example:
- did:web:example.com
- did:web:example.com:iam:user
- did:web:example.com%3A9443
- did:web:example.com%3A9443:iam:user
content:
plain/text:
schema:
type: string
example:
- did:web:example.com
- did:web:example.com:iam:user
- did:web:example.com%3A9443
- did:web:example.com%3A9443:iam:user
get:
summary: Retrieves the activation status a DID on a Discovery Service.
description: |
Expand Down
4 changes: 4 additions & 0 deletions docs/_static/vcr/vcr_v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,8 @@ components:
- type: string
example: "https://nuts.nl/credentials/v1"
- type: array
items:
type: string
example: ["https://www.w3.org/2018/credentials/v1", "https://nuts.nl/credentials/v1"]
default: ["https://www.w3.org/2018/credentials/v1", "https://nuts.nl/credentials/v1"]
type:
Expand All @@ -542,6 +544,8 @@ components:
- type: string
example: "VerifiableCredential"
- type: array
items:
type: string
example: ["VerifiableCredential", "NutsOrganizationCredential"]
issuer:
description: DID according to Nuts specification.
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/auth/selfsigned/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func issueOrganizationCredential(organization *did.Document, name, city string)
},
Visibility: &visibility,
}
err := request.Type.FromIssueVCRequestType1([]any{"VerifiableCredential", "NutsOrganizationCredential"})
err := request.Type.FromIssueVCRequestType1([]string{"VerifiableCredential", "NutsOrganizationCredential"})
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions vcr/api/vcr/v2/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func TestWrapper_IssueVC(t *testing.T) {
CredentialSubject: expectedRequestedVC.CredentialSubject,
Visibility: &public,
}
_ = request.Type.FromIssueVCRequestType1([]any{credentialType.String()})
_ = request.Type.FromIssueVCRequestType1([]string{credentialType.String()})
// assert that credential.NutsV1ContextURI is added if the request does not contain @context
testContext.mockIssuer.EXPECT().Issue(testContext.requestCtx, expectedRequestedVC, issuer.CredentialOptions{
Publish: true,
Expand All @@ -95,8 +95,8 @@ func TestWrapper_IssueVC(t *testing.T) {
CredentialSubject: expectedRequestedVC.CredentialSubject,
Visibility: &public,
}
require.NoError(t, request.Context.FromIssueVCRequestContext1([]any{vc.VCContextV1, credential.NutsV1ContextURI}))
require.NoError(t, request.Type.FromIssueVCRequestType1([]any{vc.VerifiableCredentialType, credentialType.String()}))
require.NoError(t, request.Context.FromIssueVCRequestContext1([]string{vc.VCContextV1, credential.NutsV1ContextURI.String()}))
require.NoError(t, request.Type.FromIssueVCRequestType1([]string{vc.VerifiableCredentialType, credentialType.String()}))
testContext.mockIssuer.EXPECT().Issue(testContext.requestCtx, expectedRequestedVC, issuer.CredentialOptions{
Publish: true,
Public: true,
Expand Down
4 changes: 2 additions & 2 deletions vcr/api/vcr/v2/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 4 additions & 15 deletions vcr/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,8 @@ func issueVC() *cobra.Command {
// set @context
if args[0] != "" {
request.Context = new(api.IssueVCRequest_Context)
if anyContexts := toAnyStrings(args[0]); len(anyContexts) > 1 {
//return errors.New("only 1 @context supported")
if err := request.Context.FromIssueVCRequestContext1(anyContexts); err != nil {
if contexts := strings.Split(args[0], ","); len(contexts) != 1 {
if err := request.Context.FromIssueVCRequestContext1(contexts); err != nil {
return fmt.Errorf("invalid @context: %w", err)
}
} else {
Expand All @@ -181,8 +180,8 @@ func issueVC() *cobra.Command {
}
}
// set type
if anyTypes := toAnyStrings(args[1]); len(anyTypes) > 1 {
if err := request.Type.FromIssueVCRequestType1(anyTypes); err != nil {
if types := strings.Split(args[1], ","); len(types) != 1 {
if err := request.Type.FromIssueVCRequestType1(types); err != nil {
return fmt.Errorf("invalid credential type: %w", err)
}
} else {
Expand Down Expand Up @@ -213,16 +212,6 @@ func issueVC() *cobra.Command {
return result
}

// toAnyStrings splits input at ',' and returns the resulting parts as []any
func toAnyStrings(input string) []any {
parts := strings.Split(input, ",")
anyParts := make([]any, len(parts))
for i, part := range parts {
anyParts[i] = any(part)
}
return anyParts
}

// httpClient creates a remote client
func httpClient(config core.ClientConfig) api.HTTPClient {
return api.HTTPClient{
Expand Down
4 changes: 2 additions & 2 deletions vcr/cmd/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ func TestCmd_Issue(t *testing.T) {
t.Run("ok - plural parameters", func(t *testing.T) {
otherContextURI := "http://other-context"
var contextURIsAPI v2.IssueVCRequest_Context
require.NoError(t, contextURIsAPI.FromIssueVCRequestContext1([]any{contextURI, otherContextURI}))
require.NoError(t, contextURIsAPI.FromIssueVCRequestContext1([]string{contextURI, otherContextURI}))
otherCredentialType := "other-type"
var credentialTypesAPI v2.IssueVCRequest_Type
require.NoError(t, credentialTypesAPI.FromIssueVCRequestType1([]any{credentialType, otherCredentialType}))
require.NoError(t, credentialTypesAPI.FromIssueVCRequestType1([]string{credentialType, otherCredentialType}))
cmd := newCmd(t)
handler := setupServer(t, http.StatusOK, "{}")
cmd.PersistentFlags().AddFlagSet(core.ClientConfigFlags())
Expand Down
Loading