diff --git a/README.md b/README.md index 9d23d9c..0449135 100644 --- a/README.md +++ b/README.md @@ -93,5 +93,5 @@ - https://api-platform.com/docs/distribution/ - https://api-platform.com/docs/core/extending/ - ddev exec bin/console api:openapi:export --yaml + ddev exec bin/console api:openapi:export --yaml >> openapi.yaml -> export OpenApi spec \ No newline at end of file diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 08cc324..1333cbe 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -20,7 +20,7 @@ security: jwt: ~ main: json_login: - check_path: auth # The name in routes.yaml is enough for mapping + check_path: /auth # The name in routes.yaml is enough for mapping username_path: email password_path: password success_handler: lexik_jwt_authentication.handler.authentication_success diff --git a/openapi.yaml b/openapi.yaml new file mode 100644 index 0000000..e20b269 --- /dev/null +++ b/openapi.yaml @@ -0,0 +1,742 @@ +openapi: 3.1.0 +info: + title: 'Matsen API Platform' + description: '' + version: 1.0.0 +servers: + - + url: / + description: '' +paths: + /api/posts: + get: + operationId: api_posts_get_collection + tags: + - Post + responses: + 200: + description: 'Post collection' + content: + application/ld+json: + schema: + type: object + properties: + 'hydra:member': { type: array, items: { $ref: '#/components/schemas/Post.jsonld' } } + 'hydra:totalItems': { type: integer, minimum: 0 } + 'hydra:view': { type: object, properties: { '@id': { type: string, format: iri-reference }, '@type': { type: string }, 'hydra:first': { type: string, format: iri-reference }, 'hydra:last': { type: string, format: iri-reference }, 'hydra:previous': { type: string, format: iri-reference }, 'hydra:next': { type: string, format: iri-reference } }, example: { '@id': string, type: string, 'hydra:first': string, 'hydra:last': string, 'hydra:previous': string, 'hydra:next': string } } + 'hydra:search': { type: object, properties: { '@type': { type: string }, 'hydra:template': { type: string }, 'hydra:variableRepresentation': { type: string }, 'hydra:mapping': { type: array, items: { type: object, properties: { '@type': { type: string }, variable: { type: string }, property: { type: [string, 'null'] }, required: { type: boolean } } } } } } + required: + - 'hydra:member' + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Post' + text/html: + schema: + type: array + items: + $ref: '#/components/schemas/Post' + application/hal+json: + schema: + type: object + properties: + _embedded: { type: array, items: { $ref: '#/components/schemas/Post.jsonhal' } } + totalItems: { type: integer, minimum: 0 } + itemsPerPage: { type: integer, minimum: 0 } + _links: { type: object, properties: { self: { type: object, properties: { href: { type: string, format: iri-reference } } }, first: { type: object, properties: { href: { type: string, format: iri-reference } } }, last: { type: object, properties: { href: { type: string, format: iri-reference } } }, next: { type: object, properties: { href: { type: string, format: iri-reference } } }, previous: { type: object, properties: { href: { type: string, format: iri-reference } } } } } + required: + - _links + - _embedded + summary: 'Retrieves the collection of Post resources.' + description: 'Retrieves the collection of Post resources.' + parameters: + - + name: page + in: query + description: 'The collection page number' + required: false + deprecated: false + allowEmptyValue: true + schema: + type: integer + default: 1 + style: form + explode: false + allowReserved: false + deprecated: false + post: + operationId: api_posts_post + tags: + - Post + responses: + 201: + description: 'Post resource created' + content: + application/ld+json: + schema: + $ref: '#/components/schemas/Post.jsonld' + application/json: + schema: + $ref: '#/components/schemas/Post' + text/html: + schema: + $ref: '#/components/schemas/Post' + application/hal+json: + schema: + $ref: '#/components/schemas/Post.jsonhal' + links: { } + 400: + description: 'Invalid input' + 422: + description: 'Unprocessable entity' + summary: 'Creates a Post resource.' + description: 'Creates a Post resource.' + parameters: [] + requestBody: + description: 'The new Post resource' + content: + application/ld+json: + schema: + $ref: '#/components/schemas/Post.jsonld' + application/json: + schema: + $ref: '#/components/schemas/Post' + text/html: + schema: + $ref: '#/components/schemas/Post' + application/hal+json: + schema: + $ref: '#/components/schemas/Post.jsonhal' + required: true + deprecated: false + parameters: [] + '/api/posts/{id}': + get: + operationId: api_posts_id_get + tags: + - Post + responses: + 200: + description: 'Post resource' + content: + application/ld+json: + schema: + $ref: '#/components/schemas/Post.jsonld' + application/json: + schema: + $ref: '#/components/schemas/Post' + text/html: + schema: + $ref: '#/components/schemas/Post' + application/hal+json: + schema: + $ref: '#/components/schemas/Post.jsonhal' + 404: + description: 'Resource not found' + summary: 'Retrieves a Post resource.' + description: 'Retrieves a Post resource.' + parameters: + - + name: id + in: path + description: 'PostingApi identifier' + required: true + deprecated: false + allowEmptyValue: false + schema: + type: string + style: simple + explode: false + allowReserved: false + deprecated: false + delete: + operationId: api_posts_id_delete + tags: + - Post + responses: + 204: + description: 'Post resource deleted' + 404: + description: 'Resource not found' + summary: 'Removes the Post resource.' + description: 'Removes the Post resource.' + parameters: + - + name: id + in: path + description: 'PostingApi identifier' + required: true + deprecated: false + allowEmptyValue: false + schema: + type: string + style: simple + explode: false + allowReserved: false + deprecated: false + patch: + operationId: api_posts_id_patch + tags: + - Post + responses: + 200: + description: 'Post resource updated' + content: + application/ld+json: + schema: + $ref: '#/components/schemas/Post.jsonld' + application/json: + schema: + $ref: '#/components/schemas/Post' + text/html: + schema: + $ref: '#/components/schemas/Post' + application/hal+json: + schema: + $ref: '#/components/schemas/Post.jsonhal' + links: { } + 400: + description: 'Invalid input' + 422: + description: 'Unprocessable entity' + 404: + description: 'Resource not found' + summary: 'Updates the Post resource.' + description: 'Updates the Post resource.' + parameters: + - + name: id + in: path + description: 'PostingApi identifier' + required: true + deprecated: false + allowEmptyValue: false + schema: + type: string + style: simple + explode: false + allowReserved: false + requestBody: + description: 'The updated Post resource' + content: + application/merge-patch+json: + schema: + $ref: '#/components/schemas/Post' + required: true + deprecated: false + parameters: [] + /api/users: + get: + operationId: api_users_get_collection + tags: + - User + responses: + 200: + description: 'User collection' + content: + application/ld+json: + schema: + type: object + properties: + 'hydra:member': { type: array, items: { $ref: '#/components/schemas/User.jsonld' } } + 'hydra:totalItems': { type: integer, minimum: 0 } + 'hydra:view': { type: object, properties: { '@id': { type: string, format: iri-reference }, '@type': { type: string }, 'hydra:first': { type: string, format: iri-reference }, 'hydra:last': { type: string, format: iri-reference }, 'hydra:previous': { type: string, format: iri-reference }, 'hydra:next': { type: string, format: iri-reference } }, example: { '@id': string, type: string, 'hydra:first': string, 'hydra:last': string, 'hydra:previous': string, 'hydra:next': string } } + 'hydra:search': { type: object, properties: { '@type': { type: string }, 'hydra:template': { type: string }, 'hydra:variableRepresentation': { type: string }, 'hydra:mapping': { type: array, items: { type: object, properties: { '@type': { type: string }, variable: { type: string }, property: { type: [string, 'null'] }, required: { type: boolean } } } } } } + required: + - 'hydra:member' + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/User' + text/html: + schema: + type: array + items: + $ref: '#/components/schemas/User' + application/hal+json: + schema: + type: object + properties: + _embedded: { type: array, items: { $ref: '#/components/schemas/User.jsonhal' } } + totalItems: { type: integer, minimum: 0 } + itemsPerPage: { type: integer, minimum: 0 } + _links: { type: object, properties: { self: { type: object, properties: { href: { type: string, format: iri-reference } } }, first: { type: object, properties: { href: { type: string, format: iri-reference } } }, last: { type: object, properties: { href: { type: string, format: iri-reference } } }, next: { type: object, properties: { href: { type: string, format: iri-reference } } }, previous: { type: object, properties: { href: { type: string, format: iri-reference } } } } } + required: + - _links + - _embedded + summary: 'Retrieves the collection of User resources.' + description: 'Retrieves the collection of User resources.' + parameters: + - + name: page + in: query + description: 'The collection page number' + required: false + deprecated: false + allowEmptyValue: true + schema: + type: integer + default: 1 + style: form + explode: false + allowReserved: false + deprecated: false + post: + operationId: api_users_post + tags: + - User + responses: + 201: + description: 'User resource created' + content: + application/ld+json: + schema: + $ref: '#/components/schemas/User.jsonld' + application/json: + schema: + $ref: '#/components/schemas/User' + text/html: + schema: + $ref: '#/components/schemas/User' + application/hal+json: + schema: + $ref: '#/components/schemas/User.jsonhal' + links: { } + 400: + description: 'Invalid input' + 422: + description: 'Unprocessable entity' + summary: 'Creates a User resource.' + description: 'Creates a User resource.' + parameters: [] + requestBody: + description: 'The new User resource' + content: + application/ld+json: + schema: + $ref: '#/components/schemas/User.jsonld' + application/json: + schema: + $ref: '#/components/schemas/User' + text/html: + schema: + $ref: '#/components/schemas/User' + application/hal+json: + schema: + $ref: '#/components/schemas/User.jsonhal' + required: true + deprecated: false + parameters: [] + '/api/users/{id}': + get: + operationId: api_users_id_get + tags: + - User + responses: + 200: + description: 'User resource' + content: + application/ld+json: + schema: + $ref: '#/components/schemas/User.jsonld' + application/json: + schema: + $ref: '#/components/schemas/User' + text/html: + schema: + $ref: '#/components/schemas/User' + application/hal+json: + schema: + $ref: '#/components/schemas/User.jsonhal' + 404: + description: 'Resource not found' + summary: 'Retrieves a User resource.' + description: 'Retrieves a User resource.' + parameters: + - + name: id + in: path + description: 'UserApi identifier' + required: true + deprecated: false + allowEmptyValue: false + schema: + type: string + style: simple + explode: false + allowReserved: false + deprecated: false + patch: + operationId: api_users_id_patch + tags: + - User + responses: + 200: + description: 'User resource updated' + content: + application/ld+json: + schema: + $ref: '#/components/schemas/User.jsonld' + application/json: + schema: + $ref: '#/components/schemas/User' + text/html: + schema: + $ref: '#/components/schemas/User' + application/hal+json: + schema: + $ref: '#/components/schemas/User.jsonhal' + links: { } + 400: + description: 'Invalid input' + 422: + description: 'Unprocessable entity' + 404: + description: 'Resource not found' + summary: 'Updates the User resource.' + description: 'Updates the User resource.' + parameters: + - + name: id + in: path + description: 'UserApi identifier' + required: true + deprecated: false + allowEmptyValue: false + schema: + type: string + style: simple + explode: false + allowReserved: false + requestBody: + description: 'The updated User resource' + content: + application/merge-patch+json: + schema: + $ref: '#/components/schemas/User' + required: true + deprecated: false + parameters: [] + /auth: + post: + operationId: login_check_post + tags: + - 'Login Check' + responses: + 200: + description: 'User token created' + content: + application/json: + schema: + type: object + properties: + token: { readOnly: true, type: string, nullable: false } + required: + - token + summary: 'Creates a user token.' + description: 'Creates a user token.' + requestBody: + description: 'The login data' + content: + application/json: + schema: + type: object + properties: + email: + type: string + nullable: false + password: + type: string + nullable: false + required: + - email + - password + required: true + parameters: [] +components: + schemas: + Post: + type: object + description: '' + deprecated: false + required: + - message + properties: + message: + type: + - string + - 'null' + owner: + 'owl:maxCardinality': 1 + type: + - string + - 'null' + format: iri-reference + example: 'https://example.com/' + createdAt: + readOnly: true + type: + - string + - 'null' + format: date-time + Post.jsonhal: + type: object + description: '' + deprecated: false + required: + - message + properties: + _links: + type: object + properties: + self: + type: object + properties: + href: + type: string + format: iri-reference + message: + type: + - string + - 'null' + owner: + 'owl:maxCardinality': 1 + type: + - string + - 'null' + format: iri-reference + example: 'https://example.com/' + createdAt: + readOnly: true + type: + - string + - 'null' + format: date-time + Post.jsonld: + type: object + description: '' + deprecated: false + required: + - message + properties: + '@context': + readOnly: true + oneOf: + - + type: string + - + type: object + properties: + '@vocab': + type: string + hydra: + type: string + enum: ['http://www.w3.org/ns/hydra/core#'] + required: + - '@vocab' + - hydra + additionalProperties: true + '@id': + readOnly: true + type: string + '@type': + readOnly: true + type: string + message: + type: + - string + - 'null' + owner: + 'owl:maxCardinality': 1 + type: + - string + - 'null' + format: iri-reference + example: 'https://example.com/' + createdAt: + readOnly: true + type: + - string + - 'null' + format: date-time + User: + type: object + description: '' + deprecated: false + required: + - email + - firstName + - lastName + properties: + email: + format: email + externalDocs: + url: 'https://schema.org/email' + type: + - string + - 'null' + firstName: + type: + - string + - 'null' + lastName: + type: + - string + - 'null' + password: + writeOnly: true + description: 'The plaintext password when being set or changed.' + type: + - string + - 'null' + active: + type: boolean + createdAt: + readOnly: true + type: + - string + - 'null' + format: date-time + userPosts: + type: array + items: + type: string + format: iri-reference + example: 'https://example.com/' + User.jsonhal: + type: object + description: '' + deprecated: false + required: + - email + - firstName + - lastName + properties: + _links: + type: object + properties: + self: + type: object + properties: + href: + type: string + format: iri-reference + email: + format: email + externalDocs: + url: 'https://schema.org/email' + type: + - string + - 'null' + firstName: + type: + - string + - 'null' + lastName: + type: + - string + - 'null' + password: + writeOnly: true + description: 'The plaintext password when being set or changed.' + type: + - string + - 'null' + active: + type: boolean + createdAt: + readOnly: true + type: + - string + - 'null' + format: date-time + userPosts: + type: array + items: + type: string + format: iri-reference + example: 'https://example.com/' + User.jsonld: + type: object + description: '' + deprecated: false + required: + - email + - firstName + - lastName + properties: + '@context': + readOnly: true + oneOf: + - + type: string + - + type: object + properties: + '@vocab': + type: string + hydra: + type: string + enum: ['http://www.w3.org/ns/hydra/core#'] + required: + - '@vocab' + - hydra + additionalProperties: true + '@id': + readOnly: true + type: string + '@type': + readOnly: true + type: string + email: + format: email + externalDocs: + url: 'https://schema.org/email' + type: + - string + - 'null' + firstName: + type: + - string + - 'null' + lastName: + type: + - string + - 'null' + password: + writeOnly: true + description: 'The plaintext password when being set or changed.' + type: + - string + - 'null' + active: + type: boolean + createdAt: + readOnly: true + type: + - string + - 'null' + format: date-time + userPosts: + type: array + items: + type: string + format: iri-reference + example: 'https://example.com/' + responses: { } + parameters: { } + examples: { } + requestBodies: { } + headers: { } + securitySchemes: + JWT: + type: http + scheme: bearer + bearerFormat: JWT +security: + - + JWT: [] +tags: [] +