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

Support ETag and Last-Modified in Response #71

Open
sdavids opened this issue Apr 23, 2020 · 2 comments
Open

Support ETag and Last-Modified in Response #71

sdavids opened this issue Apr 23, 2020 · 2 comments

Comments

@sdavids
Copy link

sdavids commented Apr 23, 2020

Docker Image used: 6c07143937e57095d8478efc8ab7eab52b44e67c7673285f8c0a2bf4a7b137ad

openapi: 3.0.3
info:
  title: test
  version: '1.0'
servers:
  - url: 'http://localhost:8000'
paths:
  /test:
    get:
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                    default: 'true'
              examples:
                a:
                  value:
                    ok: true
          headers:
            ETag:
              schema:
                type: string
              example: '"c561c68d0ba92bbeb8b0f612a9199f722e3a621a"'
            Last-Modified:
              schema:
                type: string
              example: Mon, 18 Jul 2016 02:36:04 GMT

Will return:

HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Content-Type: application/json
Etag: string
Last-Modified: string
Date: Thu, 23 Apr 2020 22:38:43 GMT
Content-Length: 16

Either the example values should be provided or (better) real values should be generated.

@sdavids
Copy link
Author

sdavids commented Apr 24, 2020

This is related to #46.

In the case of:

ETag:
  schema:
    type: string
Last-Modified:
  schema:
    type: string

The output would preferably be:

Etag: ${eTag}
Last-Modified: ${lastModified}

with

const serverStartup = new Date();

// ...

const lastModified = `${serverStartup}`;
const eTag = `"${serverStartup.getTime()}"`;

instead of

Etag: string
Last-Modified: string

You might even return those 2 headers regardless of their inclusion in the OpenAPI file.

@cboitel
Copy link

cboitel commented Sep 9, 2020

i would use serverStartup only if examples are not provided: after all, apisprout is all about serving examples

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

No branches or pull requests

2 participants