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

All properties are always optional #59

Closed
alesdvorakcz opened this issue Jun 24, 2020 · 3 comments
Closed

All properties are always optional #59

alesdvorakcz opened this issue Jun 24, 2020 · 3 comments

Comments

@alesdvorakcz
Copy link

alesdvorakcz commented Jun 24, 2020

Hi,
I am wondering why from this schema:

Manufacturer: {
  type: "object",
  properties: {
    id: {
      type: "string",
      format: "uuid"
    },
    created: {
      type: "string",
      format: "date-time"
    },
    modified: {
      type: "string",
      format: "date-time"
    },
    name: {
      type: "string",
      nullable: true
    },
    identificationNumber: {
      type: "string",
      nullable: true
    }
  },
  additionalProperties: false
},

I am getting this:

export interface Manufacturer {
  id?: string;
  created?: string;
  modified?: string;
  name?: string | null;
  identificationNumber?: string | null;
}

instead of this:

export interface Manufacturer {
  id: string;
  created: string;
  modified: string;
  name: string | null; //or name?: string;
  identificationNumber: string | null;  //or identificationNumber?: string;
}

Am I doing something wrong?

@js2me
Copy link
Member

js2me commented Jun 24, 2020

Hello @alesdvorakcz ! Can you say the version of usage schema ? (3.0, 3.1, 2.0)
If you are using 2.0 version then you should add the list of required properties like in this schema:
https://github.com/acacode/swagger-typescript-api/blob/master/tests/schemas/v2.0/authentiq.json#L870

@js2me
Copy link
Member

js2me commented Jun 24, 2020

Same thing you should do with 3.0+ versions:
(example with Open API 3.0)
https://github.com/acacode/swagger-typescript-api/blob/master/tests/schemas/v3.0/personal-api-example.json#L134

@alesdvorakcz
Copy link
Author

You are right, its what I am missing in my schema (3.0)

Thank you for fast response and amazing project!

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