koshevy / codegena

Tools for codegeneration from OAS3 to TypeScript. Actual Roadmap published — https://github.com/koshevy/codegena/blob/codegena-3.x/ROADMAP.md
https://codegena-playground.stackblitz.io/
MIT License
38 stars 1 forks source link

Support Nullable #39

Closed stepanzabelin closed 4 years ago

stepanzabelin commented 4 years ago

Hi! I found out that Nullable is not working

image

image

https://swagger.io/docs/specification/data-models/data-types/

koshevy commented 4 years ago

@stepanzabelin Hi! It's weird, have marked as a bug. Thanks you.

stepanzabelin commented 4 years ago

Hello @koshevy how are you? I guess you are busy lately The resolution of this bug is quite important for several projects, I hope you will find time to fix it, thanks

koshevy commented 4 years ago

@stepanzabelin Hello! Yes, that's right — big project. End of this week I gonna on vacation, this weekend I ll do it!

koshevy commented 4 years ago

@stepanzabelin Please, check update with versions from this commit: https://github.com/koshevy/codegena/commit/a7a1d6364c48a544ec4d184bbe317b073f9d881a

stepanzabelin commented 4 years ago

Hi, I've upgrated the following packages

But there is still the same problem :(

{"openapi":"3.0.0","info":{"title":"test","description":"[Swagger.json](/api/development/document-json)","version":"0.0.1","contact":{}},"tags":[],"servers":[],"components":{"schemas":{"FormProjectLocaleLocaleDto":{"type":"object","properties":{"id":{"type":"number"},"name":{"type":"string"},"enName":{"type":"string"},"locale":{"type":"string"}},"required":["id","name","enName","locale"]},"FormProjectLocaleProjectDto":{"type":"object","properties":{"id":{"type":"number"},"tag":{"type":"string"},"name":{"type":"string"},"description":{"type":"string"}},"required":["id","tag","name","description"]},"FormProjectLocaleDataDto":{"type":"object","properties":{"id":{"type":"number"},"locale":{"$ref":"#/components/schemas/FormProjectLocaleLocaleDto"},"project":{"allOf":[{"$ref":"#/components/schemas/FormProjectLocaleProjectDto"},{"nullable":true}]},"project2":{"type":"string","nullable":true}},"required":["id","locale","project","project2"]},"RowIdDataDto":{"type":"object","properties":{"id":{"type":"number"}},"required":["id"]}}},"paths":{"/test/projectLocales/get/{id}":{"get":{"operationId":"getProjectLocaleById","summary":"getProjectLocaleById","description":"### operationId: getProjectLocaleById\n","parameters":[{"name":"Security","in":"header","description":"Security","schema":{"type":"string"}},{"name":"id","required":true,"in":"path","schema":{"type":"number"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FormProjectLocaleDataDto"}}}}},"tags":["ProjectLocales"]}},"/test/projectLocales/delete/{id}":{"delete":{"operationId":"deleteProjectLocaleById","summary":"deleteProjectLocaleById","description":"### operationId: deleteProjectLocaleById\n","parameters":[{"name":"Security","in":"header","description":"Security","schema":{"type":"string"}},{"name":"id","required":true,"in":"path","schema":{"type":"number"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RowIdDataDto"}}}}},"tags":["ProjectLocales"]}}}}

Could you look up this json and check it ?

koshevy commented 4 years ago

@stepanzabelin I had looked your schema and understood problem you met. It's supposed in previous update, nullable should be in param description.

Now it has to be supported in every place. So, I had checked your example, project2 prop supports null:

import { FormProjectLocaleLocaleDto } from './form-project-locale-locale-dto';
import { FormProjectLocaleProjectDto } from './form-project-locale-project-dto';

export interface FormProjectLocaleDataDto {
  id: number;
  locale: FormProjectLocaleLocaleDto;
  project: FormProjectLocaleProjectDto;
  project2: null | string;
}

Please check following versions: https://github.com/koshevy/codegena/commit/7a3f1b587ac353cd1809b14cbcc6d388901d75f9