swagger-api / swagger-parser

Swagger Spec to Java POJOs
http://swagger.io
Apache License 2.0
780 stars 525 forks source link

$schema is null but the value of $schema should be string #2107

Open mpet opened 3 months ago

mpet commented 3 months ago

Hi,

I am trying this code and parsing https://forge.3gpp.org/rep/sa5/MnS/-/blob/Integration_Rel16_SA5_155_YAML/OpenAPI/TS28532_FaultMnS.yaml

    ParseOptions parseOptions = new ParseOptions();
    parseOptions.setResolve(true); // implicit
    parseOptions.setResolveFully(true);
   String openApiSpec = schemaReference.getUrl(); // Replace with the actual path to your OpenAPI file
    SwaggerParseResult result = new OpenAPIV3Parser().readLocation(openApiSpec, null, null);
    if (result.getMessages().isEmpty()) {
        OpenAPI openAPI = result.getOpenAPI();

        // Extract the schema from the OpenAPI specification
        ObjectMapper mapper = new ObjectMapper();
        JsonNode schemaNode = mapper.convertValue(
               openAPI.getComponents().getSchemas().get("NotifyNewAlarm"), JsonNode.class);

        // Convert the schemaNode to JSONObject
       JSONObject jsonSchema = new JSONObject(new JSONTokener(schemaNode.toString()));

image

As you can see the $schema is null but the value of $schema should be string.

Any ideas what I am lacking?

//mike