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

Cannot read property 'depricated' of undefined #34

Closed
TAGC opened this issue Feb 4, 2020 · 4 comments
Closed

Cannot read property 'depricated' of undefined #34

TAGC opened this issue Feb 4, 2020 · 4 comments

Comments

@TAGC
Copy link

TAGC commented Feb 4, 2020

I'm trying to generate a PDF from a Swagger document containing a deprecated endpoint and the operation fails. I see this in the console output:

rapipdf-min.js:45609 Uncaught (in promise) TypeError: Cannot read property 'depricated' of undefined
    at rapipdf-min.js:45609
    at Array.map (<anonymous>)
    at M (rapipdf-min.js:45609)
    at B (rapipdf-min.js:45609)
    at rapipdf-min.js:45609
    at Array.map (<anonymous>)
    at D (rapipdf-min.js:45609)
    at A (rapipdf-min.js:45609)
    at A.next (<anonymous>)
    at y (rapipdf-min.js:45609)

I assume that the error is caused by this line in the RapiPdf source code:

(paramSchema.depricated ? { text: `\n${localize.deprecated}`, style: ['small', 'red', 'b'] } : undefined),

Should it be paramSchema.deprecated instead?

@TAGC
Copy link
Author

TAGC commented Feb 4, 2020

Nevermind, I see the problem:

The document I'm using has the following content:

  "paths": {
    "/api/Quote": {
      "post": {
        "tags": [
          "Quote"
        ],
        "summary": "Generates a new quote in the Sales Office system.",
        "parameters": [
          {
            "name": "application",
            "in": "header"
          },
          {
            "name": "user-key",
            "in": "header"
          }
        ],

RapiPdf seems to require that these have a schema property, and according to the OpenApi 3 spec it seems that all parameters are required to have a schema or content property in which case that seems like an error within the document and not RapiPdf.

I manually create these headers in my backend code so I should be able to fix this, test it works and then close this ticket:

private static readonly OpenApiParameter ApplicationParameter = new OpenApiParameter
{
    Name = "application",
    In = ParameterLocation.Header,
    Required = false
};

private static readonly OpenApiParameter UserKeyParameter = new OpenApiParameter
{
    Name = "user-key",
    In = ParameterLocation.Header,
    Required = false
};

@TAGC
Copy link
Author

TAGC commented Feb 4, 2020

The PDF was generated once I fixed up the document that got created:

private static readonly OpenApiParameter ApplicationParameter = new OpenApiParameter
{
    Name = "application",
    In = ParameterLocation.Header,
    Required = false,
    Schema = new OpenApiSchema()
};

private static readonly OpenApiParameter UserKeyParameter = new OpenApiParameter
{
    Name = "user-key",
    In = ParameterLocation.Header,
    Required = false,
    Schema = new OpenApiSchema()
};

Is paramSchema.depricated still meant to be paramSchema.deprecated though?

@mrin9
Copy link
Owner

mrin9 commented Feb 5, 2020

yes paramSchema.depricated should be paramSchema.deprecated
thanks for pointing it out, will get it fixed in our next patch

@mrin9
Copy link
Owner

mrin9 commented Feb 16, 2020

fixed in release 2.1.1

@mrin9 mrin9 closed this as completed Feb 16, 2020
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