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

feat(controller): getGroupById returns events #129

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AlexisAoun
Copy link
Contributor

I had to remove genre, admin and groups from events required filed.

OpenAPI would not fetch events in the get group call with those requirements.

@AlexisAoun AlexisAoun linked an issue Mar 22, 2022 that may be closed by this pull request
@AlexisAoun
Copy link
Contributor Author

AlexisAoun commented Mar 22, 2022

I guess if you fetch groups, with a list of events, that returns groups this could cause some kind of circular reference ? Causing openAPI to not be happy ?

Also I have trouble understanding why ALL the attributes where required. Not only for events. shouldn't really be the MOST important information such as the name, the date etc. ?

@RomainGuarinoni
Copy link
Collaborator

I had the same problem with the group. I think the best solution is to create another schemas for event and eventDescription, as i have done with the group below :

group: {
type: 'object',
required: ['name', 'description', 'location', 'genres', 'id', 'members'],
properties: {
id: { type: 'string' },
name: { type: 'string' },
description: { type: 'string' },
location: { type: 'string', enum: ['Douai', 'Lille'] },
genres: {
type: 'array',
items: { $ref: '#/components/schemas/genre' },
},
members: {
type: 'array',
items: { $ref: '#/components/schemas/groupMember' },
},
},
},

groupDescription: {
type: 'object',
required: ['name', 'description', 'location', 'genres'],
properties: {
name: { type: 'string' },
description: { type: 'string' },
location: { type: 'string', enum: ['Douai', 'Lille'] },
genres: {
type: 'array',
items: { $ref: '#/components/schemas/genre' },
},
},
},

@AlexisAoun
Copy link
Contributor Author

Okay but why solving this by creating a whole new schema ? Why having all the attributes as required where by definition we should only have the most important ones ?

@RomainGuarinoni
Copy link
Collaborator

because, for example, in the route Get /eventsById, the members is required. So i think it is the best solution to make two descriptions.

@RomainGuarinoni
Copy link
Collaborator

RomainGuarinoni commented Mar 22, 2022

But indeed, the fact that we have to re create a all new schema is not perfect.. maybe we could use the AllOf of openAPI, I've already done it for the Get /musicianById like below :

schema: {
              type: 'object',
              allOf: [
                { $ref: '#/components/schemas/musician' },
                {
                  type: 'object',
                  required: ['groups'],
                  properties: {
                    groups: {
                      type: 'array',
                      items: {
                        $ref: '#/components/schemas/groupDescription',
                      },
                    },
                  },
                },
              ],
            },
 ```

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

Successfully merging this pull request may close these issues.

get groups by id should return events of the group
2 participants